zerospam / laravel-gettext

Adds localization support to laravel applications using PoEdit and GNU-Gettext.
99 stars 56 forks source link

Method setLocale doens't work when called more than 1 time #7

Closed dnmarques closed 6 years ago

dnmarques commented 6 years ago

Using php artisan tinker, I always able to reproduce this:

1)

\LaravelGettext::getLocale(); => "en_US" 2) _i('View Order'); => "View Order" 3) \LaravelGettext::setLocale('pt_PT'); => Xinax\LaravelGettext\LaravelGettext {#733} 4) _i('View Order'); => "Visualizar Pedido" 5) \LaravelGettext::setLocale('en_US'); => Xinax\LaravelGettext\LaravelGettext {#733} 6) _i('View Order'); => "Visualizar Pedido"

I guess the last sentence should be in en_US. Any ideia how to solve?

dnmarques commented 6 years ago

The problem was that the fallback-locale was set to 'pt_PT'. As 'en_US' is the default locale, it has no translations and was falling on the fallback.

I fixed this changing the fallback-language to 'en_US'.