Mr.SerikuS Posted November 30, 2015 Share Posted November 30, 2015 Hello, i searched half-google and didn`t get clear answer. How can i set invoices in only one language? I have 2-language website, latvian and russian. We have official language in country - latvian, and i want to get ALL invoices in latvian, not on russian (my admin accaunt uses rus, and some customers uses it too). I tried to translate all PDF in localisation, but delivery and some module names still in russian. So - what should i modify? (Presta default language is latvian). P.S.: Found this soulution: But i dont know how to make this line $this->order->id_lang to get latvian (or default language, or lang id.). Tried some variants, but they didnt worked. protected function getTemplate($template_name) { $template = false; $default_template = _PS_PDF_DIR_.'/'.$template_name.'.tpl'; $overriden_template = _PS_THEME_DIR_.'pdf/'.$template_name.'.tpl'; if (file_exists($overriden_template)) $template = $overriden_template; else if (file_exists($default_template)) $template = $default_template; // SELECT ORDER LANGUAGE FOR THE TEMPLATE if ( $this->order ) Context::getContext()->language = new Language($this->order->id_lang); return $template; } Link to comment Share on other sites More sharing options...
tuk66 Posted December 1, 2015 Share Posted December 1, 2015 You set the language for the whole shop using: Context::getContext()->language You should rather change the language just for the invoice. Look at the /classes/pdf/PDF.php file, the setFontForLang function public function render($display = true) { $render = false; $this->pdf_renderer->setFontForLang(Context::getContext()->language->iso_code); ... Link to comment Share on other sites More sharing options...
Mr.SerikuS Posted December 14, 2015 Author Share Posted December 14, 2015 (edited) Hello! Thank you for answer. I changed $this->pdf_renderer->setFontForLang(lv); /* Context::getContext()->language->iso_code*/ but invoice still generates in account language. Found for me: protected function getTemplate($template_name) { $template = false; $default_template = _PS_PDF_DIR_.'/'.$template_name.'.tpl'; $overriden_template = _PS_THEME_DIR_.'pdf/'.$template_name.'.tpl'; if (file_exists($overriden_template)) $template = $overriden_template; else if (file_exists($default_template)) $template = $default_template; // SELECT ORDER LANGUAGE FOR THE TEMPLATE if ( $this->order ) Context::getContext()->language = new Language($this->order->id_lang); return $template; } In this line: Context::getContext()->language = new Language($this->order->id_lang); Changed $this->order->id_lang to my language ID (Latvian was 2, so changed for 2) and my invoices become in one language. Edited December 18, 2015 by Mr.SerikuS (see edit history) Link to comment Share on other sites More sharing options...
Dr.Radon Posted February 1, 2016 Share Posted February 1, 2016 (edited) first of all thanks for the answers. I´ve a similar problem. I´ve customers from different countries with different languages. When I download an invoice from an italian customer with my german backend language, than the invoice is generated in german. Therefore I´ve to change my backends language for a few seconds to italian, download the invoice (now it´s in italian) and switch back to german again. do you have any idead how I can change this behavior. thx Edited February 1, 2016 by Dr.Radon (see edit history) Link to comment Share on other sites More sharing options...
tuk66 Posted February 1, 2016 Share Posted February 1, 2016 It is a feature. In the Back Office, employee's language is used. In the Front Office, customer's one. The M4 PDF Extensions module has a switch for changing the invoice language. See 11th image in the slideshow at http://www.presta-addons.com/en/modules/3-pdf-extensions.html 1 Link to comment Share on other sites More sharing options...
nsteinbach Posted September 9, 2019 Share Posted September 9, 2019 On 2/1/2016 at 4:00 PM, tuk66 said: It is a feature. In the Back Office, employee's language is used. In the Front Office, customer's one. The M4 PDF Extensions module has a switch for changing the invoice language. See 11th image in the slideshow at http://www.presta-addons.com/en/modules/3-pdf-extensions.html It's kind of an anti-feature if you print the PDF from backend in order to put it into shipping for the customer. Also, paying for a rather expensive addon shouldn't be a necessity for something as basic as this. So is there a possibility to change the file pdf.php in such a way that it always generates the invoice in the customer's language? Link to comment Share on other sites More sharing options...
Crezco Posted March 18, 2022 Share Posted March 18, 2022 (edited) For anyone who may interest. For Prestashop 1.6 & 1.7 To print invoice from BO with customer language, go to /classes/pdf/HTMLTemplateInvoice.php Under public function __construct, serach for : // header informations $this->date = Tools::displayDate($order_invoice->date_add); Just insert below: Context::getContext()->language = new Language($this->order->id_lang); That's all Edited March 18, 2022 by Crezco (see edit history) 1 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