This repository has been archived by the owner on Dec 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for localization in extension (#24)
PBI: 29016 Task: 29017, 29018
- Loading branch information
Showing
10 changed files
with
2,161 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ | |
|
||
# Compiled JS code | ||
out/ | ||
!locales/**/out/ | ||
package.nls.*.json | ||
|
||
# User-specific files | ||
*.suo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
} | ||
] | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "npm", | ||
"script": "watch", | ||
"problemMatcher": "$tsc-watch", | ||
"isBackground": true, | ||
"presentation": { | ||
"reveal": "never" | ||
}, | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
} | ||
}, | ||
{ | ||
"type": "gulp", | ||
"task": "add-locales", | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
const gulp = require("gulp"); | ||
|
||
const ts = require("gulp-typescript"); | ||
const sourcemaps = require("gulp-sourcemaps"); | ||
const typescript = require("typescript"); | ||
const del = require("del"); | ||
const es = require("event-stream"); | ||
const vsce = require("vsce"); | ||
const nls = require("vscode-nls-dev"); | ||
|
||
const tsProject = ts.createProject("./tsconfig.json", { typescript }); | ||
|
||
const inlineMap = true; | ||
const inlineSource = false; | ||
const outDest = "out"; | ||
|
||
// A list of all locales supported by VSCode can be found here: https://code.visualstudio.com/docs/getstarted/locales | ||
const languages = [{ folderName: "en", id: "en" }]; | ||
|
||
gulp.task("clean", () => { | ||
return del( | ||
["out/**", "package.nls.*.json", "../../dist/*0.0.0-UNTRACKEDVERSION.vsix"], | ||
{ force: true } | ||
); | ||
}); | ||
|
||
const pythonToMove = ["./src/adafruit_circuitplayground/*.*", "./src/*.py"]; | ||
|
||
gulp.task("python-compile", () => { | ||
// the base option sets the relative root for the set of files, | ||
// preserving the folder structure | ||
return gulp.src(pythonToMove, { base: "./src/" }).pipe(gulp.dest("out")); | ||
}); | ||
|
||
gulp.task("internal-compile", () => { | ||
return compile(false); | ||
}); | ||
|
||
gulp.task("internal-nls-compile", () => { | ||
return compile(true); | ||
}); | ||
|
||
gulp.task("add-locales", () => { | ||
return gulp | ||
.src(["package.nls.json"]) | ||
.pipe(nls.createAdditionalLanguageFiles(languages, "locales")) | ||
.pipe(gulp.dest(".")); | ||
}); | ||
|
||
gulp.task("vsce:publish", () => { | ||
return vsce.publish(); | ||
}); | ||
|
||
gulp.task("vsce:package", () => { | ||
return vsce.createVSIX({ | ||
packagePath: "../../dist/pacifica-0.0.0-UNTRACKEDVERSION.vsix" | ||
}); | ||
}); | ||
|
||
gulp.task( | ||
"compile", | ||
gulp.series("clean", "internal-compile", "python-compile", callback => { | ||
callback(); | ||
}) | ||
); | ||
|
||
gulp.task( | ||
"build", | ||
gulp.series( | ||
"clean", | ||
"internal-nls-compile", | ||
"python-compile", | ||
"add-locales", | ||
callback => { | ||
callback(); | ||
} | ||
) | ||
); | ||
|
||
gulp.task( | ||
"publish", | ||
gulp.series("compile", "vsce:publish", callback => { | ||
callback(); | ||
}) | ||
); | ||
|
||
gulp.task( | ||
"package", | ||
gulp.series("compile", "vsce:package", callback => { | ||
callback(); | ||
}) | ||
); | ||
|
||
//---- internal | ||
|
||
function compile(buildNls) { | ||
var r = tsProject | ||
.src() | ||
.pipe(sourcemaps.init()) | ||
.pipe(tsProject()) | ||
.js.pipe(buildNls ? nls.rewriteLocalizeCalls() : es.through()) | ||
.pipe( | ||
buildNls | ||
? nls.createAdditionalLanguageFiles(languages, "locales", "out") | ||
: es.through() | ||
); | ||
|
||
if (inlineMap && inlineSource) { | ||
r = r.pipe(sourcemaps.write()); | ||
} else { | ||
r = r.pipe( | ||
sourcemaps.write("../out", { | ||
// no inlined source | ||
includeContent: inlineSource, | ||
// Return relative source map root directories per file. | ||
sourceRoot: "../src" | ||
}) | ||
); | ||
} | ||
|
||
return r.pipe(gulp.dest(outDest)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"error.stderr": "[ERROR] {0} \n", | ||
"error.unexpectedMessage": "Webview sent an unexpected message", | ||
"info.deployOutput": "\n[INFO] Deploying code to the simulator...\n", | ||
"info.extensionActivated": "Congratulations, your extension Adafruit_Simulator is now active!", | ||
"info.runningCode": "Running user code", | ||
"info.welcomeOutputTab": "Welcome to the Adafruit Simulator output tab !\n\n", | ||
"label.webviewPanel": "Adafruit CPX", | ||
"name": "Adafruit Simulator" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"pacificaExtension.commands.label": "Adafruit", | ||
"pacificaExtension.commands.openSimulator": "Open Simulator", | ||
"pacificaExtension.commands.runSimulator": "Run Simulator" | ||
} |
Oops, something went wrong.