Text in quote is falsly translated to UI language and not to client's language

There seems to be something not quite right with the translation of quotes.
I am running my UI in German.
I have a customer with

  client_languate==="english"

Many components in the quote are correctly translate.
E.g. in case of trans('quote_date') it states:
“Quote Date”.

But e.g. in the item table I have the headers of the columns or I have my own “Your VAT ID”, which is wrongly translated to German, which is the UI language but not the client’s language.

I though it might be due to a missing english/custom_lang.php (which was ok in 1.4.10) but it does not seem to make any difference.

I have not quite figured it out, yet.

Kind regards
Cornelius

I don’t know if I can follow you.
Do you have some strings printed out in german on the PDF or is it just your UI?

If you need any custom strings via the custom_lang.php file, this file needs to be present in all used language directories with the correct translations.

The PDF contains german strings.

E.g. the template looks like this:

        <div>
            <?php if ($quote->client_vat_id) {
                echo trans('Your VAT ID') . ': ' . $quote->client_vat_id;
            }?>
        </div>

and the PDF contains the german translation. Although the client, who gets the quote is set to english language.
The UI, however, is German.

For what it’s worth: This is a migration from 1.4.10 to 1.5.2.

Is that really correct? How does your custom_lang.php in the english folder look like?

With version 1.4.10 I did not use an english translation file. If no translation exists the language_string_key “This arbitrary text” in trans('This arbitrary text') was displayed.

Now I added a file at application/language/english/custom_lang.php which looks like this:

<?php
/**
 * CUSTOM LANGUAGE STRINGS
 *
 * Add your custom Language Strings here with the following scheme:
 *
 * 'language_string_key' => 'Actual content of the Language String',
 *
 * Please notice that 'language_string_key' should only contain alphanumeric
 * characters and underscores.
 * If you are not sure take a look at the ip_lang.php file or visit the
 * community forums.
 */

$lang = array(
   'description' => 'Description',
   'Your VAT ID' => 'Your VAT ID'
);

However, if I change the UI language to english again, the translation in the PDF is fine (english). But I would simply like to use the client’s language and leave the UI untouched.

On more comment. I do not see any regualrity here.

        <div>
            <?php echo trans('customer ID') . ': ' . $custom_fields["client"]["Kundennummer"]; ?>
        </div>

“customer ID” does not exist in the english custom translation. And “customer ID” is correctly printed in the PDF.

        <div>
             <?php echo trans('your contact')?>
        </div>

“your contact” also does not exist in the custom translation file. But it is falsely printed as the German translation “Ansprechpartner” in the PDF.

This it what puzzles me. Some words are falsely translated to German and some are not. What is the best way to debug this, to be able to look into what the trans helper function is doing?

Hi @Kovah,

I’ve identified the problem!

As soon as one translation string can not be found in the client’s translation array, the system falls back to the UI’s language.

“Your VAT ID” exists in custom_english.
“customer ID” does not exist in custom english.

Till now, “customer ID” was displayed in the PDF, but “Your VAT ID” was translated to German!

Now I changed the quote template like this:

        <div>
            <?php if ($quote->client_vat_id) {
                echo _trans('Your VAT ID') . ': ' . $quote->client_vat_id;
            }?>
        </div>
        <div>
            <?php echo trans('customer ID') . ': ' . $custom_fields["client"]["Kundennummer"]; ?>
        </div>

        <div>
            <?php if ($quote->client_vat_id) {
                echo _trans('Your VAT ID') . ': ' . $quote->client_vat_id;
            }?>
        </div>

Now funny output:

  • Your VAT ID (translated to english, which is the client’s language, the string was found in the english array)
  • customer ID (string was not found in english array, but it used the language_string_key)
  • Ihre UstID (the system fell back to the UI language and translated the languate_string_key “Your VAT ID” to German.

Obviously the reset_language causes the problem.

However, it will work out, if no translation is missing at all.
If only one translation is missing, all the next translations will be wrong.

1 Like

https://development.invoiceplane.com/browse/IP-531

thx a lot!

Hello Kovah!

May this bug cause this problem too?

I set default language to portuguese, but the setting is ignored, persisting in english.

Take a look

Thanks!

@RenatoR have you checked this ? Language change fail

I think I’m facing the same issue as @cornelinux
System Language is set to Greek
User Language is set to {Use system language}
Client Language is set to English

Results for a client with English language set:
Invoice PDF is generated in English
Quote (Guest URL) is in Greek