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

Python extension doesn't obey locale settings #62623

Closed
pauloneves opened this issue Nov 6, 2018 · 57 comments
Closed

Python extension doesn't obey locale settings #62623

pauloneves opened this issue Nov 6, 2018 · 57 comments
Assignees
Labels
extensions Issues concerning extensions
Milestone

Comments

@pauloneves
Copy link

Issue Type: Bug

My OS language is Brazillian Portuguese. Although my locale is set as english in my VSCode configuration, the Python extension commands are displayed in Portuguese. All other commands are in English.

image

VS Code version: Code 1.28.2 (7f3ce96, 2018-10-17T00:23:51.859Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4770S CPU @ 3.10GHz (8 x 3093)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 15.95GB (5.90GB free)
Process Argv
Screen Reader no
VM 0%
Extensions (23)
Extension Author (truncated) Version
vscode-icalendar af4 1.0.1
vscode-standardjs che 1.2.3
gitignore cod 0.5.0
vscode-markdownlint Dav 0.21.0
githistory don 0.4.3
jupyter don 1.1.4
xml Dot 2.3.2
gitlens eam 8.5.6
tslint eg2 1.0.40
json-tools eri 1.0.2
gc-excelviewer Gra 2.1.26
vscode-firefox-debug hbe 1.7.1
Python-autopep8 him 1.0.2
beautify Hoo 1.4.7
autofilename Jer 0.1.3
nbpreviewer jit 1.0.0
python ms- 2018.9.2
debugger-for-chrome msj 4.11.0
vscode-run-git-difftool nar 0.0.5
markdown-checkbox PKi 1.4.0
autolinting-for-javascript t-s 1.3.0
markdown-pdf yza 1.2.0
intelligence-change-case zhe 1.1.0

(1 theme extensions excluded)

@vscodebot vscodebot bot added the extensions Issues concerning extensions label Nov 6, 2018
@dbaeumer
Copy link
Member

dbaeumer commented Nov 6, 2018

@pauloneves Can you please report this to the owner of the Python extension. We don't ship that extension inside VS Code and all other extensions seem to honor the language setting correctly.

@dbaeumer
Copy link
Member

dbaeumer commented Nov 6, 2018

Please ping if you think this otherwise.

@DonJayamanne
Copy link
Contributor

@dbaeumer
Not sure how this is a Python extension issue. We just ship the localized package.nls.json files. and its my understanding that VSC uses these based on the locale. I.e. we don't control what localized package.nls.*.json is picked by VSC.
Or am I missing something?

@dbaeumer
Copy link
Member

@DonJayamanne yes, that is true. The reason why I asked him to start with the extension is that it seems to work for all the other extensions (see his screen shot). So there seems to be something special with Python here. So in these cases we usually start with the extension that shows the problem. I am not saying that this is not a bug in VS Code. Are you able to reproduce this?

@DonJayamanne
Copy link
Contributor

Nope, not my end

@dbaeumer
Copy link
Member

I think what is special with his setup is that is OS locale is already Brazillian Portuguese. Could that have an impact for the Python extensions?

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Nov 13, 2018

Nope, there's nothing special about the localizations in our extension, we jsut create the localized files (package.nls.*.json) and that's it.

@dbaeumer
Copy link
Member

If we can't reproduce this and there is nothing with Python extension I have no idea how to track this down.

@pauloneves does this persist if you uninstall and reinstall the Python extension?

@berend
Copy link

berend commented Nov 15, 2018

I had the same issue (see microsoft/vscode-python#3307), only with german as second language. After uninstalling, reloading, installing the python extension again, everything is good. No German artifacts in the command palette. Also, with this I can not tell if I can reproduce the state where the extension was switched to german.

But: I did not change languages/locales in any way, it happened within the first day of using vscode and installing vs-code-python. Other extension I installed are:

  • redhat.vscode-yaml
  • ryanluker.vscode-coverage-gutters
  • mermade.openapi-lint

@DonJayamanne
Copy link
Contributor

If we can't reproduce this and there is nothing with Python extension I have no idea how to track this down.

We're in the same position, besides as mentioned earlier, we don't control what locale is picked by VSC, to my knowledge there's no such API in VSC.

@dbaeumer
Copy link
Member

@berend have you experienced this with any other extension?

@dbaeumer dbaeumer reopened this Nov 16, 2018
@berend
Copy link

berend commented Nov 16, 2018

No, I have not experienced this with other extensions. But - to be fair - I used command palette probably for python commands only.

Also if other extensions don't have german locales, the error would not have appeared (like for me the python jupyter settings were still english, because there was no german translation yet).

@pauloneves
Copy link
Author

I think I have a little more info. I never installed the localization of VSCode in my own language. I doubt any other extension already come localized to Brazilian Portuguese. Maybe VSCode isn't obeying my locale configuration. Since I don't have its localization installed, it defaults to English, but the Python extension has Portuguese and uses the translated strings.

@dbaeumer
Copy link
Member

@DonJayamanne how do you translate the python extension ?

@DonJayamanne
Copy link
Contributor

The messages you see in the screen shot are commands in the command pallete.
The translation is done by creating separate package.nls.*.json files and vsc picks the right one.

@nmacosta
Copy link

@pauloneves I have the same Issue, with Spanish as you can see in the image
image
Just for testing purposes I make a backup copy of the file package.nls.es.json (spanish version) and I replace it with a copy of package.nls.json and VSCode now shows the python command in English
image

@dbaeumer
Copy link
Member

What is really strange is the fact that this only happens with the Python extension. I will check what makes it so special.

@DonJayamanne is Python part of any language pack.

@dbaeumer
Copy link
Member

dbaeumer commented Nov 20, 2018

I can not reproduce this on a German Windows. See attached screen shot:

capture

There is one thing to note: since the Python extension ships the translations pre-packaged (not with a language pack) the following can happen on a German machine:

  • no locale.json file. Which means the default OS locale is considered
  • no German language pack installed.
  • then the Python UI will be in German but the rest not.

However when setting in the locale.json 'en' for me both VS Code and the python extension is on English (see screen shot).

@DonJayamanne you might want to consider shipping your translations inside the language pack

So the question is why this is not working for @nmacosta @pauloneves as it does for me :-( Is there anything you can detect that is different than what I tried?

@dbaeumer
Copy link
Member

@berend what is your default OS locale?

@dbaeumer dbaeumer added the info-needed Issue requires more information from poster label Nov 20, 2018
@berend
Copy link

berend commented Nov 20, 2018

German, I guess. This is a picture of my settings:
https://user-images.githubusercontent.com/673681/48338628-704dce00-e666-11e8-92dc-a8c81ee65dc1.png

If you need any other info, let me know.

Also, this is the output from locale

▶ locale
LANG="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_CTYPE="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_ALL=

@DonJayamanne
Copy link
Contributor

you might want to consider shipping your translations inside the language pack

What do you mean by language pack?

@dbaeumer
Copy link
Member

dbaeumer commented Nov 20, 2018

@berend this explains why you see the Python in German unless you configure the local for VS Code to be English in all cases. Can you still repro this even if you configure the display language to be English?

@DonJayamanne MS extensions are usually getting their strings through the language pack. VS Code itself only ships with English since a while. See https://marketplace.visualstudio.com/search?target=VSCode&category=Language%20Packs&sortBy=Downloads

@berend
Copy link

berend commented Nov 20, 2018 via email

@DonJayamanne
Copy link
Contributor

you might want to consider shipping your translations inside the language pack

@dbaeumer

Is this what other extension do? I don't think so.
E.g. if I created a brand new (personal) extension tomorrow, should I be submitting PRs for all the language packs in the marketplace or should i just add localization support for the extension & ship those files with my extension.

@marcosmesser
Copy link

marcosmesser commented Dec 12, 2018

@dbaeumer I'm sorry if I misled you into thinking it was a fresh vscode install, it wasn't; and never had its locale as 'pt-br'.

@dbaeumer
Copy link
Member

@marcosmesser the interesting question is if you had a locale.json file denoting 'en' before you installed Python.

@vscodebot vscodebot bot closed this as completed Dec 21, 2018
@vscodebot
Copy link

vscodebot bot commented Dec 21, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@dbaeumer dbaeumer reopened this Dec 21, 2018
@dbaeumer
Copy link
Member

Reopening since users still see this.

@vscodebot vscodebot bot closed this as completed Dec 28, 2018
@vscodebot
Copy link

vscodebot bot commented Dec 28, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@dbaeumer dbaeumer removed the info-needed Issue requires more information from poster label Jan 7, 2019
@dbaeumer dbaeumer reopened this Jan 7, 2019
@dbaeumer dbaeumer added this to the December/January 2019 milestone Jan 7, 2019
@dbaeumer
Copy link
Member

dbaeumer commented Jan 7, 2019

Lets see if we find something out in January.

@marcosmesser
Copy link

@dbaeumer Sorry, I don't have a Windows / pt-br environment anymore, and won't be able to test it. But, regarding your last question; I do believe there was a locale.json set to English, as I had been using that installation for a few months (always in English), with several extensions (all in English; although, I don't how many had localization).

@dbaeumer
Copy link
Member

Moving to February. Still no idea to reproduce :-(

@gzurl
Copy link

gzurl commented Feb 4, 2019

I was able to reproduce this issue on Mac whose locale is set to Spanish:

  • macOS 10.14.2
  • VS Code 1.30.2
  • Python Extension 2019.1.0
  • System 'locale' output:
LANG="es_ES.UTF-8"
LC_COLLATE="es_ES.UTF-8"
LC_CTYPE="es_ES.UTF-8"
LC_MESSAGES="es_ES.UTF-8"
LC_MONETARY="es_ES.UTF-8"
LC_NUMERIC="es_ES.UTF-8"
LC_TIME="es_ES.UTF-8"
LC_ALL=

All my VS Code UI is in English (as I want), but Python Extension is showing commands in the Command Palette in Spanish. Somehow, the Python Extension locale is being adopted from system locale and not from VS Code locale.

To solve this issue:

  1. Unistall Python Extension
  2. Reboot VS Code
  3. Reinstall Python Extension
  4. Reboot VS Code
  5. Now Python Commands are shown in English

@dbaeumer
Copy link
Member

dbaeumer commented Feb 4, 2019

@gzurl thanks. Anything special how you got into the state. I tried to get into it but without any luck. Do you know when you installed the Python extension did you already have switch the UI to English using the locale.json

@gzurl
Copy link

gzurl commented Feb 4, 2019

@dbaeumer nothing special: I just installed VS Code and the UI was already in English (which is great for me). So I didn't have to change any single line in my locale.json file. Here is its content anyway:

{
	// Defines VS Code's display language.
	// See https://go.microsoft.com/fwlink/?LinkId=761051 for a list of supported languages.
	
	"locale":"en" // Changes will not take effect until VS Code has been restarted.
}

I really think that for whatever reason the Python extension is not using this file to match its UI.

Hope this helps!

@emonette123
Copy link

This is not really a bug. Just a weird behavior of VS Code. What happens is if you never configure the display language, the locale.json file in AppData\Roaming\Code\User (on windows) is not created. If you do not have any language pack, the OS locale will be used, but VS Code will display in english. If your locale is in the Python extension (for me, it was French), then the commands of the extension appear in the locale.
What is confusing is if you open the Configure Display Language, the locale.json file appears, with english locale. Then the locale.json file is created, but you still have to restart VS Code to initialize the Python extension language.

For me at least, I can only reproduce if locale.json does not exist.

@dbaeumer
Copy link
Member

I found a code path were we ask the extension to use the OS locale even if the UI is not rendered in that locale. I will fix this. However this doesn't explain the behavior were a English locale is used in the locale.json file and not honored for the extension.

@dbaeumer dbaeumer modified the milestones: February 2019, March 2019 Feb 26, 2019
@chrish42
Copy link

I was seeing this today (VS Code in English, except for Python extension in French). emonette123's solution worked for me, so thanks. However, it is also a bug. All parts of the application should always be getting their locale setting from the same source.

@dbaeumer
Copy link
Member

Steps to reproduce:

  • OS locale in one of the VS Code core languages but not English (e.g. German)
  • make sure the corresponding VS Code language pack is NOT installed
  • install Python extension
  • Reload

Ensure that the Python commands in the command palette are shown in English.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions
Projects
None yet
Development

No branches or pull requests

10 participants