Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

web-chiru's avatar

mulity language dynamically?

how laravel manages multi language functionality? in both 4.2 or any change in 4.3

0 likes
4 replies
milon's avatar

just create a folder on lang file. in 4.2 its in app/lang and in 5 resources/lang. in each folder create various language file of same name and set default language 'locale' => 'folder_name' in app/config/app.php in 4.2 and in 5 its config/app.php file. you can set your language in runtime by just adding one line. App::setLocale('es'); cool right?

keevitaja's avatar

Laravel doesn't do much for multilingual support.

There is one package for laravel 4, but it is not ready for 5: https://github.com/mcamara/laravel-localization

I would not use it. Imho the best way would be to get rid of the locale slug from uri in index.php and then define a constant and use it in app.php locale key. perhaps it is possible to remove it inside the system as well. i have not done that before with laravel, but i will soon in my current project.

to get the idea, from where laravel searches the uri, see https://github.com/symfony/HttpFoundation/blob/master/Request.php#L1614

i think with apache and nginx REQUEST_URI is safe!

this way it would work in every app.

if anyone has info on how to remove the locale slug "the right way", i would like to know that as well.

web-chiru's avatar

What if i need to manage the dynamic content language specific?

keevitaja's avatar

if you want't to know about database setup, then perhaps this could help you

https://laracasts.com/discuss/channels/requests/eloquent-with-database-multi-language-best-practices

and if you need to setup your system with locale info in uri, see my previous post. i bet this is the at least a good solution. with mcamara/laravel-localization package i think the locale slug will remain in uri, which will give you a decent headache when you have to work with uris.

Please or to participate in this conversation.