I am resurrecting this thread because I have to, and I don't see it practical to open a new one.
After following kasimi's suggestion, I am trying (once again) to use the following code...
Code: Select all
$user_row = $this->user_loader->get_user($sleeper['user_id']);
$user_instance = new \phpbb\user($language, $sleeper['user_timezone']);
$user_instance->lang_name = $user_instance->data['user_lang'] = $sleeper['user_lang'];
$user_instance->timezone = $user_instance->data['user_timezone'] = $sleeper['user_timezone'];
$user_instance->add_lang_ext('andreask/ium', 'body');
First of all I'd like to point that for this to work, I need to inject
language
. (but this is another story).
My problem is now that even though most of language works fine.
Meaning this works fine
$user_instance->add_lang_ext('andreask/ium', 'body');
It changes according to users language, but of course this is only because I specify the language during on
template()
of
messenger
.
$messenger->template('@andreask_ium/sleeper', $lang);
But if I use for instance this
$user_instance->lang('INCLUDE_FORUM_TOPICS')
I only get the English. version.
If I do a dump on user_instance the correct language is set everywhere but here...
Code: Select all
object(phpbb\user)[147]
protected 'language' =>
object(phpbb\language\language)[105]
protected 'common_language_files' =>
array (size=1)
0 => string 'common' (length=6)
protected 'common_language_files_loaded' => boolean true
protected 'default_language' => string 'el' (length=2)
protected 'user_language' => string 'en' (length=2)
protected 'language_fallback' =>
array (size=3)
0 => string 'en' (length=2)
1 => string 'el' (length=2)
2 => string 'en' (length=2)
protected 'lang' =>
array (size=2960)
'TRANSLATION_INFO' => string '' (length=0)
'DIRECTION' => string 'ltr' (length=3)
'DATE_FORMAT' => string '|d M Y|' (length=7)
'DATETIME_FORMAT' => string '|d M Y, H:i|' (length=12)
'USER_LANG' => string 'en-gb' (length=5)
see
protected 'user_language' => string 'en'
and
'USER_LANG' => string 'en-gb' (length=5)
.
Any suggestions on how I can make it use the users language?
NOT the
$this->user
but the loaded user
$user_instance
Thank you for your time!