quantum Posted February 7, 2023 Share Posted February 7, 2023 How chnage language context for Smarty, that all strings in tpl {l s='...' mod='...'} uses spesified language, instead of Employee default language. Ex., I tried in module before $this->display() or $this->context->smarty->fetch() change context: $this->context->language = new Language(5); $this->context->employee->id_lang = 5; Does not help, UI language has changed, but render of .tpl still uses employee default language. Link to comment Share on other sites More sharing options...
Prestachamps Posted February 7, 2023 Share Posted February 7, 2023 Hi, If you wish to change an employee's language, you must construct a new employee object with the preferred lang id set. Each employee has a lang id that is set when a new employee is created. Have a nice day. Kind regards, Leo Link to comment Share on other sites More sharing options...
quantum Posted February 7, 2023 Author Share Posted February 7, 2023 I need for the same employee, just show the template in the selected language. The employee himself chooses in which language he wants to see the result. Link to comment Share on other sites More sharing options...
Prestachamps Posted February 7, 2023 Share Posted February 7, 2023 You can try this: $employee = new Employee("id_employee"); $employee->id_lang = 5; // set your choosen lang_id; Kind regards, Leo Link to comment Share on other sites More sharing options...
quantum Posted February 7, 2023 Author Share Posted February 7, 2023 Issue were in deeper... Prestashop at the first mention of any {l s='..'} or $this->l(...) loads language file and cached it in global $_MODULES varaible, and after not load another language and not replaced loaded strings, even if change language context during runtime. I solved this so, need finding the place in the module where the translation has never been requested before and changing the language in the context before this place. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now