Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable graceful fallback handling. #11

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

nigeleke
Copy link
Contributor

@nigeleke nigeleke commented Jan 2, 2025

  1. When a language_identifier does not have a direct translation in the config, it will be determined if one exists for the primary_language. If so, then that will be used, otherwise revert to the configured fallback. Eg: config contains "en" and "en-GB" but user has selected "en-US". "en-US" will not be found, so "en" will be used.
    The graceful fallback hierarchy follows -<script>--, rolling from the RHS back to .

  2. It is possible to "share" a translation resource:

config
.with_locale((langid!("en-GB"), include_str!("./en-GB.ftl")
.with_locale((langid!("en"), include_str!("./en-GB.ftl")

where the included strings are not duplicated in the final config.

  1. Other changes mentioned in CHANGELOG.

  2. Note: v# bumped to 0.4.0

Closes #10

@marc2332 marc2332 self-requested a review January 2, 2025 20:07
@marc2332 marc2332 added the enhancement New feature or request label Jan 2, 2025
@marc2332
Copy link
Member

marc2332 commented Jan 2, 2025

Just had a quick look and all I have to say is this is impressive work! Feature well explained, added tests, comments, and docs, very nice job!

I'll have a longer look asap! 🦀

src/use_i18n.rs Outdated Show resolved Hide resolved
src/use_i18n.rs Outdated Show resolved Hide resolved
src/use_i18n.rs Outdated Show resolved Hide resolved
src/use_i18n.rs Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
nigeleke and others added 6 commits January 9, 2025 01:48
Reword LocaleResource comment

Co-authored-by: Marc Espin <[email protected]>
Update comment for set_language

Co-authored-by: Marc Espin <[email protected]>
Updated review comments commited online.
@nigeleke
Copy link
Contributor Author

nigeleke commented Jan 8, 2025

All comments taken onboard. @marc2332 this is my first formally reviewed PR, so not sure if you're expecting me to do a "completed changes" notification. I can't see any obvious action here on GH.
Otherewise - over to you.

@nigeleke nigeleke requested a review from marc2332 January 10, 2025 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: How to handle fallbacks
2 participants