This document explains how internationalization (i18n) is implemented in EmojiClu using the fluent-i18n crate.
EmojiClu now supports multiple languages using Mozilla's Fluent localization system. The setup includes:
- English (en) - Default/fallback language
- Spanish (es) - Complete translation
- French (fr) - Complete translation
locales/
├── en/
│ └── main.ftl
├── es/
│ └── main.ftl
└── fr/
└── main.ftl
The i18n system is initialized in src/lib.rs:
fluent_i18n::i18n!("locales", fallback = "en");The locale is automatically detected from the system settings at runtime in src/main.rs. You can override it by setting the LOCALE environment variable:
LOCALE=fr ./emojiclu # Force French
LOCALE=es ./emojiclu # Force SpanishThe system automatically handles locale variations (e.g., fr_FR, fr_BE → fr, es_ES, es_MX → es).
Replace hardcoded strings with the t! macro:
use fluent_i18n::t;
// Before
Button::with_label("Submit")
// After
Button::with_label(&t!("submit"))All translation keys are defined in .ftl files. For example, in locales/en/main.ftl:
submit = Submit
menu-new-game = New Game
app-title = EmojiClu