Welcome Guest, Not a member yet? Register   Sign In
Translated Routes
#1

(This post was last modified: 07-19-2020, 01:18 PM by kilden.)

Hello,

I've got a question about localization and translated routes :
I wonder if there is a solution to combine  'named routes' and the 'lang() function' to translate URL and keep the app very simple to update for future developments.

First I made my translations in Routes.php like this :


PHP Code:
/*In my template-view header.php*/ 
echo '<a class="menu" href="'.$base.route_to('studio_'.$locale).'">'.lang('App.menu.studio').'</a>';  

/* In Routes.php (translations in Routes for all languages and all routes... :-/ )*/ 
$routes->get('{locale}/the_studio''Home::index', ['as' => 'studio_en']); 
$routes->get('{locale}/l_atelier''Home::index', ['as' => 'studio_fr']);  

/*In app/Language/en/app.php (only for hyperlink)*/ 
return [  'menu'  => [    'studio' => 'the studio'  ] ]; 


If possible I would like to put all translations in app/Language... I've tried this without success :


PHP Code:
/*In my template-view header.php*/ 
echo '<a class="menu" href="'.$base.route_to('studio').'">'.lang('App.menu.studio').'</a>';  

/* In Routes.php */ 
$routes
->get('{locale}/'.lang('App.url.studio'), 'Home::index', ['as' => 'studio']);  

/*In app/Language/en/app.php */ 
return [  
   
'url'  => [    'studio' => "the_studio"  ],  
   
'menu'  => [    'studio' => 'the studio'  ]
]; 


It almost works, because Routes.php reads a part of the translation... but just the default language. there is no update of the locale with {locale}... Do you know a way to do it ?

Thank you for any help !
Reply


Messages In This Thread
Translated Routes - by kilden - 07-19-2020, 01:15 PM
RE: Translated Routes - by kilden - 07-21-2020, 02:54 AM
RE: Translated Routes - by kilden - 07-21-2020, 04:38 AM
RE: Translated Routes - by nicojmb - 07-21-2020, 06:35 AM
RE: Translated Routes - by kilden - 07-24-2020, 05:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB