feat(i18n): add internationalization support for puzzle text and UI s…#38
Open
ebubeb683-ship-it wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31 This PR adds internationalization (i18n) support for puzzle text, CLI prompts, hints, error messages, and TUI labels using Mozilla Fluent (fluent-bundle). User-facing strings have been extracted out of application logic into declarative Fluent .ftl resource files under contracts/puzzle/locales/.
Key Changes
String Management Integration:
Integrated fluent-bundle and unic-langid in the mesh-puzzle crate.
Built I18nManager in to handle resource bundle loading, message lookup, parameter interpolation, and fallback resolution.
Extracted Fluent Resource Files:
Added containing English UI labels, prompts, hints, and error/success messages.
Added working example translations for French in and Spanish in .
CLI --lang
Selection & Fallback:Added --lang
and --lang=CLI flag parsing in .If a requested locale is missing or a specific key is untranslated, the system automatically falls back to English (en).
Contributor Guidelines:
Updated with step-by-step instructions on how contributors can add new language files under locales/ without modifying core logic.
Unit & Integration Tests:
Added comprehensive tests in covering default locale selection, language switching, missing key and locale fallback, parameter interpolation, and flag parsing.
How to Test
bash
Run CLI with default English locale
cargo run -p mesh-puzzle
Run CLI with French locale
cargo run -p mesh-puzzle -- --lang fr
Run CLI with Spanish locale
cargo run -p mesh-puzzle -- --lang es
Run unit tests
cargo test -p mesh-puzzle