提交 42d87350 编写于 作者: D Dirk Baeumer

Fixes #4520: Code will not start with locale='zh-cn' or locale='zh-tw'

上级 ef2a1fca
......@@ -52,9 +52,9 @@ var vscodeLanguages = [
'ita'
];
var iso639_3_to_2 = {
'chs': 'zh-CN',
'cht': 'zh-TW',
'csy': 'cs-CZ',
'chs': 'zh-ch',
'cht': 'zh-tw',
'csy': 'cs-cz',
'deu': 'de',
'enu': 'en',
'esn': 'es',
......@@ -65,10 +65,10 @@ var iso639_3_to_2 = {
'kor': 'ko',
'nld': 'nl',
'plk': 'pl',
'ptb': 'pt-BR',
'ptb': 'pt-br',
'ptg': 'pt',
'rus': 'ru',
'sve': 'sv-SE',
'sve': 'sv-se',
'trk': 'tr'
};
function sortLanguages(directoryNames) {
......
......@@ -69,9 +69,9 @@ const vscodeLanguages: string[] = [
];
const iso639_3_to_2: Map<string> = {
'chs': 'zh-CN',
'cht': 'zh-TW',
'csy': 'cs-CZ',
'chs': 'zh-ch',
'cht': 'zh-tw',
'csy': 'cs-cz',
'deu': 'de',
'enu': 'en',
'esn': 'es',
......@@ -82,10 +82,10 @@ const iso639_3_to_2: Map<string> = {
'kor': 'ko',
'nld': 'nl',
'plk': 'pl',
'ptb': 'pt-BR',
'ptb': 'pt-br',
'ptg': 'pt',
'rus': 'ru',
'sve': 'sv-SE',
'sve': 'sv-se',
'trk': 'tr'
};
......
......@@ -11,6 +11,11 @@
import { env, languages, commands, workspace, window, Uri, ExtensionContext, IndentAction, Diagnostic, DiagnosticCollection, Range } from 'vscode';
// This must be the first statement otherwise modules might got loaded with
// the wrong locale.
import * as nls from 'vscode-nls';
nls.config({locale: env.language});
import * as Proto from './protocol';
import TypeScriptServiceClient from './typescriptServiceClient';
import { ITypescriptServiceClientHost } from './typescriptService';
......@@ -30,8 +35,6 @@ import WorkspaceSymbolProvider from './features/workspaceSymbolProvider';
import * as VersionStatus from './utils/versionStatus';
import * as ProjectStatus from './utils/projectStatus';
import * as nls from 'vscode-nls';
interface LanguageDescription {
id: string;
diagnosticSource: string;
......@@ -39,8 +42,6 @@ interface LanguageDescription {
}
export function activate(context: ExtensionContext): void {
nls.config({locale: env.language});
let MODE_ID_TS = 'typescript';
let MODE_ID_TSX = 'typescriptreact';
let MODE_ID_JS = 'javascript';
......
......@@ -36,8 +36,6 @@ function stripComments(content) {
return result;
};
// Duplicated in ../index.html for the renderes.
function getNLSConfiguration() {
var locale = undefined;
var localeOpts = '--locale';
......@@ -65,10 +63,15 @@ function getNLSConfiguration() {
}
}
locale = locale || app.getLocale();
// Language tags are case insensitve however an amd loader is case sensitive
// To make this work on case preserving & insensitive FS we do the following:
// the language bundles have lower case language tags and we always lower case
// the locale we receive from the user or OS.
locale = locale ? locale.toLowerCase() : locale;
if (locale === 'pseudo') {
return { locale: locale, availableLanguages: {}, pseudo: true }
}
locale = locale || app.getLocale();
var initialLocale = locale;
if (process.env.VSCODE_DEV) {
return { locale: locale, availableLanguages: {} };
......
......@@ -89,12 +89,16 @@ export const isQunit = _isQunit;
export const platform = _platform;
/**
* The language used for the user interface.
* The language used for the user interface. The format of
* the string is all lower case (e.g. zh-tw for Traditional
* Chinese)
*/
export const language = _language;
/**
* The OS locale or the locale specified by --locale
* The OS locale or the locale specified by --locale. The format of
* the string is all lower case (e.g. zh-tw for Traditional
* Chinese)
*/
export const locale = _locale;
......
......@@ -97,33 +97,6 @@
process.on('uncaughtException', function(error) { onError(error, enableDeveloperTools) });
}
function getNlsPluginConfiguration(configuration) {
var locale = configuration.locale;
if (locale === 'pseudo') {
return { availableLanguages: {}, pseudo: true }
}
if (!configuration.isBuilt) {
return { availableLanguages: {} };
}
// We have a built version so we have extracted nls file. Try to find
// the right file to use.
locale = locale || window.navigator.language;
while (locale) {
var candidate = path.join(__dirname, '..', 'workbench.main.nls.') + locale + '.js';
if (fs.existsSync(candidate)) {
return { availableLanguages: { '*': locale } };
} else {
var index = locale.lastIndexOf('-');
if (index > 0) {
locale = locale.substring(0, index);
} else {
locale = null;
}
}
}
return { availableLanguages: {} };
}
</script>
<!-- Startup Code -->
......@@ -173,7 +146,7 @@
} catch (e) {
}
if (!nlsConfig) {
nlsConfig = getNlsPluginConfiguration(configuration);
nlsConfig = { availableLanguages: {} };
}
require.config({
baseUrl: rootUrl,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册