Support the ongoing development of Laravel.io →
Configuration Views
Last updated 2 years ago.
0

I am currently learning to localize my L5 installation, thus, I am interested in this topic. As far as I can tell, the localization still works out of the box with L5. You have a default language set in the config and a fallback language. And according to my experience, this is fetching the respective language resource from the respective folders.

http://laravel.com/docs/5.0/localization

But L5 (and I guess L4 too) does not have a native multilanguage feature. You will probably have to install a package for that. Something like

https://github.com/mcamara/laravel-localization

Question: Where exactly did you try to use the 'trans' method? In a view file? I can only confirm that it works properly in view files so far...

Last updated 9 years ago.
0

Localization itself works out of the box in L4 and L5, but there is one difference: In L4 you could add whatever folder structure you like to your app/lang/{locale}/directory, you could easily access those files (even in subdirs) by Lang::get('directory_1.directory_2.[...].directory_n.key') in your views.

In L5 only those files in the directory resources/lang/{locale}/(without subdirs) are loaded. A value in resources/lang/en/foo/bar.php cannot be called in views by Lang::get('foo.bar.key') (which is by the way the same like trans('foo.bar.key')).

Having multiple lang files, I find it reasonable to organize those in several subfolders.

0

You may be right. I think I tried subfolders too at the beginning, but decided then to use underscores to "categorize" my language files, e.g. foo_bar.php. I will check asap. I will then also try other delimiters like '/'.

0

For your example you need to specify the path as:

trans('foo/bar.key');

0

For those who are facing the same problem with sub directories in Laravel 5. Its working, but you have to add a slash to the directories instead of a point.

e.g

{{ trans('foo/bar/foo.key') }}
Last updated 9 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

ndrskln ndrskln Joined 23 Feb 2015

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.