Creating and using translation files
Translation files can be uploaded to Bird and used in your templates. This guide walks you through how to upload and use them
Translation files allow you to dynamically translate content in templates based on the recipient's locale. Here's how to set up and use translation files to create a localised welcome email.
Step 1: Prepare the Translation File
File Format: Use a CSV file with the following structure:
Row Key (locale): Represents the locale (e.g.,
en-US
,fr-FR
,es-ES
).Column Headers: Keys for the sections of the template that require translation (e.g., header, body).
Example File:
welcome_email_translations.csv
en-US
Welcome to Bird!
We can't wait for you to get started with Inbox.
fr-FR
Bienvenue chez Bird!
Nous avons hâte que vous commenciez avec Inbox.
es-ES
¡Bienvenido a Bird!
Estamos ansiosos por que empieces con Inbox.
Save the File:
Save it as welcome_email_translations.csv.
Step 2: Upload the Translation File
Go to the Content > Translation Files section in Bird.
Click Upload Translation File.
Select
welcome_email_translations.csv
and upload it.Confirm the file upload is successful.
Step 3: Use Translations in the Email Template
Set the Locale: Assign the recipient's locale to a variable, typically based on their profile attribute. You can also use any custom attribute combination as long as it matches the format in your translation file.
{% assign locale = contact.attributes.locale %}
Fetch Translations: Use assign or capture to retrieve the relevant translation from the file using the render tag.
{% assign header = "welcome_email_translations/header" | t: locale %} {% assign body = "welcome_email_translations/body" | t: locale %}
Render the Template: Insert the translations dynamically into your email content. You can also render the translations directly into the variable rather than assigning them first
<h1>{{ header }}</h1> <p>{{ "welcome_email_translations/body" | t: locale }}</p>
Complete Template Example
Step 4: Test Your Translations
Send a Test Email:
Use test contacts with specific locales (e.g.
en-US
,fr-FR
,es-ES
) to ensure the translations are applied correctly.
Best Practices for Using Translation Files
Include fallbacks Always include fallback translations in case a locale-specific translation is missing. For example in the below if the locale is missing it will fallback to en-US, and if that is missing default back to the text “Welcome to Bird”.
{% assign header = "welcome_email_translations/header" | t: locale, "en-US" | default: "Welcome to Bird!" %}
Standardise Locale Codes: Ensure consistent locales (e.g.
en-US
,fr-FR
,es-ES
) are used across all translation files.Regular Updates: Keep translation files up-to-date as content changes to maintain consistency across languages.
Test Thoroughly: Regularly test templates after adding or updating translations to ensure they render correctly.
Outcome
Using the example above, a French recipient (locale = "fr-FR") will receive: Header: Bienvenue chez Bird! Body: Nous avons hâte que vous commenciez avec Inbox.
An English recipient (locale = "en-EN") will receive: Header: Welcome to Bird! Body: We can't wait for you to get started with Inbox.
This approach simplifies localisation, ensuring consistent messaging while reducing template duplication.
Last updated