test(localize): add compile time extraction to integration test (#32912)
The integration test for i18n now makes use of the new extraction tooling from the `@angular/localize` package rather than the old ViewEngine extractor. PR Close #32912
This commit is contained in:
parent
190561d8a6
commit
290bc7334d
|
@ -13,6 +13,8 @@
|
|||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"localize": false, // To prevent the CLI from doing inlining itself
|
||||
"aot": true,
|
||||
"outputPath": "dist",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
|
@ -33,7 +35,6 @@
|
|||
"tsConfig": "tsconfig.view-engine.json"
|
||||
},
|
||||
"production": {
|
||||
"localize": false, // TODO: enable when CLI supports inlining the locale
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "src/environments/environment.ts",
|
||||
|
@ -42,10 +43,9 @@
|
|||
],
|
||||
"optimization": true,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"sourceMap": true,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
"extractLicenses": true,
|
||||
"vendorChunk": false,
|
||||
"buildOptimizer": true,
|
||||
|
@ -72,9 +72,9 @@
|
|||
},
|
||||
"translated-legacy": {
|
||||
"tsConfig": "tsconfig.legacy.json",
|
||||
"optimization": true,
|
||||
"optimization": false,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"sourceMap": true,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
|
@ -84,9 +84,9 @@
|
|||
},
|
||||
"translated-legacy-xmb": {
|
||||
"tsConfig": "tsconfig.legacy-xmb.json",
|
||||
"optimization": true,
|
||||
"optimization": false,
|
||||
"outputHashing": "all",
|
||||
"sourceMap": false,
|
||||
"sourceMap": true,
|
||||
"extractCss": true,
|
||||
"namedChunks": false,
|
||||
"aot": true,
|
||||
|
@ -198,6 +198,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}},
|
||||
}
|
||||
},
|
||||
"defaultProject": "cli-hello-world-ivy-i18n"
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
"ng": "ng",
|
||||
"postinstall": "ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points",
|
||||
"start": "ng serve",
|
||||
"pretest": "ng version",
|
||||
"pretest": "ng version && rm -fr ../tmp",
|
||||
"test": "ng test && yarn e2e --configuration=ci && yarn e2e --configuration=ci-production && yarn translated:test && yarn translated:legacy-xlf:test && yarn translated:legacy-xmb:test",
|
||||
"translate": "localize-translate -r \"dist/\" -s \"**/*\" -l \"en-US\" -t \"[src/locales/messages.de.json, src/locales/extra.de.json]\" [src/locales/messages.fr.json,src/locales/extra.fr.json] -o \"../tmp/translations/{{LOCALE}}\"",
|
||||
"translate": "localize-translate --root \"dist/\" --source \"**/*\" --source-locale \"en-US\" --translations \"[src/locales/messages.de.json, src/locales/extra.de.json]\" [src/locales/messages.fr.json,src/locales/extra.fr.json] --outputPath \"../tmp/translations/{{LOCALE}}\"",
|
||||
"runtime:test": "yarn e2e --configuration=runtime-translations",
|
||||
"translated:test": "yarn build && yarn translate && yarn translated:fr:e2e && yarn translated:de:e2e && yarn translated:en:e2e",
|
||||
"translated:fr:serve": "serve ../tmp/translations/fr --listen 4200",
|
||||
|
@ -22,36 +22,37 @@
|
|||
"translated:en:e2e": "npm-run-all -p -r translated:en:serve \"ng e2e --configuration=translated-en\"",
|
||||
"translated:legacy:serve": "serve ../tmp/translations/legacy --listen 4200",
|
||||
"translated:legacy:e2e": "npm-run-all -p -r translated:legacy:serve \"ng e2e --configuration=translated-legacy\"",
|
||||
"translated:legacy:translate": "localize-translate -r \"dist/\" -s \"**/*\" -o \"../tmp/translations/{{LOCALE}}\"",
|
||||
"translated:legacy-xlf:test": "yarn ng xi18n && yarn translated:legacy-xlf:update-translations && yarn ng build --configuration=translated-legacy && yarn translated:legacy:translate -t \"../tmp/legacy-locales/messages.legacy.xlf\" && yarn translated:legacy:e2e",
|
||||
"translated:legacy-xlf:update-translations": "sed -i.bak -e 's/source>/target>'/ -e 's/Hello/Bonjour/' -e 's/source-language=\"en-US\"/source-language=\"en-US\" target-language=\"legacy\"/' ../tmp/legacy-locales/messages.legacy.xlf",
|
||||
"translated:legacy-xmb:test": "yarn ng xi18n --format=xmb --outFile=messages.legacy.xmb && yarn translated:legacy-xmb:update-translations && yarn ng build --configuration=translated-legacy-xmb && yarn translated:legacy:translate -t \"../tmp/legacy-locales/messages.legacy.xtb\" && yarn translated:legacy:e2e",
|
||||
"translated:legacy-xmb:update-translations": "sed -e 's/messagebundle/translationbundle/' -e 's/<translationbundle>/<translationbundle lang=\"legacy\">/' -e 's/msg/translation/' -e 's/Hello/Bonjour/' -e 's/<source>.*<\\/source>//' ../tmp/legacy-locales/messages.legacy.xmb > ../tmp/legacy-locales/messages.legacy.xtb"
|
||||
"translated:legacy:translate": "localize-translate --root \"dist/\" --source \"**/*\" --outputPath \"../tmp/translations/{{LOCALE}}\"",
|
||||
"translated:legacy-xlf:test": "yarn ng build && yarn extract --format xliff --outputPath ../tmp/legacy-locales/messages.legacy.xlf && yarn translated:legacy-xlf:update-translations && yarn ng build --configuration=translated-legacy && yarn translated:legacy:translate -t \"../tmp/legacy-locales/messages.legacy.xlf\" && yarn translated:legacy:e2e",
|
||||
"translated:legacy-xlf:update-translations": "node scripts/update-xlf-translation-file.js \"../tmp/legacy-locales/messages.legacy.xlf\"",
|
||||
"translated:legacy-xmb:test": "yarn ng build && yarn extract --format xmb --outputPath ../tmp/legacy-locales/messages.legacy.xmb && yarn translated:legacy-xmb:update-translations && yarn ng build --configuration=translated-legacy-xmb && yarn translated:legacy:translate -t \"../tmp/legacy-locales/messages.legacy.xtb\" && yarn translated:legacy:e2e",
|
||||
"translated:legacy-xmb:update-translations": "node scripts/update-xmb-translation-file.js \"../tmp/legacy-locales/messages.legacy.xmb\"",
|
||||
"extract": "localize-extract --source dist/main-es2015*.js"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "file:../../dist/packages-dist/animations",
|
||||
"@angular/common": "file:../../dist/packages-dist/common",
|
||||
"@angular/compiler": "file:../../dist/packages-dist/compiler",
|
||||
"@angular/core": "file:../../dist/packages-dist/core",
|
||||
"@angular/forms": "file:../../dist/packages-dist/forms",
|
||||
"@angular/localize": "file:../../dist/packages-dist/localize",
|
||||
"@angular/platform-browser": "file:../../dist/packages-dist/platform-browser",
|
||||
"@angular/platform-browser-dynamic": "file:../../dist/packages-dist/platform-browser-dynamic",
|
||||
"@angular/router": "file:../../dist/packages-dist/router",
|
||||
"core-js": "file:../../node_modules/core-js",
|
||||
"rxjs": "file:../../node_modules/rxjs",
|
||||
"tslib": "file:../../node_modules/tslib",
|
||||
"zone.js": "file:../../dist/zone.js-dist/zone.js"
|
||||
"@angular/animations": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/animations/npm_package_archive.tar.gz",
|
||||
"@angular/common": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/common/npm_package_archive.tar.gz",
|
||||
"@angular/compiler": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/compiler/npm_package_archive.tar.gz",
|
||||
"@angular/core": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/core/npm_package_archive.tar.gz",
|
||||
"@angular/forms": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/forms/npm_package_archive.tar.gz",
|
||||
"@angular/localize": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/localize/npm_package_archive.tar.gz",
|
||||
"@angular/platform-browser": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/platform-browser/npm_package_archive.tar.gz",
|
||||
"@angular/platform-browser-dynamic": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/platform-browser-dynamic/npm_package_archive.tar.gz",
|
||||
"@angular/router": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/router/npm_package_archive.tar.gz",
|
||||
"core-js": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/core-js_archive.tar.gz",
|
||||
"rxjs": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/rxjs_archive.tar.gz",
|
||||
"tslib": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/tslib_archive.tar.gz",
|
||||
"zone.js": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/zone.js/npm_package_archive.tar.gz"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "file:../../node_modules/@angular-devkit/build-angular",
|
||||
"@angular/cli": "file:../../node_modules/@angular/cli",
|
||||
"@angular/compiler-cli": "file:../../dist/packages-dist/compiler-cli",
|
||||
"@angular/language-service": "file:../../dist/packages-dist/language-service",
|
||||
"@types/jasmine": "file:../../node_modules/@types/jasmine",
|
||||
"@types/jasminewd2": "file:../../node_modules/@types/jasminewd2",
|
||||
"@types/node": "file:../../node_modules/@types/node",
|
||||
"@angular-devkit/build-angular": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/angular-devkit_build-angular_archive.tar.gz",
|
||||
"@angular/cli": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/angular_cli_archive.tar.gz",
|
||||
"@angular/compiler-cli": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/compiler-cli/npm_package_archive.tar.gz",
|
||||
"@angular/language-service": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/angular/packages/language-service/npm_package_archive.tar.gz",
|
||||
"@types/jasmine": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/types_jasmine_archive.tar.gz",
|
||||
"@types/jasminewd2": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/types_jasminewd2_archive.tar.gz",
|
||||
"@types/node": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/types_node_archive.tar.gz",
|
||||
"codelyzer": "5.2.0",
|
||||
"jasmine-core": "3.5.0",
|
||||
"jasmine-spec-reporter": "4.2.1",
|
||||
|
@ -61,15 +62,15 @@
|
|||
"karma-jasmine": "2.0.1",
|
||||
"karma-jasmine-html-reporter": "1.4.2",
|
||||
"npm-run-all": "4.1.5",
|
||||
"protractor": "file:../../node_modules/protractor",
|
||||
"puppeteer": "file:../../node_modules/puppeteer",
|
||||
"protractor": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/protractor_archive.tar.gz",
|
||||
"puppeteer": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/puppeteer_archive.tar.gz",
|
||||
"serve": "11.2.0",
|
||||
"ts-node": "8.3.0",
|
||||
"tslint": "5.18.0",
|
||||
"typescript": "file:../../node_modules/typescript"
|
||||
"typescript": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/typescript_archive.tar.gz"
|
||||
},
|
||||
"//resolutions-comment": "Ensure a single version of webdriver-manager which comes from root node_modules that has already run webdriver-manager update",
|
||||
"resolutions": {
|
||||
"**/webdriver-manager": "file:../../node_modules/webdriver-manager"
|
||||
"**/webdriver-manager": "file:/private/var/tmp/_bazel_pete/f9acfb7f019473a10a34c8c30adc55ea/execroot/angular/bazel-out/darwin-fastbuild/bin/integration/ivy-i18n_test.debug.sh.runfiles/npm/webdriver-manager_archive.tar.gz"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/**
|
||||
* This file simulates translating a generated translation file into a new locale.
|
||||
* In particular it takes an English locale XLIFF 1.2 format and translates to the French locale.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Load the file
|
||||
const filePath = path.resolve(__dirname, '..', process.argv.pop());
|
||||
const contents = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// Backup the file
|
||||
fs.writeFileSync(filePath + '.bak', contents, 'utf8');
|
||||
|
||||
// Write translated file
|
||||
const updated =
|
||||
contents.replace(/source>/g, 'target>')
|
||||
.replace(/Hello/g, 'Bonjour')
|
||||
.replace(/source-language="([^"]+)"/g, 'source-language="$1" target-language="legacy"');
|
||||
fs.writeFileSync(filePath, updated, 'utf8');
|
|
@ -0,0 +1,19 @@
|
|||
/**
|
||||
* This file simulates translating a generated translation file into a new locale.
|
||||
* In particular it takes an English locale XMB format and translates to a French locale XTB format.
|
||||
*/
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
// Load the file
|
||||
const filePath = path.resolve(__dirname, '..', process.argv.pop());
|
||||
const contents = fs.readFileSync(filePath, 'utf8');
|
||||
|
||||
// Write translated file
|
||||
const updatedFilePath = filePath.replace(/\.xmb$/, '.xtb');
|
||||
const updatedContents = contents.replace(/messagebundle/g, 'translationbundle>')
|
||||
.replace(/<translationbundle>/g, '<translationbundle lang="legacy">')
|
||||
.replace(/\bmsg\b/g, 'translation')
|
||||
.replace(/Hello/g, 'Bonjour')
|
||||
.replace(/<source>.*<\/source>/g, '');
|
||||
fs.writeFileSync(updatedFilePath, updatedContents, 'utf8');
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue