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

OSX launches with wrong locale #16261

Closed
mikes-gh opened this issue Nov 30, 2016 · 18 comments
Closed

OSX launches with wrong locale #16261

mikes-gh opened this issue Nov 30, 2016 · 18 comments
Assignees
Labels
electron Issues and items related to Electron help wanted Issues identified as good community contribution opportunities *out-of-scope Posted issue is not in scope of VS Code upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@mikes-gh
Copy link

  • VSCode Version: 1.7.2
  • OS Version: OSX 10.12
    locale en-GB
    Steps to Reproduce:
  1. lauch vscode from Dock or applications I get en-US dates from Date.prototype.toLocaleString();
  2. launch vscode from terminal using code I get en-GB dates from Date.prototype.toLocaleString();

On Windows 7 I always get en-GB dates

@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Nov 30, 2016
@dbaeumer dbaeumer assigned bpasero and unassigned dbaeumer Dec 1, 2016
@dbaeumer
Copy link
Member

dbaeumer commented Dec 1, 2016

This has nothing to do with i18n.

@bpasero moving to you since this looks like a electron / node issue under Mac.

@bpasero bpasero added help wanted Issues identified as good community contribution opportunities upstream Issue identified as 'upstream' component related (exists outside of VS Code) labels Dec 1, 2016
@bpasero bpasero added this to the Backlog milestone Dec 1, 2016
@joews
Copy link

joews commented Dec 5, 2016

I can't replicate with:

  • VSCode Version: 1.7.2
  • OS Version: OSX 10.12.1

OS Language preference set to "English". $LANG: en_GB.UTF-8

Steps:

  1. Launch code from Dock.
  2. Open developer tools.
  3. Run in the console new Date().toLocaleString()

I see ex. "05/12/2016, 22:47:16"

Then:

  1. Exit code
  2. Use System Preferences > Language to change locale to United States. $LANG: en_US.UTF-8
  3. Re-open code from Dock
  4. Open developer tools
  5. Run in the console new Date().toLocaleString()

I see ex. "12/5/2016, 10:49:09 PM"

So the OS locale is honoured and picks up changes immediately. @mikes-gh does this match what you did?

@mikes-gh
Copy link
Author

mikes-gh commented Dec 6, 2016

Yes I get the same results as you.
The developer console gives correct results.

I get incorrect results from ToLocaleString() in the extension Im working on.

You could try this as a repo.

  1. ext Install
  2. select - git history (git log)

https://github.com/DonJayamanne/gitHistoryVSCode

Steps to get incorrect results

  1. Start vscode from dock or applications
  2. Open any repo.
  3. Right click a file -> Git View File History
  4. I get american dates in the item list (incorrect locale)

Steps to get correct results

  1. Start vscode from terminal using code
  2. Open any repo.
  3. Right click a file -> Git View File History
  4. I get British dates (correct locale)

Let me know if you can reproduce . Thanks for your help on this

@mikes-gh
Copy link
Author

mikes-gh commented Dec 18, 2016

@jwhitfieldseed Did you mange to reproduce?

@joews
Copy link

joews commented Jan 13, 2017

@mikes-gh I'm sorry for the slow reply, I missed the notification.

I can repro with your steps. I also get the incorrect results launching with Spotlight and Alfred.

I can also repro with a fresh extension. I ran yo code and replaced the default message in extension.ts with:

vscode.window.showInformationMessage('Hello World! ' + new Date().toLocaleString());
vscode.window.showInformationMessage(`[${vscode.env.language}]`);
vscode.window.showInformationMessage(`[${process.env.LANG}]`)

Opening code from the terminal:

Hello World! 13/01/2017, 22:52:41
[en]
[en_GB.UTF-8]

Opening code from Applications, Dock etc:

Hello World! 1/13/2017, 10:53:46 PM
[en]
[undefined]

Opening code from the terminal with an explicit language, like this:

"/Applications/Visual Studio Code.app/Contents/MacOS/Electron" -AppleLanguages '(fr)' ~/code/hello

Gives me:

Hello World! 13/01/2017, 23:16:01
[fr]
[en_GB.UTF-8]

This is exactly the same output as if I change the OS language setting to French and open code from the terminal.

When I change the OS language setting to French and open code from the Dock, I get:

Hello World! 1/13/2017, 11:28:12 PM
[fr]
[undefined]

The expected output for new Date().toLocaleString() in French is "13/01/2017 à 23:26:42. (open Developer Tools in Code with the system language set to French and try it in the console).

This looks like two issues to me:

  1. When code is opened in a way other than the terminal, it uses the en-US locale. It should use the system locale.
  2. When code is opened from the terminal, it uses $LANG instead of the default locale.

I'm not sure if part 2 is a bug or desired behaviour.

@joews
Copy link

joews commented Jan 13, 2017

I can also repro with a vanilla Electron app:

  1. https://github.com/electron/electron-quick-start
  2. npm install npm install electron-packager
  3. Add to the createWindow method of main.js:
electron.dialog.showMessageBox({  message: new Date().toLocaleString()  })
  1. ./node_modules/.bin/electron-packager . --platform=darwin

