Learn how to generate multi-language images in seconds with Bannerly!See Bannerly.io

Customer translations

Last modified: May 08, 2021Author: 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.

add customer-specific context

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

Add customer-specific translations

Now you can add customer-specific translation in the translation editor just like any other language translation! Save changes and publish translations.

add customer-specific translation

Access customer-specific translations

You can access your customer-specific translations using CDN links 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}}

Example

# Fetch project translations for all languages for given `my_customer`
https://cdn.simplelocalize.io/MY-PROJECT-TOKEN/_latest/_index_my_customer
{
  "de" : {
    "HELLO_WORLD" : "Hallo" //default translation for 'de'
  },
  "en" : {
    "HELLO_WORLD" : "Hello My Customer!" //customized translation for 'en' and 'my_customer'
  }
}

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

Access customers with customized translations

You can check first if there are any translations for given {{customerId}}. To do that you can fetch a list with all customers and check if your customer is on it. If yes, then you have 100% confidence that CDN request will return translations.

Example

# Fetch all customers for given project
https://cdn.simplelocalize.io/MY-PROJECT-TOKEN/_latest/_customers
[
  {
    "id": "my_customer_id" 
  },
  {
    "id": "874259234_my_customer"
  }
]

id from the response is equal to {{customerId}} in this article, and this is the value which you set up in the 'Customer-specific translations' section in the 'Language' tab.

customer-specific translation id