You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I've a LanguageFilter wiht method "before" to check session value and set current languange with method setLanguage($locale) in the codigniter request classs.
In debug toolbar the the laguage is correct but translations show incorrect language (when i use lang() always return default language translation).
the problem only happens when i've an lang() function call before the request()->setLocale($language) and static service language not update when run setLocale($locale) and return next translation with default locale.
The translation files are correct, if i change default language to english, showme "logout" twice :(
If i comment the first lang() then works as expected.
CodeIgniter 4 version
4.0.4
Affected module(s)
Language Helper
Language Service
Expected behavior, and steps to reproduce if appropriate
lang() function get correct translation after "setLocale" function.
Context
OS: Centos
Web server: Nginx
PHP version: 7.4.10
The text was updated successfully, but these errors were encountered:
nicojmb
added
the
bug
Verified issues on the current code behavior or pull requests that will fix them
label
Sep 13, 2020
This is not a bug. When we call lang() function for the first time we simply initialize the shared language service. The next call to lang() operates on the same instance as before so that's why there is no change - despite changing the locale for the request.
You should use service('language')->setLocale($lang) instead.
Great, i try and works, boy also needs to call "service('request')->setLocale($lang);" to update request current language if not the debug toolbar showme incorrect language buy translations works.
Describe the bug
I've a LanguageFilter wiht method "before" to check session value and set current languange with method setLanguage($locale) in the codigniter request classs.
In debug toolbar the the laguage is correct but translations show incorrect language (when i use lang() always return default language translation).
the problem only happens when i've an lang() function call before the request()->setLocale($language) and static service language not update when run setLocale($locale) and return next translation with default locale.
The translation files are correct, if i change default language to english, showme "logout" twice :(
If i comment the first lang() then works as expected.
CodeIgniter 4 version
4.0.4
Affected module(s)
Language Helper
Language Service
Expected behavior, and steps to reproduce if appropriate
lang() function get correct translation after "setLocale" function.
Context
The text was updated successfully, but these errors were encountered: