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

Use platform.language more #171659

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,18 +575,27 @@ async function resolveNlsConfiguration() {
// VS Code moves to Electron 22.
// Ref https://github.com/microsoft/vscode/issues/159813
// and https://github.com/electron/electron/pull/36035
// if ('getPreferredSystemLanguages' in app
// && typeof app.getPreferredSystemLanguages === 'function'
// && app.getPreferredSystemLanguages().length) {
// appLocale = app.getPreferredSystemLanguages()[0];
// }
if (process.platform === 'win32'
&& 'getPreferredSystemLanguages' in app
&& typeof app.getPreferredSystemLanguages === 'function'
&& app.getPreferredSystemLanguages().length) {
// Use the most preferred OS language for language recommendation.
appLocale = app.getPreferredSystemLanguages()[0];
}

if (!appLocale) {
nlsConfiguration = { locale: 'en', availableLanguages: {} };
} else {

// See above the comment about the loader and case sensitiveness
appLocale = appLocale.toLowerCase();

if (appLocale.startsWith('zh-hans')) {
appLocale = 'zh-cn';
} else if (appLocale.startsWith('zh-hant')) {
appLocale = 'zh-tw';
}

const { getNLSConfiguration } = require('./vs/base/node/languagePacks');
nlsConfiguration = await getNLSConfiguration(product.commit, userDataPath, metaDataFile, appLocale);
if (!nlsConfiguration) {
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/comments/browser/timestamp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import * as dom from 'vs/base/browser/dom';
import { fromNow } from 'vs/base/common/date';
import { Disposable } from 'vs/base/common/lifecycle';
import { language } from 'vs/base/common/platform';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { COMMENTS_SECTION, ICommentsConfiguration } from 'vs/workbench/contrib/comments/common/commentsConfiguration';

Expand Down Expand Up @@ -62,6 +63,6 @@ export class TimestampWidget extends Disposable {
}

private getDateString(date: Date): string {
return date.toLocaleString();
return date.toLocaleString(language);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,7 @@ export class LocalizationWorkbenchContribution extends Disposable implements IWo

private checkAndInstall(): void {
const language = platform.language;
let locale = platform.locale ?? '';
if (locale.startsWith('zh-hans')) {
locale = 'zh-cn';
} else if (locale.startsWith('zh-hant')) {
locale = 'zh-tw';
}
const locale = platform.locale ?? '';
const languagePackSuggestionIgnoreList = <string[]>JSON.parse(this.storageService.get(LANGUAGEPACK_SUGGESTION_IGNORE_STORAGE_KEY, StorageScope.APPLICATION, '[]'));

if (!this.galleryService.isEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { disposableTimeout, RunOnceScheduler } from 'vs/base/common/async';
import { Disposable, dispose, IDisposable, MutableDisposable } from 'vs/base/common/lifecycle';
import { language } from 'vs/base/common/platform';
import { localize } from 'vs/nls';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { themeColorFromId, ThemeIcon } from 'vs/platform/theme/common/themeService';
Expand Down Expand Up @@ -272,7 +273,7 @@ class TimerCellStatusBarItem extends Disposable {
text: formatCellDuration(duration),
alignment: CellStatusbarAlignment.Left,
priority: Number.MAX_SAFE_INTEGER - 1,
tooltip: isDone ? new Date(endTime).toLocaleString() : undefined
tooltip: isDone ? new Date(endTime).toLocaleString(language) : undefined
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { IConfigurationResolverService } from 'vs/workbench/services/configurati
import { sanitizeProcessEnvironment } from 'vs/base/common/processes';
import { ILogService } from 'vs/platform/log/common/log';
import { IShellLaunchConfig, ITerminalEnvironment, TerminalSettingId, TerminalSettingPrefix, TerminalShellType, WindowsShellType } from 'vs/platform/terminal/common/terminal';
import { IProcessEnvironment, isWindows, locale, OperatingSystem, platform, Platform } from 'vs/base/common/platform';
import { IProcessEnvironment, isWindows, language, OperatingSystem, platform, Platform } from 'vs/base/common/platform';
import { escapeNonWindowsPath, sanitizeCwd } from 'vs/platform/terminal/common/terminalEnvironment';
import { isString } from 'vs/base/common/types';
import { ITerminalBackend } from 'vs/workbench/contrib/terminal/common/terminal';
Expand Down Expand Up @@ -390,7 +390,7 @@ export async function createTerminalEnvironment(
mergeEnvironments(env, shellLaunchConfig.env);

// Adding other env keys necessary to create the process
addTerminalEnvironmentKeys(env, version, locale, detectLocale);
addTerminalEnvironmentKeys(env, version, language, detectLocale);
}
return env;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { DeferredPromise } from 'vs/base/common/async';
import { Emitter, Event } from 'vs/base/common/event';
import { Disposable } from 'vs/base/common/lifecycle';
import { language } from 'vs/base/common/platform';
import { listenStream } from 'vs/base/common/stream';
import { isDefined } from 'vs/base/common/types';
import { localize } from 'vs/nls';
Expand Down Expand Up @@ -152,7 +153,7 @@ export class TestingOutputTerminalService implements ITestingOutputTerminalServi
}

const completedAt = result.completedAt ? new Date(result.completedAt) : new Date();
const text = localize('runFinished', 'Test run finished at {0}', completedAt.toLocaleString());
const text = localize('runFinished', 'Test run finished at {0}', completedAt.toLocaleString(language));
output.pushData(`\r\n\r\n\x1b[1m> ${text} <\x1b[0m\r\n\r\n`);
output.ended = true;
this.revealMarker(terminal, thenSelectMarker);
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/contrib/testing/common/testResult.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TestCoverage } from 'vs/workbench/contrib/testing/common/testCoverage';
import { maxPriority, statesInOrder, terminalStatePriorities } from 'vs/workbench/contrib/testing/common/testingStates';
import { removeAnsiEscapeCodes } from 'vs/base/common/strings';
import { TestId } from 'vs/workbench/contrib/testing/common/testId';
import { language } from 'vs/base/common/platform';

export interface ITestRunTaskResults extends ITestRunTask {
/**
Expand Down Expand Up @@ -286,7 +287,7 @@ export class LiveTestResult implements ITestResult {
public readonly onChange = this.changeEmitter.event;
public readonly onComplete = this.completeEmitter.event;
public readonly tasks: ITestRunTaskResults[] = [];
public readonly name = localize('runFinished', 'Test run at {0}', new Date().toLocaleString());
public readonly name = localize('runFinished', 'Test run at {0}', new Date().toLocaleString(language));

/**
* @inheritdoc
Expand Down