-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Lang package - Set the desired language #5333
Comments
Does the operating system you are using not provide language setting at a central location? Many apps are (finally) moving to a model where (like light/dark mode before it) the setting matches across all apps... |
Hi Andy, Thanks for your answer. I agree with your design philosophy, but I'm working on a client app for an API and the language in this case is defined by user settings. Maybe you could give me the instruction for the right way to do this with the lang package and I'll implement it on my side. If you really don't think it could be a nice to have feature. Actually, the default behaviour could stay as it is now. Thanks in advance for your precious help. Kind regards. |
There is a PR being worked on to support this - if you're able to build from a Fyne fork you could try to work with it. - #5026 It is also possible to implement this feature without any API support from Fyne in a slightly hacky way. I recently did so to add a lanugage selector to my app because users were asking for it (mostly to force the app to English despite system language). You can load only the translation for the desired language, but in a |
Hi Drew, Indeed I need a language selector too. I'm happy to see that I'm not the only one in this situation. Thanks for your insight. I guess I can close this feature request. I will wait for this to be available. I will manage things differently for the moment. Thanks a lot. Kind regards, Happy Xmas to all of you. |
Maybe we do need to find a clean way to help settings be applied per-app. |
That's it. Just as an extra feature. Thanks for amazing work. |
IMO, theme variant and language should be able to (and default to) follow system settings, while at the same time providing the ability to override it programmatically (so you CAN offer users the ability to set an exception for the app they use). So theme variant might be |
Yes indeed, that is how theme operates already and what the language defaults to. Though it is worth noting that Apple devices (macOS and iOS) already have per-app language settings and we are seeing apps prompt users to go to system settings instead of including in the app itself... |
My point was rather, that currently it is the only possible option to follow system defaults. For themes this can be worked around by implementing a very simple custom theme that inherits from the default theme but allows overriding the variant (as the For fonts though, fyne currently relies on the But just to reiterate this: it's only about developers have the choice to offer that. The default should always be to simply follow system settings. For simple apps or when devs don't care, the app should behave as sane as possible. But for more complicated use-cases, having the ability to intervene and offer the user customizations beyond their system wide settings would be nice to have. Adding my end-user perspective here, although I am obviously more of a power-user and therefore probably not a representative example: My system language is typically German; simply because I got used to it and many people around me have their system in German. If I want to help them, it's easier for me to know the German terms for all the menus etc. However, complex/"professional" software tools I use I almost exclusively use in English. It's so much easier to get help online or find blueprints if you work with the English terms that I don't want to translate things back and forth and lose information on the way. Sometimes I also just switch the language temporarily to look something up. If I had to switch the whole OS locale every time, I would go mad. Similar with themes: my eyes can't stand dark themes most of the time, but individual apps - depending on their color schemes - look better (= less exhausting) in dark mode. So I have most of my system in light mode but individual apps in dark mode (or vice versa). If every app forced me to have a unified light/dark mode, I would also be angry. So obviously, if I develop an application, I try to give my users the same kind of freedom I would expect: sane defaults but lots of customization if they need it. |
That isn't a workaround, that is the API provided to control theme and variant.
Yes. I think your long message basically says we are in agreement. I was just pointing out that many OS are now handling this per-app so it is worth checking if the work has not already been done for you. |
How I personally do it. https://github.com/alexballas/go2tv/blob/main/internal/gui/gui.go#L247-L256 |
@alexballas FYI that may only work on Linux, I believe on Windows and Mac, the language setting is communicated through OS APIs, not env vars This is how I did it, if anyone's curious: https://github.com/dweymouth/supersonic/pull/510/files#diff-2873f79a86c0d8b3335cd7731b0ecf7dd4301eb19a82ef7a1cba7589b5252261R50 |
thank you @dweymouth! That did the trick for me. Just pushed something similar to your code here. https://github.com/alexballas/go2tv/blob/devel/internal/gui/gui.go#L252-L265 A bit simplistic given the limited number of languages my app supports, but does the trick :) |
Checklist
Is your feature request related to a problem?
The new lang package is awesome and I like the simplicity of the json files.
I cannot understand why there is no way to manually change the current language.
Most of the time the language of an app can be changed in settings. But, the setupLang function is not shared.
If it's possible and I missed it, I'm sorry in advance.
Is it possible to construct a solution with the existing API?
It should be pretty simple. I don't know if the current setupLang should simply become public.
I guess it will take a bit more work to make it cleaner.
Describe the solution you'd like to see.
Something like :
It would be perfect.
The text was updated successfully, but these errors were encountered: