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

davidleads's avatar

Multi Language in Laravel

Lets assume I have a big blog with around 8-9 different languages.. Is there any practical solution to manage all the translations? Do I really have to store every string of the other language in a file within the resources\lang directory? I have different content writes which are supposed to update different parts of the blog during the time.. It's not realistic for me to give an access to these translation PHP files. Is there some out-of-the-box solution for this one?

0 likes
6 replies
haheap's avatar

I have used the package Astrotomic/laravel-translatable before.

It's great for making your models translatable - for instance blog posts etc.

Is that what you're after or are you looking for translations of the 'fixed' text like menus and forms?

davidleads's avatar

I was talking about something which is more similar to WPML (of wordpress) - That i'll be able to manage these translations in some dashboard instead of taking care of .json files all the time. That's kinda not an intuitive way to manage so many languages and so much data.

davidleads's avatar

Well, now I can see that it's scanning __("String to be translated") within the views and knows how to manage their translations. But what if I'm retrieving dynamic data from the db inside a blade tag? For example, let's take 'user_profession.blade.php' -

...
$user_profession = $user->profession;
$current_language = App::getLocale();
<p>
__('Profession'): {{Lang::get($current_language,[], $user_profession )}}
</p>
...

So yeah, It will scan the first 'Profession' string and will let me manage it inside its' nice GUI template, but let's assume I have 5 pre-defined professions in the DB and I wish to hold a translation for each of them.. So let's say if the current user's profession is Carpenter, and getLocale() is 'it' (italian) - then logically it should retrieve the italian translation for the Carpenter english word, but langly won't scan it since it doesn't start with the '__' prefix, and i still need to manage the user's professions translations in .json file, or am I missing something?

Please or to participate in this conversation.