It is possible to have your templates in multiple languages at the same time, and for the app to automatically display the correct language document for each customer. It does take some setting up, but once it's done, it will automate the process entirely.
Note: This guide is relevant if you're using the default template designs provided in the Order Printer Pro app.
Each template contains a section where all of the wording for the template is set up. To make a template support multiple languages, you repeat that section for each language and have some additional liquid code to switch to the correct language section based on the customer's language.
Translate Based on Customer Locale
Some apps will assing the customer's language using cart attributes attributes.lang
So we'll use those as the first criterion to determine the template language.
If these attributes don't exist, the fallback condition will be customer_locale
, which is a property assigned by Shopify. It represents the customer's choice of language during purchase or the one assigned by the store based on their location (Localization and translation).
If none of that is present, you'll also have a default language that will appear for anyone without any of these properties. Here are the steps to accomplish that:
Step 1
Go to the "Manage templates" page of Order Printer Pro
Step 2
Click the "Edit template" button on the template you would like to set up in multiple languages.
Step 3
In the "Code" section, you will see the section that controls the wording of your template:
Step 4
Open a text editor or Word document, and paste the following into it:
{% assign language_code = attributes.lang | default: customer_locale | split: "-" | first %}
{% case language_code %}
{% when 'de' %}
GERMAN WORD ASSIGNMENTS
{% else %}
DEFAULT LANGUAGE ASSIGNMENTS
{% endcase %}
IMPORTANT: The above language identifier of 'de' is only an example of the German language. Make sure you enter the two-character language identifier for your translation app account.
Here is another example if you want to translate into more than two languages:
{% assign language_code = attributes.lang | default: customer_locale | split: "-" | first %}
{% case language_code %}
{% when 'en' %}
English WORD ASSIGNMENTS
{% when 'es' %}
SPANISH WORD ASSIGNMENTS
{% when 'de' %}
GERMAN WORD ASSIGNMENTS
{% else %}
DEFAULT LANGUAGE ASSIGNMENTS
{% endcase %}
Step 5
Copy the section of code from your template that defines the wording in the document:
Step 6
Paste that into each of the sections where you added a language, and translate the words into the correct language. For example:
{% assign language_code = attributes.lang | default: customer_locale | split: "-" | first %}
{% case language_code %}
{% when 'de' %}
PASTE HERE THEN TRANSLATE TO GERMAN
{% else %}
PASTE HERE
{% endcase %}
Note: Only change the wording that is within the quotes. For example:
{% assign TEXT_receipt_tax_invoice = "Receipt / Tax Invoice" %}
Would be translated like this:
{% assign TEXT_receipt_tax_invoice = "Rechnung" %}
Step 7
Copy all of the text in your text editor or Word document, and paste it back into the template, replacing the old wording section. In the end, it should look similar to this:
Step 8
Click the "Save" button at the top of the page.
You are done. This template will automatically switch to the correct language for each order or customer based on the language they used at checkout.
Translate Based on Currency
If you want to set the template language based on the currency and not the language used, you may use this code instead:
β
{% case currency %}
{% when 'EUR' %}
TEMPLATE CODE FOR ORDERS IN EUR
{% when 'GBP' %}
TEMPLATE CODE FOR ORDERS IN GBP
{% else %}
TEMPLATE USED FOR ORDERS IN OTHER CURRENCIES
{% endcase %}