mercredi 28 juin 2017

Use translation strings in routes in Laravel

Hi I try to use localization (__() or trans()) on my routes, however it does not seem to work.

Done so far

  • wrote the routes
  • determined what the locale should be in a serviceprovider

for example

Route::any(trans('routes.account') . '/' . trans('routes.login'), 'SomeController@SomeFunc');

Those translation lang files are filled

I determine the locales in a serviceprovider

class DefaultLocalesProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        switch (url('/')) {
            case 'https://www.example.nl':
                App::setLocale('nl_NL');
                break;
            case 'http://ift.tt/1owT7EK':
                App::setLocale('en_GB');
                break;
    } //etc.
}

It almost looks like the keys don't get translated at all, but just returned the keys themself. Here is my xdebug output on the last line of web.php.

enter image description here



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire