Closed stfr closed 5 years ago
Hi, I have the same problem. How do you call loadLocaleFile
on your middleware? How do you initialise the extended translator/ get the translator reference?
It's been a while, but I think we added this line in our custom Locale Middleware which define locale from the url :
// Set locale and refresh locale file
LaravelGettext::getTranslator()->setLocale($locale);
it will directly force the locale in the translator Class, which refresh the cache.
Tell me if it works, I forgot to close this issue :)
It works! I used LaravelGettext::setLocale($sessionLocale)
and these resource file problem drove me crazy...
Many many thanks!
Hello, First of all, thanks for this package ! :)
In my project, locale is changed by a custom LocaleMiddleware, which take the lang from the URL ( /en/my-page), and change it with
LaravelGetText::setLocale()
+App::setLocale()
But it doesn't work perfectly. This is what happens :
/fr/ma-page
) : French file is loaded/es/mi-pagina
): Spanish file is loaded/es/mi-pagina
: French is back (butApp::getLocale()
&LaravelGettext::getLocale()
returns Spanish)So, it seems to be something related to the cache. I tried lot of things, but i'm running out of ideas. Someone have ever seen this case ?
I have found an ugly solution: extend the Symfony Translator to put the
loadLocaleFile
method as public, in order to call it at the end of my LocaleMiddleware, after theLaravelGettext::setLocale()
...