Reputation: 289
How I can get current language in Laravel? I need get these codes: ro_RO
, en_US
e.t.c..
When I write:
app()->getLocale();
I get only: ro
, en
..
How I can get: ro_RO
, en_US
e.t.c?
I need set these codes for function setLocale
:
setlocale(LC_ALL,app()->getLocale() . '.UTF-8');
My solution is not working.
Upvotes: 2
Views: 1595
Reputation: 18557
Default is set in config/app.php
as en
change it to
'locale' => 'en_US',
You can add multiple locales as below
'locales' => ['en_US' => 'English', 'ro_RO' => 'Romanian'],
And fire the command,
php artisan config:cache
It should work.
By using official doc, you can set locale as
$locale = App::getLocale();
App::setLocale($locale);
Upvotes: 2