Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions aio/content/examples/i18n/stackblitz.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"description": "i18n",
"files":[
"!**/*.d.ts",
"!**/*.js",
"!**/*.[0-9].*"
],
"file": "src/app/app.component.ts",
"tags": ["Angular", "i18n", "internationalization"]
}
984 changes: 557 additions & 427 deletions aio/content/guide/i18n.md

Large diffs are not rendered by default.

101 changes: 61 additions & 40 deletions aio/tools/examples/run-example-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ const DEFAULT_CLI_EXAMPLE_PORT = 4200;
const DEFAULT_CLI_SPECS_CONCURRENCY = 1;
const IGNORED_EXAMPLES = [];

const fixmeIvyExamples = [
// fixmeIvy('unknown') app fails at runtime due to missing external service (goog is undefined)
'i18n',
];
const fixmeIvyExamples = [];

if (!argv.viewengine) {
IGNORED_EXAMPLES.push(...fixmeIvyExamples);
Expand Down Expand Up @@ -72,8 +69,10 @@ function runE2e() {
const outputFile = path.join(AIO_PATH, './protractor-results.txt');

return Promise.resolve()
.then(() => findAndRunE2eTests(argv.filter, outputFile, argv.shard,
argv.cliSpecsConcurrency || DEFAULT_CLI_SPECS_CONCURRENCY, argv.retry || 1))
.then(
() => findAndRunE2eTests(
argv.filter, outputFile, argv.shard,
argv.cliSpecsConcurrency || DEFAULT_CLI_SPECS_CONCURRENCY, argv.retry || 1))
.then((status) => {
reportStatus(status, outputFile);
if (status.failed.length > 0) {
Expand Down Expand Up @@ -226,8 +225,12 @@ function runProtractorSystemJS(prepPromise, appDir, appRunSpawnInfo, outputFile)
});
})
.then(
function() { return finish(appRunSpawnInfo.proc.pid, true); },
function() { return finish(appRunSpawnInfo.proc.pid, false); });
function() {
return finish(appRunSpawnInfo.proc.pid, true);
},
function() {
return finish(appRunSpawnInfo.proc.pid, false);
});
}

function finish(spawnProcId, ok) {
Expand Down Expand Up @@ -263,15 +266,15 @@ function runE2eTestsCLI(appDir, outputFile, bufferOutput, port) {
// `--no-webdriver-update` is needed to preserve the ChromeDriver version already installed.
const config = loadExampleConfig(appDir);
const testCommands = config.tests || [{
cmd: 'yarn',
args: [
'e2e',
'--prod',
'--protractor-config=e2e/protractor-puppeteer.conf.js',
'--no-webdriver-update',
'--port={PORT}',
],
}];
cmd: 'yarn',
args: [
'e2e',
'--prod',
'--protractor-config=e2e/protractor-puppeteer.conf.js',
'--no-webdriver-update',
'--port={PORT}',
],
}];
let bufferedOutput = `\n\n============== AIO example output for: ${appDir}\n\n`;

const e2eSpawnPromise = testCommands.reduce((prevSpawnPromise, {cmd, args}) => {
Expand All @@ -281,26 +284,30 @@ function runE2eTestsCLI(appDir, outputFile, bufferOutput, port) {
args = args.map(a => a.replace('{PORT}', port || DEFAULT_CLI_EXAMPLE_PORT));

return prevSpawnPromise.then(() => {
const currSpawn = spawnExt(cmd, args, {cwd: appDir}, false,
bufferOutput ? msg => bufferedOutput += msg : undefined);
const currSpawn = spawnExt(
cmd, args, {cwd: appDir}, false, bufferOutput ? msg => bufferedOutput += msg : undefined);
return currSpawn.promise.then(
() => Promise.resolve(finish(currSpawn.proc.pid, true)),
() => Promise.reject(finish(currSpawn.proc.pid, false)));
});
}, Promise.resolve());

return e2eSpawnPromise.then(() => {
fs.appendFileSync(outputFile, `Passed: ${appDir}\n\n`);
return true;
}, () => {
fs.appendFileSync(outputFile, `Failed: ${appDir}\n\n`);
return false;
}).then(passed => {
if (bufferOutput) {
process.stdout.write(bufferedOutput);
}
return passed;
});
return e2eSpawnPromise
.then(
() => {
fs.appendFileSync(outputFile, `Passed: ${appDir}\n\n`);
return true;
},
() => {
fs.appendFileSync(outputFile, `Failed: ${appDir}\n\n`);
return false;
})
.then(passed => {
if (bufferOutput) {
process.stdout.write(bufferedOutput);
}
return passed;
});
}

