microsoft/vscode-react-native

Public

mirrored fromhttps://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1fe78525cb3778a3fadfcad91e71c2720d5cb626

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

gulp_scripts/translator.js

87lines · modecode

1const gulp = require("gulp");
2const log = require("fancy-log");
3const path = require("path");
4const nls = require("vscode-nls-dev");
5const es = require("event-stream");
6const minimist = require("minimist");
7
8const getBuilder = require(appRoot + "/gulp_scripts/builder");
9
10/**
11 * Whether we're running a nightly build.
12 */
13const isNightly = process.argv.includes("--nightly");
14
15const fullExtensionName = isNightly
16 ? "msjsdiag.vscode-react-native-preview"
17 : "msjsdiag.vscode-react-native";
18
19const translationProjectName = "vscode-extensions";
20
21const defaultLanguages = [
22 { id: "zh-tw", folderName: "cht", transifexId: "zh-hant" },
23 { id: "zh-cn", folderName: "chs", transifexId: "zh-hans" },
24 { id: "ja", folderName: "jpn" },
25 { id: "ko", folderName: "kor" },
26 { id: "de", folderName: "deu" },
27 { id: "fr", folderName: "fra" },
28 { id: "es", folderName: "esn" },
29 { id: "ru", folderName: "rus" },
30 { id: "it", folderName: "ita" },
31
32 // These language-pack languages are included for VS but excluded from the vscode package
33 { id: "cs", folderName: "csy" },
34 { id: "tr", folderName: "trk" },
35 { id: "pt-br", folderName: "ptb", transifexId: "pt-BR" },
36 { id: "pl", folderName: "plk" },
37];
38
39function addi18n() {
40 return gulp
41 .src(["package.nls.json"])
42 .pipe(nls.createAdditionalLanguageFiles(defaultLanguages, "i18n"))
43 .pipe(gulp.dest("."));
44}
45
46const translationsExport = gulp.series(getBuilder.buildTask, function runTranslationExport() {
47 return gulp
48 .src(["package.nls.json", "nls.metadata.header.json", "nls.metadata.json"])
49 .pipe(nls.createXlfFiles(translationProjectName, fullExtensionName))
50 .pipe(gulp.dest(path.join("..", `${translationProjectName}-localization-export`)));
51});
52
53const translationImport = gulp.series(done => {
54 var options = minimist(process.argv.slice(2), {
55 string: "location",
56 default: {
57 location: "../vscode-translations-import",
58 },
59 });
60 es.merge(
61 defaultLanguages.map(language => {
62 let id = language.transifexId || language.id;
63 log(path.join(options.location, id, "vscode-extensions", `${fullExtensionName}.xlf`));
64 return gulp
65 .src(
66 path.join(
67 options.location,
68 id,
69 "vscode-extensions",
70 `${fullExtensionName}.xlf`,
71 ),
72 )
73 .pipe(nls.prepareJsonFiles())
74 .pipe(gulp.dest(path.join("./i18n", language.folderName)));
75 }),
76 ).pipe(
77 es.wait(() => {
78 done();
79 }),
80 );
81}, addi18n);
82
83module.exports = {
84 addi18n,
85 translationImport,
86 translationsExport,
87};
88