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

Uninstalling language pack for current display language does not update display language setting #82791

Closed
Colengms opened this issue Oct 17, 2019 · 18 comments · Fixed by #171891 or #172082
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders l10n-platform Localization platform issues (not wrong translations) verified Verification succeeded
Milestone

Comments

@Colengms
Copy link
Contributor

This is similar to #79741 , but this is not a feature request. It's a bug. The language used in the UI becomes an inconsistent mix of 2 languages, and the current language setting remains set to something no longer valid and no longer available to the user.

Steps to repro:

  1. Install a language pack.
  2. Use 'Configure Display Language' command to set current display language to that language
  3. Restart VS Code, as prompted
  4. Uninstall the language pack
  5. Restart VS Code

Seeing: VS Code has mostly fallen back to the default language, however there are still various strings in the other language. Extensions that use vscode-nls still display strings in the other language. (For example, all strings coming from the C/C++ Extension such as IntelliSense, are in the removed language. This appears to be true for some built-in VS Code extensions as well.).

Expected: When uninstalling the language pack for the currently selected display language, the setting should be reverted to the default language. Extensions that use vscode-nls should not still display the removed language. Note that the available languages in Configure Display Language only include languages there are language packs for, so it doesn't make sense for the current language setting to remain something not on that list.

Version: 1.39.2 (user setup)
Commit: 6ab5985
Date: 2019-10-15T15:35:18.241Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@dbaeumer
Copy link
Member

The problem here is that the setting still points to the removed language and that for example C++ ships with its own language bundle, hence that still wins.

@sandy081 is there an event that I can listen to when an extension is uninstalled. Then I could reset the setting.

@dbaeumer dbaeumer added the bug Issue identified by VS Code Team member as probable bug label Oct 18, 2019
@dbaeumer dbaeumer added this to the November 2019 milestone Oct 18, 2019
@sandy081
Copy link
Member

@dbaeumer What setting is this and how this is set? Where does this setting exists?

@dbaeumer
Copy link
Member

It is not a setting. It is in its own file locale.json stored at the user data level (side by side to the settings.josn file).

@sandy081
Copy link
Member

@dbaeumer This can be done here - https://github.com/microsoft/vscode/blob/master/src/vs/workbench/contrib/localizations/browser/localizations.contribution.ts#L48

I have code to check when a lang pack is installed, we can add here to check if a lang pack extension is uninstalled and it is currently active. Let me know if you want to handle this or I can do it.

@dbaeumer
Copy link
Member

@sandy081 feel free to do the change. Is appreciated!

@sandy081 sandy081 self-assigned this Nov 25, 2019
@sandy081
Copy link
Member

sandy081 commented Dec 4, 2019

@dbaeumer just to be sure, extensions are directly reading this file? If so why are not getting locale id from us?

@sandy081 sandy081 modified the milestones: November 2019, December 2019 Dec 4, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Dec 5, 2019

No, extension never read that file. They get the language id from us. It is more around removing a language id from the file if the LP gets uninstalled.

@leosdad
Copy link

leosdad commented Oct 21, 2021

For some time now I'm starting getting Arduino/C/C++ error messages in Brazilian Portuguese which is my native language, which I don't want. The translations are often just incomprehensible, laughable or sheer nonsense. My VS Code is configured to use English everywhere, I want my messages in English again, I'm not sure what happened. I was redirected from this topic.

@sandy081 sandy081 modified the milestones: Backlog, October 2021 Oct 25, 2021
@sandy081 sandy081 assigned TylerLeonhardt and unassigned dbaeumer and sandy081 Oct 25, 2021
@sandy081 sandy081 removed this from the October 2021 milestone Oct 25, 2021
@sandy081
Copy link
Member

@TylerLeonhardt Assigning it to you as you are owning language packs feature.

@TylerLeonhardt
Copy link
Member

As a workaround you can set your locale to English using Configure Display Language... but yes it would be nice to gracefully handle when a language pack is uninstalled.

@quetzalcoatl
Copy link

My VSCode was always set to english, everything was displayed in english. Build error messages were in english. And intellisense warnings were in english. After installing PlatformIO some time ago, nothing has changed. Still everything was in english. But that was more than half of a year ago. Now I came back, opened a now-old project, VSCode with PlatformIO were unused since that time, and I was surprised with intelliSense messages showing up in my OS language, instead of english. What a 👀

I'm pretty sure I never installed any language packs, especially NOT for my native language. I truly HATE seeing my native language in technical IT contexts. I wouldn't do that. And I doubt PlatformIO installed would do that for me.

Traditional first three results on a more or less random search engine pointed me to "configure display language" setting, which, frankly, told me that my UI language is english. Well, ok, nah. (Also, my native lang was not listed as 'installed/available').

