slint icon indicating copy to clipboard operation
slint copied to clipboard

Add support for translations without gettext

Open ogoffart opened this issue 8 months ago • 4 comments

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 )

ogoffart avatar Oct 20 '23 10:10 ogoffart

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.

qarmin avatar Nov 06 '23 19:11 qarmin

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

ogoffart avatar Nov 07 '23 10:11 ogoffart

Any progress on changing the language dynamically?

CarbonPool avatar Nov 25 '23 07:11 CarbonPool