Choose and set the translations for a specific language.
setLocale(locale: string)
This method sets the language of the player, to the given code, and thus loads the translations associated with that language. The language definition and codes need to exist in the org. Visit the Language doc for more information.
JavaScript
player.setLocale('EN-US');
Usage
This method is intended to be used by the front-end whenever the configurator form UI needs to load the translations stored in the ThreeKit org for your given project. The player will feed the names of attributes, items, and tags to the front-end with the translations stored in the given language requested by this function.
getTranslations()
This method returns the translations available for the active locale, in a key/value object that can be used with an i18n library
JavaScript
player.getTranslations();
Example return:
{
"Cotton Blue": "Bleu",
"Cotton Red": "Rouge",
"Fabric": "Materiel",
"Legs": "Jambes",
"Microfiber Green": "Vert",
"Microfiber Purple": "Violette",
"Wood Maple": "Erable",
"Wood Walnut": "Noyer"
}
Usage
This method would be useful when building a custom configurator form UI on the front-end, and the user can choose between a set of different languages. The front-end can first call the setLocale()
to set the language, then call the getTranslations()
method to get the translated values for the attributes and their choices.