Localization
Although 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 now, only the English translations will be used.
Language Files
To enable localization, you need to specify the relative path to the folder containing 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 folder specified under the localization
key (e.g., Resources/Localization
in the given example).
These files are JSON files containing simple key-value pairs to store translated text for a specific language.
Example Files
Below are examples of localization files from the MoBroHardwareMonitor plugin:
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 (same keys):
{
"metrics.system.osname.title": "Bezeichnung",
"metrics.system.osname.desc": "Der Name des Betriebssystems",
"metrics.system.osversion.title": "Version",
"metrics.system.osversion.desc": "Die Version des Betriebssystems",
"metrics.system.ostype.title": "Typ",
"metrics.system.ostype.desc": "Der Typ des Betriebssystems (32bit/64bit)",
...
}
Usage
Using translated strings is straightforward. Simply reference the defined key from the localization files in places
where a plain string would have been used in the past.
MoBro will automatically handle all localization.
Example
Instead of using a plain string when creating a metric, you pass the localization key 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 approach applies universally to all registrable items (metrics, categories, groups, etc.), plugin settings, and
more.
Whenever you pass a string to MoBro, you can use a localization key instead.