Multilingual File Generator, a dotnet tool to generate multilingual files for all platforms.
$ dotnet add package dotnet-mlgenA generator for .NET multilingual files for all native target platforms Windows, macOS, iOS, Android.
It can serve as a replacement for the Microsoft Multilingual App Toolkit.
This tool can be used to generate multilingual files: Xliff and translated resource files.
This can be platform specific resource files for net8.0-android, net8.0-ios, net8.0-macos or Windows.
The Microsoft Multilingual App Toolkit no longer seems to support these specific native platforms.
Other advantages of using this dotnet tool:
A configuration file needs to be in the project directory (Multilingual.config), for more info see below.
The config specifies the source resource (e.g. English language). The tool will create and update Xliff's depending on changes in the source resource. It will also generated localized target resources based on the Xliff.
Xliff can be editted with any Xliff editor or the Microsoft Multilingual App Toolkit Editor, see https://learn.microsoft.com/en-us/windows/apps/design/globalizing/multilingual-app-toolkit-editor-downloads.
For more information about local/global .NET tools see https://learn.microsoft.com/en-us/dotnet/core/tools/global-tools
dotnet tool install --global dotnet-mlgen
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local dotnet-mlgen
Restore in repo:
dotnet tool restore
dotnet mlgen (mlgen = Multilingual generator)OR:
On prompt: dotnet mlgen <full path to config file>.
The sample config file contains translations for the Spanish (es) and Dutch (nl) language.
dotnet mlgen create-sample-config android AppName
dotnet mlgen create-sample-config ios AppName
dotnet mlgen create-sample-config macos AppName
dotnet mlgen create-sample-config windows AppName
{
"SourceSettings": {
"ApplicationName": "AppName",
"SourceFileFormat": "android",
"SourceLanguage": "en-US",
"SourceFile": "Resources/values/Strings.xml"
},
"TargetSettings": {
"TargetFileFormat": "android",
"XliffBaseDir": "MultilingualResources",
"ResourcesBaseDir": "Resources"
},
"Targets": [
{
"TargetLanguage": "es",
"TargetXliff": "AppName.es.xlf",
"TargetResource": "values-es/Strings.xml"
},
{
"TargetLanguage": "nl",
"TargetXliff": "AppName.nl.xlf",
"TargetResource": "values-nl/Strings.xml"
}
]
}
All paths for file generation are relative to the location of the config file.
Settings for the source, this file should already exist.
| Name | Description |
|---|---|
| ApplicationName | Name of the application, used in the Xliff for generating id's |
| SourceFileFormat | Describes the type of multilingual input resource: allowed values "android", "apple" or "windows". Android = "strings.xml", apple = "Localizable.strings", windows = "resources.resx". |
| SourceLanguage | The source language |
| SourceFile | location of the source resource file relative to the multilingual.json location |
Settings that apply to all Targets
| Name | Description |
|---|---|
| TargetFileFormat | Describes the type of multilingual input resource: allowed values "android", "apple" or "windows". Android = "strings.xml", apple = "Localizable.strings", windows = "resources.resx". |
| XliffBaseDir | Base directory for the Xliff files |
| ResourcesBaseDir | Base directory for the resource files |
An array of target languages that need to be generated (Xliff and resouce in specific file format)
| Name | Description |
|---|---|
| TargetLanguage | Target language |
| TargetXliff | Filename of the target Xliff |
| TargetResource | File name of the target resource |
Untranslate strings can be automatically translated using OpenAI/ChatGPT API. The translated strings will get the status "NeedsReview". The model is now hardcoded to "gpt-4.1-mini"
To use these feature define a environment variable "OpenAIKey" with your OpenAI Api Key