After trying a to generate a solution using an quantum random genetic algorithm (*) churning through half a zilion search similar-looking internet search results, and failing, I re-visited "configure display language", thinking, "what if it just displays stale data?". I switched my VSCode to a random other language I could read enough to be able to switch it back. It installed the pack, restarted itself ... no, it didn't. It displayed an infobox "do you want to restart now?". Of course NOT, I want to now reinstall back the english. So "configure display language" and I switched back to english, "do you want to restart now?" again, of course YES this time. And in this process, actually, nothing has changed. After restarting VS, I still got native lang in intellisense.

(*) an advanced multi-step one, like: pick post at random, copy, paste, mutate, tell myself I know what I'm doing, repeat.

At this point I probably errorneously assumed that I succeeded switching languages, and that "configure display language" displayed correct, nonstale, data all the time.

Then, after re-reading at least:

I came to and idea that it MUST be "configure display language", and I must have done something wrong, maybe I misclicked and didn't switch? I sometimes read and subconsciously translate languages, and later I'm 100% sure I saw language X when it was Z. I tried once again. To be sure, I picked chinese. "do you want to restart now?", of course NOT yet. Then I switch back to english. "do you want to restart now?", of course YES. VSCode restarted itself, and nothing has changed. I still had native intellisense messages.

But this got me thinking. That setting MUST be saved somewhere. And I've read somewhere that when a language pack is uninstalled, something stale may be left somewhere out there.

I found the setting here in

C:\Users\<<myname>>\.vscode\argv.json

and it looked like this:

image

That locale: zh-CN is pretty odd. Note that I did switch to chinese, did not restart, then switch to english, and then accepted restart. However, at NO POINT in time I have seen chinese UI in VSCode. At this moment, after that last restart, my VS showed up in english (as ordered to), and yes, shows intellisense in my native, but that zh-CN in the argv.json is pure nonsense. And if it is there, then how VS showed up in english?

There is a chance that I mindlessly clicked and uninstalled chinese language pack just before switching back to english (so I might have done: change to chinese, deny restart, uninstall chinese extension, change to english, restart), but I'm 100% sure that my last action before restarting was "configure display language" into english.

This got me into thinking, maybe it's not flexible enough, and maybe two-changes-at-one-time is too much? Maybe restart is required each time, or else something desyncs even more?

I "configure display language" to my native language pack. "do you want to restart now?". YES. It restarted, it started up in my laguage. "configure display language" to english. "do you want to restart now?". YES. It restarted, it started up in english. IntelliSense messages were now IN ENGLISH. And the argv.json contains locale: en instead.

So.. to be honest, that was just as crazy random and disorganized as I'm ashamed to admit, but I got it back to english. And I cannot 100% prove that it was the fault of "configure display language" and not-restarting the VS immediately, but to me, it looks like that. And I have no idea why this problem showed up in the first place, as, really, I wouldn't install a language pack, until the VSCode refused to cooperate (at which point I'd just uninstall it and switch to another IDE), and threatened me with deleting my projects and/or harddrive (ok sir, look here, I'm installing the language pack).

However, one thing I'm sure I got it back to english by:

  • try out "configure display language", ignore what it shows as currently chosen, select something else
  • do not touch anything else in the configuration and agree to having the VSCode restarted immediately after installation of the language pack
  • wait until VSCode fully restarts and presents the just-chosen language
  • use "configure display language" to switch back to english and agree to having the VSCode restarted immediately
  • wait until VSCode fully restarts

One thing that maybe would work much faster, and I'd try that for sure if I knew it beforehand, is changing the locale attribute in C:\Users\<<myname>>\.vscode\argv.json. Most probably I had something other than "en" there, and most probably closing VSCode, editing this setting to EN, and re-opening VSCode would do that trick in under 30 seconds, instead of a few hours of grepping the internet and trying out various options and switching language packs. Frankly, I'm quite happy having everything in english now, and I'm not really willing to play with this again and retest these observations in a more rigorous way. But, if the lang breaks/switches again on its own, I will, and I will add the results here, probably in a much shorter post. Sorry for a wall of text, I wanted to be as verbose as I could and as I can recall, in case any of those steps are important for fixing this in VSCode, or for someone who wants to fix their UI language.

@Lilly3252
Copy link

If a Language pack is installed and you wanna uninstall it , you go into the Extension folder in C:\Users\<<myname>>\.vscode\extensions , language pack are installed there.

@italocjs
Copy link

italocjs commented Oct 3, 2022

I was been having the same issue, hints were in portuguese brazilian, rest of the program in english.
What fixed for me was setting the language to something else than english (i set to pt-br), restart, set it back to english and restart.

