Translate in a specific language in Laravel
There are 3 ways to achieve this:
- You can change default language at runtime by doing this:
App::setLocale('fr');
NB: This is not suitable for your current need as it will only take effect on next page load.
- You can set default language here app/config/app.php
'fallback_locale' => 'fr'
I took a deeper look at Illuminate\Translation\Translator:
get($key, array $replace = array(), $locale = null)
This means you can do this using Translator Facade:
Lang::get($key, array $replace = array(), $locale = null);
Example:
Lang::get('group.key',[],'fr');
NB: You folder structure should look like this
/app
/lang
/en
messages.php
/fr
messages.php
To get a language specific translation - different from the current locales without setting and unsetting the locales, just do
__('description_1', [], 'en')