Localization
While localization is already supported by the plugin SDK and the MoBro data service, it is not yet implemented in the
MoBro desktop application itself.
For the time being, only the english translations will be used.
Language files
To use localization, we need to specify the relative path to the folder containing the localization files in
the mobro_plugin_config.json
.
The following example is taken from
the MoBroHardwareMonitor plugin.
{
"name": "modbros_mobrohardwaremonitor",
"displayName": "MoBro Hardware Monitor",
"author": "ModBros",
"description": null,
"assembly": "Plugin.MoBroHardwareMonitor.dll",
"localization": "Resources/Localization",
"settings": []
}
The localization files (one for each supported language) must be placed in the specified
folder (Resources/Localization
in case of the example above).
Localization files are JSON files containing simple key-value pairs for the translated text in the specific
language.
Example files
These examples are taken from the MoBroHardwareMonitor plugin as well.
English language file:
{
"metrics.system.osname.title": "Name",
"metrics.system.osname.desc": "The name of the operating system",
"metrics.system.osversion.title": "Version",
"metrics.system.osversion.desc": "The specific version of the operating system",
"metrics.system.ostype.title": "Type",
"metrics.system.ostype.desc": "The type of the operating system (32bit/64bit)",
...
}
German language file using the same keys:
{
"metrics.system.osname.title": "Bezeichnung",
"metrics.system.osname.desc": "Der Name des Betriebsystems",
"metrics.system.osversion.title": "Version",
"metrics.system.osversion.desc": "Die Version des Betriebsystems",
"metrics.system.ostype.title": "Typ",
"metrics.system.ostype.desc": "Der Type des Betriebsystems (32bit/64bit)",
...
}
Usage
Making use of the translated strings is as easy as just using the defined key from the localization files wherever you
would previously have used the plain string.
Everything else is automatically handled by MoBro.
Example
Instead of passing the string directly when creating this metric , we just pass the key as defined in the localization files:
// create a new metric
var metric = MoBroItem
.CreateMetric()
.WithId("osname")
.WithLabel("metrics.system.osname.title", "metrics.system.osname.desc")
.OfType(CoreMetricType.Text)
.OfCategory(CoreCategory.Miscellaneous)
.OfNoGroup()
.Build();
This applies the same way for all registrable items (metrics, categories, groups, etc.), plugin settings, etc.
Whenever you pass a string to MoBro you can pass a localization key instead.