// Report final status.
Expand All @@ -309,23 +316,31 @@ function reportStatus(status, outputFile) {

log.push('Suites ignored due to legacy guides:');
IGNORED_EXAMPLES.filter(example => !fixmeIvyExamples.find(ex => ex.startsWith(example)))
.forEach(function(val) { log.push(' ' + val); });
.forEach(function(val) {
log.push(' ' + val);
});

if (!argv.viewengine) {
log.push('');
log.push('Suites ignored due to breakage with Ivy:');
fixmeIvyExamples.forEach(function(val) { log.push(' ' + val); });
fixmeIvyExamples.forEach(function(val) {
log.push(' ' + val);
});
}

log.push('');
log.push('Suites passed:');
status.passed.forEach(function(val) { log.push(' ' + val); });
status.passed.forEach(function(val) {
log.push(' ' + val);
});

if (status.failed.length == 0) {
log.push('All tests passed');
} else {
log.push('Suites failed:');
status.failed.forEach(function(val) { log.push(' ' + val); });
status.failed.forEach(function(val) {
log.push(' ' + val);
});
}
log.push('\nElapsed time: ' + status.elapsedTime + ' seconds');
log = log.join('\n');
Expand All @@ -334,8 +349,8 @@ function reportStatus(status, outputFile) {
}

// Returns both a promise and the spawned process so that it can be killed if needed.
function spawnExt(command, args, options, ignoreClose = false,
printMessage = msg => process.stdout.write(msg)) {
function spawnExt(
command, args, options, ignoreClose = false, printMessage = msg => process.stdout.write(msg)) {
let proc;
const promise = new Promise((resolve, reject) => {
let descr = command + ' ' + args.join(' ');
Expand Down Expand Up @@ -370,13 +385,19 @@ function getE2eSpecs(basePath, filter) {
let specs = {};

return getE2eSpecsFor(basePath, SJS_SPEC_FILENAME, filter)
.then(sjsPaths => { specs.systemjs = sjsPaths; })
.then(sjsPaths => {
specs.systemjs = sjsPaths;
})
.then(() => {
return getE2eSpecsFor(basePath, CLI_SPEC_FILENAME, filter).then(cliPaths => {
return cliPaths.map(p => { return p.replace(`${CLI_SPEC_FILENAME}`, ''); });
return cliPaths.map(p => {
return p.replace(`${CLI_SPEC_FILENAME}`, '');
});
});
})
.then(cliPaths => { specs.cli = cliPaths; })
.then(cliPaths => {
specs.cli = cliPaths;
})
.then(() => specs);
}

Expand Down
39 changes: 11 additions & 28 deletions aio/tools/examples/shared/boilerplate/i18n/angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,18 @@
"root": "",
"sourceRoot": "src",
"prefix": "app",
"i18n": {
"sourceLocale": "en-US",
"locales": {
"fr": "src/locale/messages.fr.xlf"
}
},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"localize": true,
"aot": true,
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
Expand Down Expand Up @@ -57,35 +65,10 @@
}
]
},
"production-fr": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"outputPath": "dist/my-project-fr/",
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
},
"fr": {
"aot": true,
"outputPath": "dist/my-project-fr/",
"i18nFile": "src/locale/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error"
"localize": [
"fr"
]
}
}
},
Expand Down
1 change: 1 addition & 0 deletions aio/tools/examples/shared/boilerplate/i18n/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@angular/compiler": "~9.1.4",
"@angular/core": "~9.1.4",
"@angular/forms": "~9.1.4",
"@angular/localize": "^9.1.4",
Comment thread
petebacondarwin marked this conversation as resolved.
Resolved
"@angular/platform-browser": "~9.1.4",
"@angular/platform-browser-dynamic": "~9.1.4",
"@angular/router": "~9.1.4",
Expand Down
68 changes: 68 additions & 0 deletions aio/tools/examples/shared/boilerplate/i18n/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/***************************************************************************************************
* Load `$localize` onto the global scope - used if i18n tags appear in Angular templates.
*/
import '@angular/localize/init';
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/

/***************************************************************************************************
* BROWSER POLYFILLS
*/

/** IE10 and IE11 requires the following for NgClass support on SVG elements */
// import 'classlist.js'; // Run `npm install --save classlist.js`.

/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch
* requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch
* specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/

/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js/dist/zone'; // Included with Angular CLI.

/***************************************************************************************************
* APPLICATION IMPORTS
*/
1 change: 1 addition & 0 deletions aio/tools/examples/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@angular/core": "~9.1.4",
"@angular/elements": "~9.1.4",
"@angular/forms": "~9.1.4",
"@angular/localize": "~9.1.4",
Comment thread
petebacondarwin marked this conversation as resolved.
Resolved
"@angular/platform-browser": "~9.1.4",
"@angular/platform-browser-dynamic": "~9.1.4",
"@angular/platform-server": "~9.1.4",
Expand Down
Loading