slint
slint copied to clipboard
Add support for translations without gettext
We need to support user changing translations through the interface, as well as translation on platform that do not have gettext (MCU)
The idea would be somehow to have API to provide a translator.
Perhaps we can re-use an interface similar to https://docs.rs/tr/latest/tr/trait.Translator.html and have a global setter to set it. That setter would mark all translated string as dirty.
( This should also help for https://github.com/slint-ui/slint/issues/3307 )
I know that this has been discussed before and that the idea was already discarded, but isn't it worthwhile, however, to give users the option of using fluent-rs instead of gettext, since it works very well under any system, including windows.
This way, the external dependence on the code in C can be removed and it will make cross-compilation easier.
Regarding fluent, this can be done by using a global.
The old documentation should five hint https://slint.dev/releases/1.0.2/docs/slint/src/recipes/recipes#translations
So you would have in your code something like text: Fluent.translate("my-text", ["FooBar"])
Other possibilities are also possible: https://github.com/slint-ui/slint/issues/33#issuecomment-1275856180
Any progress on changing the language dynamically?