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.

Route aliases ?

Hello,

i just curious ..

so i have multi module app. my router more or less is :

foreach ($application->getModules() as $key => $module) {
                    $router->add('/'.$key.'/:params', array(
                        'module' => $key,
                        'controller' => 'index',
                        'action' => 'index',
                        'params' => 1
                    ))->setName($key);

                    $router->add('/'.$key.'/:controller/:params', array(
                        'module' => $key,
                        'controller' => 1,
                        'action' => 'index',
                        'params' => 2
                    ));

                    $router->add('/'.$key.'/:controller/:action/:params', array(
                        'module' => $key,
                        'controller' => 1,
                        'action' => 2,
                        'params' => 3
                    ));
                }

so now if i call /user/profile/ it goes to module: users and controller profile.

What i want to achive is can I tweak the url in other language ? :), so for example in Bulgarian will be something like /потребител/профил

so calling /потребител/профил (URI) will be the same as /user/profile/

Thanks



33.7k
Accepted
answer

A static route would help

$router->add('/'.$key.'/потребител/профил', array(
    'module' => $key,
    'controller' => 'user',
    'action' => 'profile'
));