Maomi can generate different binaries for different languages, a.k.a. the i18n support.
By default, i18n support is disable. To enable it, specify the locale in "MAOMI_I18N_LOCALE" environment variable while compilation.
When this environment variable often changes, it is recommended to add this line to build.rs:
When i18n support enabled, maomi requires every text node in the template to be translated.
Every string without translation will be marked a compilation error.
To translate this string, create a "i18n/[LOCALE].toml" file. Use "i18n/zh_CN.toml" as an example:
The string will be replaced according to this file when compiling the "MAOMI_I18N_LOCALE=zh_CN" version.
If the text node is an expression, the value must be a "LocaleString" or "LocaleStaticStr". Normal strings are not accepted.
If the string is static and can be translated through translation files, the `i18n!` macro can be used to translate it.
If the string is dynamic content or does not need to be translated, mark it as translated manually.
By default, the "[translation]" group in translation files are used. It is able to use other groups.
Then in the translation file:
For dynamic string translation, use "i18n_group!" to get the group.
The "maomi-tools" crate provides a tool "maomi-i18n-format" to collect untranslated strings and format the translation files.
Collect the metadata with "MAOMI_I18N_LOCALE" and "MAOMI_I18N_FORMAT_METADATA" environment variable.
Then do the format: