Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localization #18962

Merged
merged 41 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
b6b656b
Add localization (#18954)
paulacamargo25 Apr 19, 2022
a82e89f
Update pipeline
paulacamargo25 Apr 19, 2022
69e2abc
Update pushStep
paulacamargo25 Apr 19, 2022
21e8047
Fix move item step
paulacamargo25 Apr 19, 2022
162bfe8
Fix pull Steps
paulacamargo25 Apr 19, 2022
166f1fa
Fix pipeline push and pull
paulacamargo25 Apr 19, 2022
710a6da
Fix translations import param
paulacamargo25 Apr 19, 2022
38216c2
Fix generate translations task
paulacamargo25 Apr 20, 2022
6d04906
Add generate translation task to compile script
paulacamargo25 Apr 20, 2022
e4bc379
Add generate translations in the build steps
paulacamargo25 Apr 20, 2022
b226bcf
Change i18n pt-br file name
paulacamargo25 Apr 20, 2022
dd60351
Delete package.nls.de.json
paulacamargo25 Apr 20, 2022
f6d0349
Delete package.nls.pt-br.json
paulacamargo25 Apr 20, 2022
b05c883
Move generate translation task to PullStep
paulacamargo25 Apr 20, 2022
0486c9a
Add nls webpack configuration
paulacamargo25 Apr 20, 2022
e3e3c25
Add nls config in extension.ts
paulacamargo25 Apr 20, 2022
66886e4
Try new path in webpack loader
paulacamargo25 Apr 20, 2022
4c1089d
Test removing nls conf
paulacamargo25 Apr 20, 2022
bd82056
Add nls plugin
paulacamargo25 Apr 20, 2022
8a7c51b
Fix translations, remove nls pluging
paulacamargo25 Apr 20, 2022
f709c31
Remove unnecessary files
paulacamargo25 Apr 20, 2022
6f6f9d9
Clean code
paulacamargo25 Apr 20, 2022
2cd4150
Fix some comments
paulacamargo25 Apr 21, 2022
27d0df0
Remove unnecessary packages
paulacamargo25 Apr 21, 2022
45e3694
Fix string with format
paulacamargo25 Apr 23, 2022
37d2c9d
Merge branch 'main' of github.com:microsoft/vscode-python into Add-lo…
paulacamargo25 Apr 23, 2022
9b92cd7
Fix localize string
paulacamargo25 Apr 23, 2022
9be935d
Fix test in watcher
paulacamargo25 Apr 23, 2022
139d397
Ignore localization files
paulacamargo25 Apr 25, 2022
153e21f
Change strings in tests
paulacamargo25 Apr 25, 2022
a0534b2
Test importing nls in other file
paulacamargo25 Apr 25, 2022
595ba89
Fix comment in translations in tests
paulacamargo25 Apr 25, 2022
663d108
Add missing translations
paulacamargo25 Apr 25, 2022
6cd92df
Remove nls config in all files
paulacamargo25 Apr 25, 2022
d6e1563
Add location steps in the stable pipeline
paulacamargo25 Apr 25, 2022
7c9bcf7
Using new vscode-engineering feature to abstract away gulp (#19063)
TylerLeonhardt May 3, 2022
0c9a2fc
Merge branch 'main' of github.com:microsoft/vscode-python into Add-lo…
paulacamargo25 May 4, 2022
59706af
Add i18n to vscodeignore
paulacamargo25 May 4, 2022
3cb9db8
Clean Code
paulacamargo25 May 4, 2022
fc15653
Remove old translations
paulacamargo25 May 4, 2022
c413d15
update templates to main
TylerLeonhardt May 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion build/azure-pipeline.pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,32 @@ resources:
- repository: templates
type: github
name: microsoft/vscode-engineering
ref: main
ref: tyler/translations
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
endpoint: Monaco

extends:
template: azure-pipelines/extension/pre-release.yml@templates
parameters:
locPushSteps:
- script: echo '$(SetTranslationsPath.EnglishStrings)'
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
- script: npm ci
displayName: Install NPM dependencies
- script: npm run translations-export
displayName: Run translations-export
- pwsh: |
$Destination = "$(SetTranslationsPath.EnglishStrings)"
Move-Item "$(Pipeline.Workspace)/ms-python.python/*" $Destination -Force
displayName: Move vscode-python-translations-export to translations path
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved

locPullSteps:
- script: echo '$(SetTranslationsPath.TranslatedStrings)'
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
- script: npm ci
displayName: Install NPM dependencies
- script: gulp translations-import --location "$(SetTranslationsPath.TranslatedStrings)"
- pwsh: ls ./i18n/
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
- script: gulp translations-generate
displayName: Generate translations

buildSteps:
- task: NodeTool@0
inputs:
Expand Down
6 changes: 6 additions & 0 deletions build/webpack/webpack.extension.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ const config = {
},
module: {
rules: [
{
loader: 'vscode-nls-dev/lib/webpack-loader',
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
options: {
base: path.join(__dirname, '../../src/client'),
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
test: /\.ts$/,
use: [
Expand Down
124 changes: 123 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,19 @@ const flat = require('flat');
const { argv } = require('yargs');
const os = require('os');
const rmrf = require('rimraf');
const nls = require('vscode-nls-dev');
const sourcemaps = require('gulp-sourcemaps');
const typescript = require('typescript');
const es = require('event-stream');
const minimist = require('minimist');

const tsProject = ts.createProject('./tsconfig.json', { typescript });
const filter = require('gulp-filter');

const isCI = process.env.TRAVIS === 'true' || process.env.TF_BUILD !== undefined;

gulp.task('compile', (done) => {
let failed = false;
const tsProject = ts.createProject('tsconfig.json');
tsProject
.src()
.pipe(tsProject())
Expand Down Expand Up @@ -353,3 +360,118 @@ function hasNativeDependencies() {
}
return false;
}

const translationProjectName = 'ms-python.python';
const translationExtensionName = 'vscode-python';

const defaultLanguages = [
{ id: 'de', folderName: 'de' },
{ id: 'fr', folderName: 'fr' },
{ id: 'es', folderName: 'es' },
{ id: 'cs', folderName: 'cs' },
{ id: 'it', folderName: 'it' },
{ id: 'ja', folderName: 'ja' },
{ id: 'ko', folderName: 'ko' },
{ id: 'pl', folderName: 'pl' },
{ id: 'pt-BR', folderName: 'pt-br' },
{ id: 'ru', folderName: 'ru' },
{ id: 'tr', folderName: 'tr' },
{ id: 'zh-Hans', folderName: 'zh-Hans' },
{ id: 'zh-Hant', folderName: 'zh-Hant' },
{ id: 'qps-ploc', folderName: 'qps-ploc' },
];
// ****************************
// Command: translations-generate
// The following is used to import an i18n directory structure and generate files used at runtime.
// ****************************

// Generate package.nls.*.json files from: ./i18n/*/package.i18n.json
// Outputs to root path, as these nls files need to be along side package.json

const generateAdditionalLocFiles = () =>
gulp
.src(['package.nls.json'])
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
.pipe(gulp.dest('.'));

// Generates ./dist/nls.bundle.<language_id>.json from files in ./i18n/** *//<src_path>/<filename>.i18n.json
// Localized strings are read from these files at runtime.
const generateSrcLocBundle = () =>
// Transpile the TS to JS, and let vscode-nls-dev scan the files for calls to localize.
tsProject
.src()
.pipe(sourcemaps.init())
.pipe(tsProject())
.js.pipe(nls.createMetaDataFiles())
.pipe(nls.createAdditionalLanguageFiles(defaultLanguages, 'i18n'))
.pipe(nls.bundleMetaDataFiles('ms-vscode.python', 'out'))
.pipe(nls.bundleLanguageFiles())
.pipe(filter(['**/nls.bundle.*.json', '**/nls.metadata.header.json', '**/nls.metadata.json']))
.pipe(gulp.dest('out'));

gulp.task('translations-generate', gulp.series(generateSrcLocBundle, generateAdditionalLocFiles));

// ****************************
// Command: translations-export
// The following is used to export and XLF file containing english strings for translations.
// The result will be written to: ../vscode-extensions-localization-export/ms-vscode/
// ****************************
const exportTranslations = (done) => {
const jsStream = tsProject.src().pipe(sourcemaps.init()).pipe(tsProject()).js.pipe(nls.createMetaDataFiles());

// Merge files from all source streams
jsStream

// Filter down to only the files we need
.pipe(filter(['**/*.nls.json', '**/*.nls.metadata.json']))

// Consoldate them into nls.metadata.json, which the xlf is built from.
.pipe(nls.bundleMetaDataFiles('ms-vscode.python', '.'))

// filter down to just the resulting metadata files
.pipe(filter(['**/nls.metadata.header.json', '**/nls.metadata.json']))

// Add package.nls.json, used to localized package.json
.pipe(gulp.src(['package.nls.json']))

// package.nls.json and nls.metadata.json are used to generate the xlf file
// Does not re-queue any files to the stream. Outputs only the XLF file
.pipe(nls.createXlfFiles(translationProjectName, translationExtensionName))
.pipe(gulp.dest('../'))
.pipe(
es.wait(() => {
done();
}),
);
};

gulp.task('translations-export', exportTranslations);

// ****************************
// Command: translations-import
// The following is used to import an XLF file containing all language strings.
// This results in a i18n directory, which should be checked in.
// ****************************

// Imports translations from raw localized MLCP strings to VS Code .i18n.json files
gulp.task('translations-import', (done) => {
const options = minimist(process.argv.slice(2), {
string: 'location',
default: {
location: '../vscode-translations-import',
},
});
es.merge(
defaultLanguages.map((language) => {
const id = language.transifexId || language.id;
return gulp
.src(path.join(options.location, id, `${translationExtensionName}.xlf`))
.pipe(nls.prepareJsonFiles())
.pipe(gulp.dest(path.join('./i18n', language.folderName)));
}),
).pipe(
es.wait(() => {
done();
}),
);
});
paulacamargo25 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions news/1 Enhancements/18286.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Enable localization using vscode-nlsß
Loading