Get text
Dynamic Content can be used to get localized text based on subscriber locale, using GetText method.
To use this you need to create data table with name Translations and following structure:
Column name | Type | PK |
---|---|---|
key | string(255) | Yes |
locale | string min. 7 characters | Yes |
translation | text | No |
Method signature:
${GetText(key, locale, fallback, valuepairs)}
key
of translated valuelocale
is a culture of translation e.g. ‘RU’, ‘PL’, ‘default’fallback
is default value which will be returned when there is no translation for provided key and locale and there is no default locale for the key.valuepairs
is dictionary of parameters which will be replaced in translated sentence. Note that parameter name needs to be placed between % signs.
Example:
Let’s say that we have following rows in our Translations table:
Key | Locale | translation |
---|---|---|
expiration_date | default | Your %param_account% subscription expires on: %param_date% |
expiration_date | PL | Twoja subskrypcja %param_account% wygasa: %param_date% |
<%
var valuepairs = new System.Collections.Generic.Dictionary<string, string>();
valuepairs.Add('param_account','Netflix');
valuepairs.Add('param_date','2020-04-15 00:13:00');
%>
Default: ${GetText('expiration_date')} <br />
Default: ${GetText('expiration_date', 'default', '', valuepairs)} <br />
PL: ${GetText('expiration_date', 'PL', '', valuepairs)} <br />
BR (no translation in table): ${GetText('expiration_date', 'BR', '', valuepairs)} <br />
Output:
Default: Your %param_account% subscription expires on: %param_date%
Default: Your Netflix subscription expires on: 2020-04-15 00:13:00
PL: Twoja subskrypcja Netflix wygasa: 2020-04-15 00:13:00
BR (no translation in table): Your Netflix subscription expires on: 2020-04-15 00:13:00