glossa-codegen
Use a code generator to generate code.
It can generate const language localisation map for code at compile time
features
- yaml
- Enabled by default.
- The default file extension is ".yaml" or ".yml"
- ron
- The default ext is ".ron"
- toml
- The ext is ".toml"
- json
- ext: ".json"
- highlight
In addition to highlight, this corresponds to different types of configuration. You can enable all features or add them as needed.
By default, the file type is determined based on the file name suffix, and the map name (table name) is set based on the file name. Whether deserialisation is needed at compile-time is determined by the enabled feature.
Preparations
Before writing build.rs
, we need to prepare the localisation resource files (localised files).
de (Deutsch, Lateinisch, Deutschland):
- "assets/l10n/de/error.yaml"
text-not-found: Kein lokalisierter Text gefunden
en (English, Latin, United States):
- "assets/l10n/en/error.yaml"
text-not-found: No localized text found
en-GB (English, Latin, Great Britain):
assets/l10n/en-GB/error.yaml
text-not-found: No localised text found
es (español, latino, España):
assets/l10n/es/error.yaml
text-not-found: No se encontró texto localizado
pt (português, latim, Brasil)
assets/l10n/pt/error.yaml
text-not-found: Nenhum texto localizado encontrado
build.rs
use ;
use ;