The target language for localization
The package authorized to provide default language configurations
The translation dictionary for the target language
Fallback translations if the target keys are not found
Private
#formattersCached store of Intl.ListFormat instances.
Localize a string by drawing a translation from the available translations dictionary, if available If a translation is not available, the original string is returned
The string ID to translate
The translated string
{
"MYMODULE.MYSTRING": "Hello, this is my module!"
}
game.i18n.localize("MYMODULE.MYSTRING"); // Hello, this is my module!
{{localize "MYMODULE.MYSTRING"}} <!-- Hello, this is my module! -->
Localize a string including variable formatting for input arguments. Provide a string ID which defines the localized template. Variables can be included in the template enclosed in braces and will be substituted using those named keys.
The string ID to translate
Provided input data
The translated and formatted string
{
"MYMODULE.GREETING": "Hello {name}, this is my module!"
}
game.i18n.format("MYMODULE.GREETING" {name: "Andrew"}); // Hello Andrew, this is my module!
{{localize "MYMODULE.GREETING" name="Andrew"}} <!-- Hello, this is my module! -->
Retrieve list formatter configured to the world's language setting.
Optional
options: { The list formatter style, either "long", "short", or "narrow".
The list formatter type, either "conjunction", "disjunction", or "unit".
Private
_discoverPrivate
_getPrivate
_filterPrivate
_loadStatic
localizePerform one-time localization of the fields in a DataModel schema, translating their label and hint properties.
The DataModel class to localize
Options which configure how localization is performed
An array of localization key prefixes to use. If not specified, prefixes are learned from the DataModel.LOCALIZATION_PREFIXES static property.
A localization path prefix used to prefix all field names within this model. This is generally not required.
JavaScript class definition and localization call.
class MyDataModel extends foundry.abstract.DataModel {
static defineSchema() {
return {
foo: new foundry.data.fields.StringField(),
bar: new foundry.data.fields.NumberField()
};
}
static LOCALIZATION_PREFIXES = ["MYMODULE.MYDATAMODEL"];
}
Hooks.on("i18nInit", () => {
Localization.localizeDataModel(MyDataModel);
});
JSON localization file
{
"MYMODULE": {
"MYDATAMODEL": {
"FIELDS" : {
"foo": {
"label": "Foo",
"hint": "Instructions for foo"
},
"bar": {
"label": "Bar",
"hint": "Instructions for bar"
}
}
}
}
}
Static
Private
#localizeStatic
Private
#localize
A helper class which assists with localization and string translation
Param: serverLanguage
The default language configuration setting for the server