Jump to content
Mr.SerikuS

Invoice Language

Recommended Posts

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;
}

Share this post


Link to post
Share on other sites

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);
...

Share this post


Link to post
Share on other sites

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 by Mr.SerikuS (see edit history)

Share this post


Link to post
Share on other sites

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 by Dr.Radon (see edit history)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More