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

(This post was last modified: 07-21-2020, 02:57 AM by kilden.)

So, Is there no solution to avoid translations into routes.php ?

The best I could do (because the function 'lang' in Routes.php doesn't recognize current locale) looks like this :

PHP Code:
/*in Routes.php*/
$routes->get('fr/'.lang('App.url.art_direction_fr'), 'Pages::art_direction', ['as' => 'art_direction_fr']);
$routes->get('en/'.lang('App.url.art_direction_en'), 'Pages::art_direction', ['as' => 'art_direction_en']);

/*in view header.php*/
echo '<li><a class="menu" href="'.$base.route_to('art_direction_'.$locale).'">'.lang('App.menu.art_direction').'</a></li>';

/*in app/Language/fr/app.php ('fr' is the default language)*/
return [
  'url'  => [
    'art_direction_fr' => 'direction_artistique',
    'art_direction_en' => 'art_direction',  ],

  'menu'  => [ 'art_direction' => 'direction artistique';  ]
]; 
But with that solution, it's not very clean...
Routes.php doesn't recognize current $locale, so I need two lines... And all translations of urls are in app/Language/fr/app.php which is pretty dumb and illogical.

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