Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb11f04

Browse files
committed
fix: prioritize enviornment variables over Intl.DateTimeFormat
While `Intl.DateTimeFormat` should be the most reliable way to get theuser's locale, it lacks flexibility.For example, on Windows PowerShell, there's no way to change thedetection result in-session (you have to logout and login again).So in order to provide an escape hatch for developers and users whowant to temporarily change the locale, we prioritize environmentvariables over `Intl.DateTimeFormat`.In POSIX shells, you can do `LANG=zh_CN.UTF-8` to change the locale toChinese;In CMD, it's `set LANG=zh_CN.UTF-8`;In PowerShell, it's `$env:LANG = 'zh_CN.UTF-8'`.Closes#369
1 parent6665f0e commitbb11f04

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎utils/getLanguage.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ interface Language {
4545

4646
functiongetLocale(){
4747
constshellLocale=
48-
Intl.DateTimeFormat().resolvedOptions().locale||// Built-in ECMA-402 support
4948
process.env.LC_ALL||// POSIX locale environment variables
5049
process.env.LC_MESSAGES||
5150
process.env.LANG||
52-
//TODO: Windows support if needed, could consider https://www.npmjs.com/package/os-locale
51+
Intl.DateTimeFormat().resolvedOptions().locale||//Built-in ECMA-402 support
5352
'en-US'// Default fallback
5453

5554
constlocale=shellLocale.split('.')[0].replace('_','-')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp