MyBB Community Forums
[Rejected] Switching language programatically multiple time not working - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Development (https://community.mybb.com/forum-161.html)
+--- Forum: MyBB 1.8 Development (https://community.mybb.com/forum-165.html)
+---- Forum: 1.8 Bugs and Issues (https://community.mybb.com/forum-157.html)
+----- Forum: Rejected (https://community.mybb.com/forum-184.html)
+----- Thread: [Rejected] Switching language programatically multiple time not working (/thread-210893.html)



Switching language programatically multiple time not working - wyrda - 2017-06-05

If you want in a script to use first italian, after that english and after that italian again(always loading the same section) will not work.

The problem is in inc/class_language.php, line 147 require_once $lfile;
It should be only require, not require_once.

Real use case:
- admin approval registration
- default language Italian
- admin language English

Register using Italian language, the script will send and email to the admin(switch language once), after that will prepare a message for the user(switch language second time). Because of the require_once, the second switch will have no effect because that file was already required when the script started(member.php)


RE: Switching language programatically multiple time not working - fizz - 2017-07-07

I don't understand why you need to switch languages 3 times in the same script. Why wouldn't you just load the Italian lang files, copy whatever Italian strings you need for step 1 and 3 in your example to a local variable, and then once that's done just switch to English?

require_once() shouldn't be a problem here. There's no reason to load the language files more than once, because once they're loaded they are just added to the $lang object's list of keys and stay there. Therefore requiring them only one time should not be an issue, unless I'm misunderstanding what you're saying.

The example you're giving here just doesn't make sense to me tbh. The board can automatically email admins using the board's default language on new user register; that's a core feature that you don't need to make a script for and therefore wouldn't need to be manually switching languages.


RE: Switching language programatically multiple time not working - broatcast - 2017-07-07

I think he mean he as admin using english, a new user register on his forum and he activate them in acp, then the new user who get activated recive the mail he get activated in english instead of italien, what he choosed on registration process.

thats how i understand his problem, but i have not checked it, so i can not comfirm if its a exist bug or not.


RE: Switching language programatically multiple time not working - fizz - 2017-07-08

(2017-07-07, 03:18 PM)broatcast Wrote: I think he mean he as admin using english, a new user register on his forum and he activate them in acp, then the new user who get activated recive the mail he get activated in english instead of italien, what he choosed on registration process.

thats how i understand his problem, but i have not checked it, so i can not comfirm if its a exist bug or not.

I see what you mean. But is that a bug with MyBB or just the way it's intended to work? If the board is sending automated messages I would assume that it should send them in the board's default language, not the specific language that a certain user is using. Feel free to correct me on this though, I haven't looked into it enough to see for myself.