-
-
Notifications
You must be signed in to change notification settings - Fork 1k
switch languages without an app restart #1555
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
Conversation
mikeller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, I didn't expect this to be possible so easily.
|
Except that the builds are failing. :-( |
|
I did a similar feature when I made the translation system, and @mikeller asked to remove this live language change because not all is changed. Some combos that are loaded in the js and other thinks are not translated. I suggested some workarounds but it was some more little work for the developers. I will look at the discussion to see if I can find it... |
|
Here is the original PR #892 |
|
Thanks I'll take a closer look at what doesn't update. If we can get the last percentage fixed I think we can make a strong case going forward for people to keep things translatable on the fly. I figure that the log could be left alone just because of how logs work. Sometimes these things need to sneak up in stages. I should benchmark the retranslation compared to asking it to translate new items in the document. |
|
@McGiverGim: Good point, I remember now. My point still stands that, if this requires extra coding effort and understanding from people wanting to contribute to the configurator, then this disadvantage outweighs the benefits we get from it. After all, for the majority of users, selecting the language will be a one-off operation, and they won't have any need to switch the language again after selecting the one they want, so having to restart the application for this is only a very minor inconvenience. @Docteh: Agreed that leaving the log in whatever language it was generated is acceptable. |
That again for me turns into a matter of deciding what is more important - the capability to change languages without a restart, or the capability to add translations to whatever we want without restriction, and without having to think about what is working and what isn't. |
|
How about a compromise? We could only change the language if the GUI doesn't think its connected. Leave the message stating that a restart is required. Right now if something on a tab doesn't switch languages, you can just go to a different tab, and then come back. |
|
Interesting point, I never looked at it this way, but since tabs are reloaded entirely on every change this will work. Or take this in a different direction, and put the language drop down into the landing tab (this makes it easier to discover for somebody not fluent in the display language as well). |
|
Put the language switcher on the landing page? I like that idea. That'll be my next move. |
|
I like it - it shows the option in your language / alphabet right on startup - doesn't go much more straightforward than that. |
McGiverGim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too sure about the change. In this way we have options in the main page, and different options to select in the menu. I like to have all of them in the same manner.
If we finally do this change, maybe is better to make it more visual, maybe add a little flag before each text. If not, I'm pretty sure that most people will not read it.
|
The locales were there to give "some order" to the texts. They are ordered by locale. I don't know if now, without them, it seems more only a mesh of languages... |
|
I am a bit on the fence about adding the locale for every language to the list - my sense of ordering likes it, my sense of curiosity likes to be able to see what the languages not using the latin alphabet are, but my sense of aestethics just loves the simplicity of the list of languages without any distractions. But one thing I think we need to address is that currently the cursor when hovering over the language names is text selection - this makes it harder than needed to discover that they are clickable. |
|
I switched the spans out for links, so they'll be more obviously clickable. We could also do something to the text on hover. Like underline, or a color change. |
mikeller
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good now. Can you rebase / squash please?
locales/fake/messages.json
Outdated
| @@ -0,0 +1,6 @@ | |||
| { | |||
| "language_default_pretty": { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wut?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or to be more precise: What is this used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In English language_default_pretty is fully defined: "System Default ($t(detectedLanguage))"
This works as a fallback as many languages have language_default translated.
messing with fallback might be a way to rename a key, and not lose the translated content.
tabLanding
defaultChangelogAction
defaultPrivacyPolicyAction
tabHelp
tabFirmwareFlasher
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I understand this right, but the way fallbackLng is used it looks now like fake is the only language that will ever be used as fallback language. This is probably not what we want.
Also, should this mythical language maybe be called fallback or similar instead of fake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the fallback is to english. We can specify multiple fallback languages. So for defaultDonateBottom on the landing page gets english when using german. (my change to the link ended up wiping out the translations).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at the code. Only the first element of fallbackLng seems to ever be used. Is it possible that English is a hardcoded default fallback for the framework we are using?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In i18next or in our code? We are injecting information (resources) into the first fallbackLng, but I figured that would be okay to ignore. I figure it'd be an annoying problem to throw out a language while running, even if its a fake one.
For this screenshot I made did fallbackLng: ['fallback','de','en'], and then loaded polish translation manually i18next.changeLanguage('pl')

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad, I'd assumed fallbackLng was an option that we'd added (dodgy name and all).
|
Looks like I did something slightly wrong. I'll try to fix. Let me know on the fallback fakery. |
| TABS.landing = {}; | ||
| TABS.landing.initialize = function (callback) { | ||
| var self = this; | ||
| var self = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file will need to have the indentation adjusted at some point (not in this pull request though).
|
@McGiverGim: Is this ok now? |
|
My review yes, now has been fixed. But I don't understand all this fallback language. @Docteh can you explain why it is needed? I see that you have translations that recommend to translate in other place, translations that are in the fallback... |
|
It seems it has been done in this way to maintain some actual translations. If they are not valid/needed the correct way is to remove/change them. I don't have too much time now to look deeply to the PR, so if it is needed for certain reasons sorry, I have not see them. |
|
Oh, probably should have commented that the |
McGiverGim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need to add something like a flag to make them more visible but is ok for now. Good job!




Hello, Looks like anything except the GUI.log can be re-translated on the fly.
Give it a go. I'll fix the commit with a revision to
locales/en/messages.jsonif needed. But maybe we can just drop the string that says that a restart is required.<span i18n="userLanguageSelect" class="i18n-replaced">Sprache (Das Programm muss zur Änderung neu gestartet werden)</span>