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

Add an example demonstrating integration with fluent for localization #12

Open
alice-i-cecile opened this issue Apr 14, 2024 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@alice-i-cecile
Copy link
Contributor

This is an important wrinkle, and it would be great to showcase how this fits together.

@alice-i-cecile alice-i-cecile added the documentation Improvements or additions to documentation label Apr 14, 2024
@brandon-reinhart
Copy link
Contributor

The way I do this is implement Display for Id that writes Id's in hex 0xDEADBEEF. I then can insert these into labels with a prefix:
"item0xDEADBEEF" or pass them as tokens to fluent strings "crafting?item_type=item0xDEADBEEF".

Then I have a system that resolves all Text components that also have a UiLocalize component. Resolution involves first replacing the hex with the matching manifest entry's name "crafting?item_type=wood" and then passing that to bevy_fluent's content fn.

There are probably steps that could be removed, maybe the interim hex encoding, but I found that's useful for eyeballing problems.

Another neat thing you can do is mark any strings that fallback with a custom TextColor, so if you're playing in French, strings that fail to localize in French and fallback to English will show up red or whatever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants