Static routines for common translation tasks.
- Version:
- 16.3.1
- Source:
Members
(static) Type :String
stable API
An enum of common translation categories. All translatable strings in the translation table must be rooted on one of the types below. If used consistently to build the keys of the translation table, the table will in the end look like:
Type:
- String
Properties:
Name | Type | Description |
---|---|---|
Application |
String | For app-level metadata: App name, copyright notices, etc. |
Page |
String | For the page tree and all components on a page |
Entity |
String | For entities and fields |
MainMenu |
String | For menus and sub-menus |
- Version:
- 16.3.1
- Source:
- See:
Example
"main-menu": {
"homePage": "Home"
}
"entities": {
"Sales" : {
"name": "Sales",
"revenue": {
"name": "Revenue"
}
}
}
"pages": {
"homePage": {
"displayName": "Home",
"button-123456678": {
"displayName":
}
}
}
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);
(static) key(type, …varArgs) → {String}
stable API
Builds an i18n key from the string tokens passed in.
The first parameter passed in must be one of the enum types listed in I18n.Type.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
String | one of the enum strings in I18n.Type |
|
varArgs |
String |
<repeatable> |
keyTokens a vararg of all string tokens that must be constructed into a key |
- Version:
- 16.3.1
- Source:
Throws:
-
in cases where number of tokens < 2 or > 50
- Type
- Error
Returns:
a key generated from the passed-in tokens
- Type
- String
Examples
var viewI8nKey = I18n.key(I18n.Type.Page, activePage.getId(), view.getId(), 'titleText');
var fieldNameKey = I18n.key(I18n.Type.Entity, entity.getId(), field.getId(), I18n.Suffix.SingularName);