forked from angular/angular
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(ivy): i18n - add compile time translation to integration test (a…
…ngular#32881) PR Close angular#32881
- Loading branch information
1 parent
9bcdd8f
commit 9c0731c
Showing
19 changed files
with
1,839 additions
and
1,843 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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
built/ | ||
dist/ | ||
vendor/ | ||
tmp/ | ||
*/src/*.d.ts | ||
*/src/*.js | ||
!karma.conf.js | ||
|
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
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,38 @@ | ||
## E2E tests | ||
|
||
There are four different sets of e2e tests in this folder. They are all testing different | ||
translation scenarios, but they are all built with IVY enabled. | ||
|
||
### runtime | ||
|
||
Translations are provided at runtime by calling `loadTranslations()` in the polyfill.ts | ||
|
||
### de and fr | ||
|
||
The application is built (into the `dist` folder) and then two sets of translations | ||
(`src/locales/messages.(de|fr).json`) are used to generate two copies of the app, which have | ||
been translated (compile-time inlined). | ||
|
||
These translated apps are stored in `tmp/translations/(de|fr)`. | ||
|
||
### legacy | ||
|
||
The legacy `ng xi18n` tool extracts the messages from the Angular templates, into the XLIFF 1.2 | ||
format with legacy message ids (`tmp/legacy-locales/messages.legacy.xlf`). | ||
|
||
The translation file is modified to apply a simple translation. | ||
|
||
The app must be compiled using the `i18nLegacyMessageIdFormat` option set to ensure that the correct | ||
message ids are used to match those in the translation files. | ||
|
||
The app is translated using the compile-time inlining tool to generate a copy that has the | ||
translated message in it. | ||
|
||
## Hosting | ||
|
||
Since the CLI hosts from and in-memory file-system the compile-time inliner is not able to | ||
translate the output files. So the `de`, `fr` and `legacy` apps must be statically built to | ||
disk and translated there. | ||
|
||
Since the translated app is now on disk, we cannot use the CLI to serve it. Instead we use | ||
a simple static HTTP server instead. |
File renamed without changes.
17 changes: 17 additions & 0 deletions
17
integration/cli-hello-world-ivy-i18n/e2e/de/app.e2e-spec.ts
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,17 @@ | ||
import {AppPage} from '../app.po'; | ||
|
||
describe('cli-hello-world-ivy App', () => { | ||
let page: AppPage; | ||
beforeEach(() => { | ||
page = new AppPage(); | ||
page.navigateTo(); | ||
}); | ||
|
||
it('should display title', () => { | ||
expect(page.getHeading()).toEqual('Guten Tag, cli-hello-world-ivy-compat! (inline)'); | ||
}); | ||
|
||
it('should display welcome message', () => { | ||
expect(page.getParagraph('message')).toEqual('Willkommen in der i18n App. (inline)'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
integration/cli-hello-world-ivy-i18n/e2e/de/protractor.conf.js
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 @@ | ||
const {config} = require('../protractor.conf'); | ||
exports.config = { | ||
...config, | ||
specs: ['./app.e2e-spec.ts'], | ||
}; |
16 changes: 16 additions & 0 deletions
16
integration/cli-hello-world-ivy-i18n/e2e/fr/app.e2e-spec.ts
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,16 @@ | ||
import {AppPage} from '../app.po'; | ||
|
||
describe('cli-hello-world-ivy App', () => { | ||
let page: AppPage; | ||
beforeEach(() => { | ||
page = new AppPage(); | ||
page.navigateTo(); | ||
}); | ||
|
||
it('should display title', | ||
() => { expect(page.getHeading()).toEqual('Bonjour, cli-hello-world-ivy-compat! (inline)'); }); | ||
|
||
it('should display welcome message', () => { | ||
expect(page.getParagraph('message')).toEqual('Bienvenue sur l\'application i18n. (inline)'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
integration/cli-hello-world-ivy-i18n/e2e/fr/protractor.conf.js
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 @@ | ||
const {config} = require('../protractor.conf'); | ||
exports.config = { | ||
...config, | ||
specs: ['./app.e2e-spec.ts'], | ||
}; |
18 changes: 18 additions & 0 deletions
18
integration/cli-hello-world-ivy-i18n/e2e/legacy/app.e2e-spec.ts
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,18 @@ | ||
import {AppPage} from '../app.po'; | ||
|
||
describe('cli-hello-world-ivy App', () => { | ||
let page: AppPage; | ||
beforeEach(() => { | ||
page = new AppPage(); | ||
page.navigateTo(); | ||
}); | ||
|
||
it('should display translated title', | ||
() => { expect(page.getHeading()).toEqual('Bonjour cli-hello-world-ivy-compat!'); }); | ||
|
||
it('should display untranslated welcome message', () => { | ||
// This message does not get translated because we did not provide a translation for it | ||
// See "translated:legacy:extract-and-update" in package.json. | ||
expect(page.getParagraph('message')).toEqual('Welcome to the i18n app.'); | ||
}); | ||
}); |
5 changes: 5 additions & 0 deletions
5
integration/cli-hello-world-ivy-i18n/e2e/legacy/protractor.conf.js
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 @@ | ||
const {config} = require('../protractor.conf'); | ||
exports.config = { | ||
...config, | ||
specs: ['./app.e2e-spec.ts'], | ||
}; |
2 changes: 1 addition & 1 deletion
2
...lo-world-ivy-i18n/e2e/src/app.e2e-spec.ts → ...orld-ivy-i18n/e2e/runtime/app.e2e-spec.ts
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
5 changes: 5 additions & 0 deletions
5
integration/cli-hello-world-ivy-i18n/e2e/runtime/protractor.conf.js
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 @@ | ||
const {config} = require('../protractor.conf'); | ||
exports.config = { | ||
...config, | ||
specs: ['./app.e2e-spec.ts'], | ||
}; |
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
7 changes: 7 additions & 0 deletions
7
integration/cli-hello-world-ivy-i18n/src/locales/messages.de.json
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,7 @@ | ||
{ | ||
"locale": "de", | ||
"translations": { | ||
"1638894134994447485": " Guten Tag, {$INTERPOLATION}! (inline)", | ||
"6762263703087737643": "Willkommen in der i18n App. (inline)" | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
integration/cli-hello-world-ivy-i18n/src/locales/messages.fr.json
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,7 @@ | ||
{ | ||
"locale": "fr", | ||
"translations": { | ||
"1638894134994447485": " Bonjour, {$INTERPOLATION}! (inline)", | ||
"6762263703087737643": "Bienvenue sur l'application i18n. (inline)" | ||
} | ||
} |
104 changes: 0 additions & 104 deletions
104
integration/cli-hello-world-ivy-i18n/src/polyfills.legacy-id-mode.ts
This file was deleted.
Oops, something went wrong.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
integration/cli-hello-world-ivy-i18n/src/tsconfig.view-engine.json
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,6 @@ | ||
{ | ||
"extends": "./tsconfig.app.json", | ||
"angularCompilerOptions": { | ||
"enableIvy": false | ||
} | ||
} |
Oops, something went wrong.