From 19b127a6c9d2b7ba78d9ce9839e817d9d795a0d5 Mon Sep 17 00:00:00 2001 From: Michel Kaporin Date: Thu, 6 Apr 2017 16:37:52 +0200 Subject: [PATCH] Fixed language codes for build process. --- build/gulpfile.vscode.js | 25 ++++++++++++------------- build/lib/i18n.js | 13 ++++++++----- build/lib/i18n.ts | 14 +++++++++----- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/build/gulpfile.vscode.js b/build/gulpfile.vscode.js index e0f026cfccb..84fd5cc5342 100644 --- a/build/gulpfile.vscode.js +++ b/build/gulpfile.vscode.js @@ -343,21 +343,20 @@ gulp.task('vscode-linux-arm-min', ['minify-vscode', 'clean-vscode-linux-arm'], p // Transifex Localizations const vscodeLanguages = [ - 'chs', - 'cht', - 'jpn', - 'kor', - 'deu', - 'fra', - 'esn', - 'rus', - 'ita' + 'zh-hans', + 'zh-hant', + 'ja', + 'ko', + 'de', + 'fr', + 'es', + 'ru', + 'it' ]; - const setupDefaultLanguages = [ - 'chs', - 'cht', - 'kor' + 'zh-hans', + 'zh-hant', + 'ko' ]; const apiHostname = process.env.TRANSIFEX_API_URL; diff --git a/build/lib/i18n.js b/build/lib/i18n.js index b8bc05b043d..055894f081a 100644 --- a/build/lib/i18n.js +++ b/build/lib/i18n.js @@ -219,8 +219,8 @@ var vscodeLanguages = [ 'ita' ]; var iso639_3_to_2 = { - 'chs': 'zh-hans', - 'cht': 'zh-hant', + 'chs': 'zh-cn', + 'cht': 'zh-tw', 'csy': 'cs-cz', 'deu': 'de', 'enu': 'en', @@ -238,6 +238,9 @@ var iso639_3_to_2 = { 'sve': 'sv-se', 'trk': 'tr' }; +/** + * Used to map Transifex to VS Code language code representation. + */ var iso639_2_to_3 = { 'zh-hans': 'chs', 'zh-hant': 'cht', @@ -878,7 +881,7 @@ function retrieveResource(language, resource, apiHostname, credentials) { return new Promise(function (resolve, reject) { var slug = resource.name.replace(/\//g, '_'); var project = resource.project; - var iso639 = iso639_3_to_2[language]; + var iso639 = language.toLowerCase(); var options = { hostname: apiHostname, path: "/api/2/project/" + project + "/resource/" + slug + "/translation/" + iso639 + "?file&mode=onlyreviewed", @@ -890,7 +893,7 @@ function retrieveResource(language, resource, apiHostname, credentials) { res.on('data', function (data) { return xlfBuffer += data; }); res.on('end', function () { if (res.statusCode === 200) { - resolve(new File({ contents: new Buffer(xlfBuffer), path: project + "/" + language + "/" + slug + ".xlf" })); + resolve(new File({ contents: new Buffer(xlfBuffer), path: project + "/" + iso639_2_to_3[language] + "/" + slug + ".xlf" })); } reject(slug + " in " + project + " returned no data. Response code: " + res.statusCode + "."); }); @@ -909,7 +912,7 @@ function prepareJsonFiles() { var messages = file.messages, translatedFile; // ISL file path always starts with 'build/' if (file.originalFilePath.startsWith('build/')) { - var defaultLanguages = { 'zh-cn': true, 'zh-tw': true, 'ko': true }; + var defaultLanguages = { 'zh-hans': true, 'zh-hant': true, 'ko': true }; if (path.basename(file.originalFilePath) === 'Default' && !defaultLanguages[file.language]) { return; } diff --git a/build/lib/i18n.ts b/build/lib/i18n.ts index cba587b2441..2f4da02db39 100644 --- a/build/lib/i18n.ts +++ b/build/lib/i18n.ts @@ -279,8 +279,8 @@ const vscodeLanguages: string[] = [ ]; const iso639_3_to_2: Map = { - 'chs': 'zh-hans', - 'cht': 'zh-hant', + 'chs': 'zh-cn', + 'cht': 'zh-tw', 'csy': 'cs-cz', 'deu': 'de', 'enu': 'en', @@ -299,6 +299,9 @@ const iso639_3_to_2: Map = { 'trk': 'tr' }; +/** + * Used to map Transifex to VS Code language code representation. + */ const iso639_2_to_3: Map = { 'zh-hans': 'chs', 'zh-hant': 'cht', @@ -319,6 +322,7 @@ const iso639_2_to_3: Map = { 'sv-se': 'sve', 'tr': 'trk' }; + interface IDirectoryInfo { name: string; iso639_2: string; @@ -976,7 +980,7 @@ function retrieveResource(language: string, resource: Resource, apiHostname, cre return new Promise((resolve, reject) => { const slug = resource.name.replace(/\//g, '_'); const project = resource.project; - const iso639 = iso639_3_to_2[language]; + const iso639 = language.toLowerCase(); const options = { hostname: apiHostname, path: `/api/2/project/${project}/resource/${slug}/translation/${iso639}?file&mode=onlyreviewed`, @@ -989,7 +993,7 @@ function retrieveResource(language: string, resource: Resource, apiHostname, cre res.on('data', (data) => xlfBuffer += data); res.on('end', () => { if (res.statusCode === 200) { - resolve(new File({ contents: new Buffer(xlfBuffer), path: `${project}/${language}/${slug}.xlf` })); + resolve(new File({ contents: new Buffer(xlfBuffer), path: `${project}/${iso639_2_to_3[language]}/${slug}.xlf` })); } reject(`${slug} in ${project} returned no data. Response code: ${res.statusCode}.`); }); @@ -1012,7 +1016,7 @@ export function prepareJsonFiles(): ThroughStream { // ISL file path always starts with 'build/' if (file.originalFilePath.startsWith('build/')) { - const defaultLanguages = { 'zh-cn': true, 'zh-tw': true, 'ko': true }; + const defaultLanguages = { 'zh-hans': true, 'zh-hant': true, 'ko': true }; if (path.basename(file.originalFilePath) === 'Default' && !defaultLanguages[file.language]) { return; }