Localization
Localizations Assets allow you to localize text in your Lens so that it can be used by Snapchatters all around the world! The Lens will automatically use the correct localized string provided by a Localizations Asset based on the Snapchatter's device language.
In order to use this feature, you will need to provide your own text localization. Check out the Localization Template which provides several examples of commonly localized text.
Localizations Asset
The Localizations Asset
is a resource in your Lens Studio project that provides the necessary localized text for your Lens. The asset refers to a folder containing files for each language that you’ve translated your texts to.
Unlike other assets, Localizations Asset
does not need to be added into a Component
. It simply needs to be in the Asset Browser
panel of your current project.
Creating a folder of translations
The process of creating a folder to be imported as Localizations Asset
happens outside of Lens Studio. You can use any text editor to create the required files. However, they should follow the following guidelines to be recognized by Lens Studio.
Each file name should be formatted as such: strings_[Locale Code].json
,
where the Locale Code represents the content’s language.
The contents of the .json
are key value pairs, where the key is used to refer to the text in the Text
Component and its value is the localized text. Note that your Key should start with the @
symbol.
{
"@key": "Translated Text",
"@key2": "Another Translated Text"
}
Tip: the Localizations Asset only cares about the filename. Within the folder, you can have any structure that you want.
Lastly, you’ll also want to add a strings.json
file. The strings.json
will be used when the user's device language does not match any of the provided .json
s. This file is also generally used when the user’s device language isEnglish.
Tip: Download an example of this Localization folder
Dynamic Text and Localization
In some cases you may want to add dynamic texts to your localized text. To do so, place the dynamic texts within two curly brackets.
{
"@HelloWorld": "Hello {{DisplayName}}"
}
Adding your folder of localizations as a Localizations Asset
To add your localization folder into your project, in the Asset Browser
panel, press +
, then Localization
.
In your computer file selection window, navigate to the folder you created in the previous step, and press Open
.
You should now see your Localization
file in your Asset Browser
panel.
You can select the Localizations
asset and see its content in the Inspector
panel.
You can add more than one Localization Assets
in a Lens! For example you can use the example localization file, while adding your own based on your needs.
Using your Localized text
To use your localized text, simply use the key you’ve defined before in your Text component!
In your Preview
panel, instead of the @Key
, you should see its value.
Your Text component should not contain any other characters (including a space) other than the keyword. Since languages may work differently, your localized text should contain the placement for any dynamic text within it.
Testing your Localized text
In the Preview
panel, you have the option to simulate how your Lens would look in different languages.
Select the Three Dots
in the far right corner of the panel, then select Lens Language
, and finally choose the language to preview.
Locale Codes
Language | Translated Language Name | Locale Code |
Arabic | العربية | ar_AA |
Bengali (Bangladesh) | বাংলা | bn_BD |
Bengali (India) | বাংলা | bn_IN |
Chinese (Simplified) | 简体中文 | zh_CN |
Chinese (Traditional) | 繁體中文 | zh_TW |
Danish | Dansk | da_DK |
Dutch | Nederlands | nl_NL |
English (UK) | English | en_GB |
English (US) | English | en_US |
Filipino | Filipino | fil_PH |
Finnish | Suomi | fi_FI |
French | Français | fr_FR |
German | Deutsch | de_DE |
Greek | Ελληνικά | el_GR |
Gujarati | ગુજરાતી | gu_IN |
Hindi | हिंदी | hi_IN |
Indonesian | Bahasa Indonesia | id_ID |
Italian | Italiano | it_IT |
Japanese | 日本語 | ja_JP |
Kannada | ಕನ್ನಡ | kn_IN |
Korean | 한국어 | ko_KR |
Malay | Bahasa Melayu | ms_MY |
Malayalam | മലയാളം | ml_IN |
Marathi | मराठी | mr_IN |
Norwegian | Norsk | nb_NO |
Polish | Polski | pl_PL |
Portuguese (Brazil) | Português | pt_BR |
Portuguese (Portugal) | Português | pt_PT |
Punjabi | ਪੰਜਾਬੀ | pa_IN |
Romanian | Român | ro_RO |
Russian | Русский | ru_RU |
Spanish (Argentina) | Español (AR) | es_AR |
Spanish (International) | Español | es_001 |
Spanish (Mexico) | Español (MX) | es_MX |
Spanish (Spain) | Español (ES) | es_ES |
Swedish | Svenska | sv_SE |
Tamil | தமிழ் | ta_IN |
Telugu | తెలుగు | te_IN |
Thai | ภาษาไทย | th_TH |
Turkish | Türkçe | tr_TR |
Urdu | اردو | ur_PK |
Vietnamese | Tiếng Việt | vi_VN |
Last Update: 8/16/2021