Imagine you have a customer who needs a different translation for specific keys and languages. You don't want these changes to affect all users—only this particular customer or a few select clients.
![How to handle customer-specific and industry-specific translations](/docs/customer-specific-translations.jpg)
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.
Customer ID can have a max length of 40 characters and contain only letters, numbers, dashes ('-'), and underscores ('_').
Filter customers in the translation editor
To work comfortably with customer-specific translations, you can filter translations by customer context. This way, you can focus on base translations only or translations for a specific customer.
![Filter translations by customer context](/docs/customer-filter.png)
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.
Customer permissions
When inviting a new user to your project, you can assign permissions to specific customer contexts. This way, you can control who can access and modify customer-specific translations.
![Assigning permissions to customer context](/docs/customer-permissions.png)
Use permissions to ensure that only the intended customer sees and interacts with their translations.
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