Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/contrib/localization/browser/localeService.ts')
-rw-r--r--src/vs/workbench/contrib/localization/browser/localeService.ts51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/vs/workbench/contrib/localization/browser/localeService.ts b/src/vs/workbench/contrib/localization/browser/localeService.ts
index c59d84821b2..dc8138589bf 100644
--- a/src/vs/workbench/contrib/localization/browser/localeService.ts
+++ b/src/vs/workbench/contrib/localization/browser/localeService.ts
@@ -3,31 +3,62 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
-import { language } from 'vs/base/common/platform';
+import { localize } from 'vs/nls';
+import { Language } from 'vs/base/common/platform';
+import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import { ILanguagePackItem } from 'vs/platform/languagePacks/common/languagePacks';
import { ILocaleService } from 'vs/workbench/contrib/localization/common/locale';
+import { IHostService } from 'vs/workbench/services/host/browser/host';
+import { IProductService } from 'vs/platform/product/common/productService';
export class WebLocaleService implements ILocaleService {
declare readonly _serviceBrand: undefined;
- async setLocale(languagePackItem: ILanguagePackItem): Promise<boolean> {
+ constructor(
+ @IDialogService private readonly dialogService: IDialogService,
+ @IHostService private readonly hostService: IHostService,
+ @IProductService private readonly productService: IProductService
+ ) { }
+
+ async setLocale(languagePackItem: ILanguagePackItem): Promise<void> {
const locale = languagePackItem.id;
- if (locale === language || (!locale && language === navigator.language)) {
- return false;
+ if (locale === Language.value() || (!locale && Language.value() === navigator.language)) {
+ return;
}
if (locale) {
window.localStorage.setItem('vscode.nls.locale', locale);
} else {
window.localStorage.removeItem('vscode.nls.locale');
}
- return true;
- }
- async clearLocalePreference(): Promise<boolean> {
- if (language === navigator.language) {
- return false;
+ const restartDialog = await this.dialogService.confirm({
+ type: 'info',
+ message: localize('relaunchDisplayLanguageMessage', "To change the display language, {0} needs to reload", this.productService.nameLong),
+ detail: localize('relaunchDisplayLanguageDetail', "Press the reload button to refresh the page and set the display language to {0}.", languagePackItem.label),
+ primaryButton: localize({ key: 'reload', comment: ['&& denotes a mnemonic character'] }, "&&Reload"),
+ });
+
+ if (restartDialog.confirmed) {
+ this.hostService.restart();
}
+ }
+
+ async clearLocalePreference(): Promise<void> {
window.localStorage.removeItem('vscode.nls.locale');
- return true;
+
+ if (Language.value() === navigator.language) {
+ return;
+ }
+
+ const restartDialog = await this.dialogService.confirm({
+ type: 'info',
+ message: localize('clearDisplayLanguageMessage', "To change the display language, {0} needs to reload", this.productService.nameLong),
+ detail: localize('clearDisplayLanguageDetail', "Press the reload button to refresh the page and use your browser's language."),
+ primaryButton: localize({ key: 'reload', comment: ['&& denotes a mnemonic character'] }, "&&Reload"),
+ });
+
+ if (restartDialog.confirmed) {
+ this.hostService.restart();
+ }
}
}