Customer translations

Last updated: November 17, 2022Author: Jakub Pomykała

Image you have a customer who would like to use a different translation for some translation keys and languages. You don't want to change this translation for everyone. This should apply only for one or a few clients.

how to handle customer-specific and industry-specific translations

With SimpleLocalize, you can handle such situations with ease!

Create customer context

Open 'Languages' tab and click 'Add customer context' button. Enter 'customer id' which should be unique for your project. You can also add some description to recognize this customer later.

How to add customer-specific context

Customer ID can have a max length of 40 characters and contain only letters, numbers, dashes ('-'), and underscores ('_').

Create translation for customer

Customer translations are created in the same way as regular translations. Open the 'Translations' tab and make sure that your editor is List View with All translations selected.

How to add customer-specific translation for white-label product

Access via Translation Hosting

Fetch customer-specific translations

You can access your customer-specific translations using Translation Hosting resources like below:

# Fetch all translations with translations for given customerId
https://cdn.simplelocalize.io/{projectToken}/_latest/_index_{customerId}

# Fetch translations for given language key with translations for given customerId
https://cdn.simplelocalize.io/{projectToken}/_latest/{languageKey}_{customerId}

Response

Fetch project translations for all languages for given my_customer

{
  "de" : {
    "HELLO_WORLD" : "Hallo" // default translation for 'de' language key
  },
  "en" : {
    "HELLO_WORLD" : "Hello My Customer!" // customized translation for 'en' and 'my_customer'
  }
}

If there is no translation for a given {customerId}, then the default translation is used. If you attempt to access translations for {customerId} who does not exist in SimpleLocalize, then Translation Hosting will return a response with 404 HTTP status code.

Fetch a list of customer contexts

You can fetch a list with all customers.

https://cdn.simplelocalize.io/{projectToken}/_latest/_customers

Response

[
  {
    "id": "my_customer_id"
  },
  {
    "id": "874259234_my_customer"
  }
]

Access via command-line tool

You can access your customer-specific translations using SimpleLocalize CLI by passing --customerId parameter with customer id from the 'Languages' tab.

simplelocalize download \
 --apiKey PROJECT_API_KEY \
 --downloadPath ./translations_{lang}.json \
 --customerId my_customer_id \
 --downloadFormat single-language-json