Running from the terminal: (./electron-quick-start-darwin-x64/electron-quick-start.app/Contents/MacOS/electron-quick-start) alerts 13/01/2017, 23:49:05

Running from Finder alerts 1/13/2017 11:50:47.

I can't tell if this is a vanilla Electron or a packaging issue (since I don't know how to repro it without a packager). I'll raise an issue on electron-packager for now.

@bpasero
Copy link
Member

bpasero commented May 15, 2017

@mikes-gh can you print what kind of environment variables you have defined? I suspect your terminal has some LC_ variables defined that are set when you run from terminal and not when you run from the Dock.

@mikes-gh
Copy link
Author

mikes-gh commented Jun 3, 2017

@bpasero

TERM_PROGRAM=Apple_Terminal
SHELL=/bin/bash
TERM=xterm-256color
TMPDIR=/var/folders/l9/3f8nhyrj2ts60qr9w44q_rdh0000gn/T/
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.YGit9FQ6Gk/Render
TERM_PROGRAM_VERSION=388.1
TERM_SESSION_ID=05F369FB-124B-42DF-8AB2-230ED2BEE1DE
USER=MikeS
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.DlsCIBBwuW/Listeners
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x2
PATH=/Users/MikeS/.dnx/runtimes/dnx-mono.1.0.0-rc2-16441/bin:/Users/MikeS/.dnx/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet
PWD=/Users/MikeS
LANG=en_GB.UTF-8
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
SHLVL=1
HOME=/Users/MikeS
LOGNAME=MikeS
_=/usr/bin/env

@bpasero
Copy link
Member

bpasero commented Jun 4, 2017

@mikes-gh you should be able to fix this by removing this from your environment:

LANG=en_GB.UTF-8

@mikes-gh
Copy link
Author

mikes-gh commented Jun 4, 2017

The problem is launching from dock.
Launching from a terminal window works so actually what you suggest would break my desired behaviour.

Desired behaviour is that vscode uses computer regional settings.

Its a confirmed issue with electron

@wraith13
Copy link

I also encountered the same cause problem.
Because LANG is empty, pbcopy / pbpaste and its dependent node-copy-paste do not work correctly with Non-ASCII characters.

@bpasero bpasero added electron Issues and items related to Electron and removed workbench labels Nov 12, 2017
@bpasero
Copy link
Member

bpasero commented Nov 14, 2017

Is this still happening?

@bpasero bpasero added the info-needed Issue requires more information from poster label Nov 14, 2017
@wraith13
Copy link

Yes, it is. ( vscode 1.18.0, macOS Sierra 10.12.6 )

@bpasero bpasero removed the info-needed Issue requires more information from poster label Nov 15, 2017
@bpasero bpasero removed this from the Backlog milestone Nov 16, 2017
@bpasero
Copy link
Member

bpasero commented Aug 17, 2018

Is this still happening?

@bpasero bpasero added the info-needed Issue requires more information from poster label Aug 17, 2018
@wraith13
Copy link

Yes, it is. ( vscode 1.26.1, macOS High Sierra 10.13.5 )

This is my vscode extention's screenshot when
launch vscode from code command on Terminal.app. 🐕 is displayed correctly.
2018-08-17 22 53 09

This is my vscode extention's screenshot when
launch vscode from dock or launchpad or spotlight.🐕 is not displayed correctly.
2018-08-17 22 53 53

I can not recommend vscode to mac users because of this problem.

@bpasero bpasero removed the info-needed Issue requires more information from poster label Aug 18, 2018
wraith13 added a commit to wraith13/sysinfo-vscode that referenced this issue Sep 14, 2018
とは言っても、とりあえず microsoft/vscode#16261 の問題についてのみ
@wraith13
Copy link

This is still happening. ( vscode 1.27.2, macOS Mojave 10.14 ( Darwin 18.0.0 ) )

( I know it is macOS's fault. This is just a report. )

@wcass77
Copy link

wcass77 commented Feb 21, 2019

I'm having an issue that I think is related to this. I changed my $SHELL with

chsh -s /usr/local/bin/bash

to use the homebrew version. The change was picked up immediately by Terminal.app when creating a new shell. VSCode continues to launch the OSX version and

echo $SHELL

produces: /bin/bash (VSCode) instead of the /usr/local/bin/bash (Terminal.app)

A workaround is to set the "terminal.integrated.shell.osx" option. This launches the right shell, but doesn't fix $SHELL, so I also added this to ~/.bash_profile:

# Fix $SHELL when using vscode:
export SHELL="/usr/local/bin/bash"

Hope people find this helpful.

Also, I think this is related to some downstream vscode-python issues with environment variables:
microsoft/vscode-python#1027
microsoft/vscode-python#1403

@vscodebot vscodebot bot added the *out-of-scope Posted issue is not in scope of VS Code label Oct 7, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 7, 2019

This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

Thanks for your understanding and happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron Issues and items related to Electron help wanted Issues identified as good community contribution opportunities *out-of-scope Posted issue is not in scope of VS Code upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

7 participants