@TylerLeonhardt TylerLeonhardt modified the milestones: Backlog, January 2023 Dec 8, 2022
TylerLeonhardt added a commit that referenced this issue Jan 21, 2023
The most important part of this change is that we now listen for when extensions are uninstalled and if they uninstalled language currently set then a modal will show up prompting for restart (required to change the language back to English).

This change also makes the LocaleService the thing that writes to the argv.json instead of a few places doing it

and cleans up some of the wording.

Fixes #82791
TylerLeonhardt added a commit that referenced this issue Jan 21, 2023
The most important part of this change is that we now listen for when extensions are uninstalled and if they uninstalled language currently set then a modal will show up prompting for restart (required to change the language back to English).

This change also makes the LocaleService the thing that writes to the argv.json instead of a few places doing it

and cleans up some of the wording.

Fixes #82791
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jan 21, 2023
@VSCodeTriageBot VSCodeTriageBot removed the insiders-released Patch has been released in VS Code Insiders label Jan 23, 2023
@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Jan 24, 2023
@roblourens roblourens added the verified Verification succeeded label Jan 26, 2023
@roblourens
Copy link
Member

Only odd thing is that the locale has the comma on the next line:

image

@TylerLeonhardt
Copy link
Member

That's odd. I'm just using the jsonEditingservice. Nothing has changed on that front:

await this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['locale'], value: locale }], true);

could that have been some copilot trickery?

@roblourens
Copy link
Member

I deleted the locale and set it up again, and now the locale is always at the end. So it was probably already like that and the comma was added by something else editing that file.

@jasonyang-ee
Copy link

jasonyang-ee commented Mar 4, 2023

#82791 (comment)
I followed everything in this response, but no luck. I did located the argv.json file and updated it to have "en" value.
I looked into \ms-vscode.cpptools-1.14.4-win32-x64\dist, and see the actual display language file nls.bundle.zh-tw.json
I dig into main.js and found function:

exports.getLocalizedString = getLocalizedString;
function getLocaleId() {
    if (typeof process.env.VSCODE_NLS_CONFIG === 'string') {
        const vscodeOptions = JSON.parse(process.env.VSCODE_NLS_CONFIG);
        if (vscodeOptions.availableLanguages) {
            const value = vscodeOptions.availableLanguages['*'];
            if (typeof value === 'string') {
                return value;
            }
        }
        if (typeof vscodeOptions.locale === 'string') {
            return vscodeOptions.locale.toLowerCase();
        }
    }
    return "en";
}

I forced changed return vscodeOptions.locale.toLowerCase(); to return "en"; but has no luck.

Learned more about how argv.json->locale being parsed.
1st: I added nls.bundle.en.json for it to parse. No luck.
2nd: I decided to replace my native language nls.bundle with nls.metadata.json. Now, the feature is broken lol...

Decided this is some VS Code fuck up:
1st: I disable setting sync.
2nd: I go deleted everything in \AppData\Roaming\Code and restart like a fresh installation.

NOT FUCKING WORKING. WTF. cpptools still shows my native language.

So, this must be cpptool fuck up. I can't even. I have already spend 8+ hours on this shit.

I then removed VS Code completely. Both .vscode and Code folder in /user.

A complete new installation of VS Code on my Zh-TW Windows OS.

The MF still shows my native language on Intellisense and code warning and all ....................................................

This is it... I give up.

******** Edit **************

I FUCKING FIXED IT:

HERE, I don't know which one. But just set all those MF options.locale and language to 'en' and call it the day:

remember to Developer: Reload Window after updating that damn javacript main.js

In user\.vscode\extensions\ms-vscode.cpptools-1.14.4-win32-x64\dist\main.js

    if (isString(process.env.VSCODE_NLS_CONFIG)) {
        try {
            var vscodeOptions_1 = JSON.parse(process.env.VSCODE_NLS_CONFIG);
            var language = void 0;
            if (vscodeOptions_1.availableLanguages) {
                var value = vscodeOptions_1.availableLanguages['*'];
                if (isString(value)) {
                    language = 'en';
                }
            }
            if (isString(vscodeOptions_1.locale)) {
                options.locale = 'en';
            }
            if (language === undefined) {
                options.language = 'en';
            }
            else if (language !== 'en') {
                options.language = 'en';
            }

******** Edit 2 *************
Sorry for the bad language. But the issue is about bad language after all....:::.(

So, here is a reported issue to cpptools microsoft/vscode-cpptools#10632

That issue report has more details.

I hope this helps.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug insiders-released Patch has been released in VS Code Insiders l10n-platform Localization platform issues (not wrong translations) verified Verification succeeded
Projects
None yet