Static routines for common translation tasks.
- Version:
- 16.3.1
- Source:
Members
Methods
(static) createTranslatable(i18nKey) → {translations/js/api/Translatable}
stable API
A factory method for instantiating Translatable. The i18n key passed into this method can be:
- The key of a currently existing translation, run-time or design-time
- A newly minted key for a non-existing translation; use I18n.key() to construct such keys
- The empty string. Creating empty-string translatables can be used to intialize fields with a Translatable whose value can be entered later
Parameters:
Name | Type | Description |
---|---|---|
i18nKey |
String | the key for the new translatable |
- Version:
- 16.3.1
- Source:
Returns:
the created translatable or undefined if the passed-in key was invalid
- Type
- translations/js/api/Translatable
Examples
var displayNameNls = I18n.createTranslatable('componentsDt.createButtonDisplayText');
var fieldNameNls = I18n.createTranslatable(I18n.key(I18n.Type.Entity, entity.getId(), field.getId(), I18n.Suffix.SingularName));
var displayNameNls = I18n.createTranslatable('');
// Reading a previously persisted translatable
var serializedDisplayName = model.data.displayName;
// De-serializing a translatable
var displayNameNls = I18n.createTranslatable(serializedDisplayName);