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:
Pete Bacon Darwin
2019-11-18 10:51:18 +00:00
committed by Andrew Kushnir
parent 190561d8a6
commit 290bc7334d
5 changed files with 2550 additions and 1585 deletions

View File

@ -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');

View File

@ -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');