Cheers, I've changed my translation from nativ Laravel to this package, because it looks much easier for my translation team to work with po/mo instead of php and json.
The .po generation and the Poedit "Actualizar" are working like a charm.
The Problem:
My translation team (greek -> el_GR) filled the .po files with the translations and gave them back to me. I changed the saved .po and .mo files in my resources folder and restarted the webserver. But when I change the active local with your controller example (works!) I can only see the default fallback local german (de_DE). The .mo files are ignored. I tried around a couple days but nothing works. If I run LaravelGettext::getLocale(); at a breakpoint on my compiled view it returns the correct locale but the _i('foobar') isn't correct. My folder structur is the generated from the beginning:
DE
../resources/lang/i18n/de_DE/LC_MESSAGES/messages.po
../resources/lang/i18n/de_DE/LC_MESSAGES/messages.mo
GR
../resources/lang/i18n/el_GR/LC_MESSAGES/messages.po
../resources/lang/i18n/el_GR/LC_MESSAGES/messages.mo
EN
../resources/lang/i18n/en_US/LC_MESSAGES/messages.po
../resources/lang/i18n/en_US/LC_MESSAGES/messages.mo
Project environment:
Laravel: 5.7
Virtual Box Package: laravel/homestead 8.0
Installed locales (+utf8 generation): de_DE, el_GR, en_US
Active Webserver: Nginx
I use LaravelGettext and not php-gettext
Configuration:
/**
* Translation handlers, options are:
*
* - symfony: (recommended) uses the symfony translations component. Incompatible with php-gettext
* you must uninstall the php-gettext module before use this handler.
*
* - gettext: requires the php-gettext module installed. This handler has well-known cache issues
*/
'handler' => 'symfony',
/**
* Session identifier: Key under which the current locale will be stored.
*/
'session-identifier' => 'laravel-gettext-locale',
/**
* Default locale: this will be the default for your application.
* Is to be supposed that all strings are written in this language.
*/
'locale' => 'de_DE',
/**
* Supported locales: An array containing all allowed languages
*/
'supported-locales' => [
'de_DE',
'el_GR',
'en_US',
],
/**
* Default charset encoding.
*/
'encoding' => 'UTF-8',
Is there something I can check? Did I forgot something?
If you have any questions, or if you would like further information or code, please don't hesitate to contact me.
Thanks for checking my issue!
Update
I've debugged the loading of the catalogues. The german changes in the .mo file are changed. The el_GR messages are empty:
Update - Solution
The solution was to build a middleware and to call loadLocaleFile after setting the active locale.
Cheers, I've changed my translation from nativ Laravel to this package, because it looks much easier for my translation team to work with po/mo instead of php and json.
The .po generation and the Poedit "Actualizar" are working like a charm.
The Problem: My translation team (greek -> el_GR) filled the .po files with the translations and gave them back to me. I changed the saved .po and .mo files in my resources folder and restarted the webserver. But when I change the active local with your controller example (works!) I can only see the default fallback local german (de_DE). The .mo files are ignored. I tried around a couple days but nothing works. If I run
LaravelGettext::getLocale();
at a breakpoint on my compiled view it returns the correct locale but the_i('foobar')
isn't correct. My folder structur is the generated from the beginning:DE ../resources/lang/i18n/de_DE/LC_MESSAGES/messages.po ../resources/lang/i18n/de_DE/LC_MESSAGES/messages.mo GR ../resources/lang/i18n/el_GR/LC_MESSAGES/messages.po ../resources/lang/i18n/el_GR/LC_MESSAGES/messages.mo EN ../resources/lang/i18n/en_US/LC_MESSAGES/messages.po ../resources/lang/i18n/en_US/LC_MESSAGES/messages.mo
Project environment: Laravel: 5.7 Virtual Box Package: laravel/homestead 8.0 Installed locales (+utf8 generation): de_DE, el_GR, en_US Active Webserver: Nginx I use LaravelGettext and not php-gettext
Configuration:
Is there something I can check? Did I forgot something? If you have any questions, or if you would like further information or code, please don't hesitate to contact me. Thanks for checking my issue!
Update I've debugged the loading of the catalogues. The german changes in the .mo file are changed. The el_GR messages are empty:![no-loaded-messages-from-mo](https://user-images.githubusercontent.com/22943809/60096440-3e026400-9751-11e9-86d8-16b71689caa5.png)
Update - Solution The solution was to build a middleware and to call
loadLocaleFile
after setting the active locale.Now i'm using:
instead of:
Thanks @stfr from issue #26.