i18n()
Lookup a language token.
Please note - this property requires the Editor extension for DataTables.
Description
This method exposes Editor's translated strings for each lookup based on Javascript object notation string. It is similar to the DataTables i18n() method, but provides an additional parameter to simplify external logic when dealing with optional configuration parameters for objects (e.g. fields). There is also no support for plurals in this method.
This method is only likely to be useful to you if you load additional information into the Editor configuration object, or you are developing a field type plug-in.
Type
i18n( custom, token [, default] )
Look up a translation token from the loaded language configuration.
Parameters:
| Name | Type | Optional | |
|---|---|---|---|
| 1 | custom | No | |
User defined string for this token. While it would be possible to check for this value outside the method, it is a common action to check for custom text values on objects (e.g. field configuration objects), so this is provided to simplify that logic. If not | |||
| 2 | token | No | |
The JS object notation string for the value that is to be loaded. For example for | |||
| 3 | default | Yes - default: | |
Fallback value - if there is no match for the first two parameters, the value from this parameter is returning. Failing that, an empty string is returned. | |||
Returns:
string:
The resolved language token.
Examples
Get default language string:
let editor = new DataTable.Editor(
// ...
);
editor.i18n('edit.button');
// Results in 'Edit'Set and get custom i18n data:
let editor = new DataTable.Editor({
i18n: {
custom: {
first: 'First',
second: 'Second
}
}
// ...
});
editor.i18n('custom.second');
// Results in 'Second'Related
The following options are directly related and may also be useful in your application development.