Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

language in url and translated routes


i want to have my routes follow this format so for english we have for italian we have if i call should not work

i'm not sure how to explain better

is this kind of thing possible with phalcon ? how would you do this ?

thanks in advance for any help


You can create your routes that way:


$router = new Phalcon\Mvc\Router(false);

$router->add('/{language:[a-z]+}/:controller/:action', array(
    'controller' => 2,
    'action' => 3

$router->add('/{language:[a-z]+}/:controller/:action/:params', array(
    'controller' => 2,
    'action' => 3,
    'params' => 4

thanks i will try and come back if i have problems

I know that this discussion is rather old, but I've the same problem that quasiperfect had. The answer from phalcon reports exactly what I had done in my project, but there is one thing I did not understand: how do you translate the url without duplicating controllers and actions for each language?

I have followed also this discussion: I am not sure, however, if that is the best answer for me; it use a redirection, but I want to use only one request. Is there in Phalcon a tool to do that?

Thank you very much.