@@ -25,7 +25,7 @@ export const langTranslations = [
25
25
translation : {
26
26
helloPartial : 'Bonjour' ,
27
27
hello : 'Bonjour i18n!' ,
28
- plural : 'Mis à jour Il y a 3 minutes' ,
28
+ plural : 'Mis à jour il y a 3 minutes' ,
29
29
date : 'janvier' ,
30
30
} ,
31
31
translationReplacements : [
@@ -34,7 +34,7 @@ export const langTranslations = [
34
34
[ 'Updated' , 'Mis à jour' ] ,
35
35
[ 'just now' , 'juste maintenant' ] ,
36
36
[ 'one minute ago' , 'il y a une minute' ] ,
37
- [ ' other {' , 'other {Il y a' ] ,
37
+ [ / o t h e r { / g , 'other {il y a ' ] ,
38
38
[ 'minutes ago' , 'minutes' ] ,
39
39
] ,
40
40
} ,
@@ -52,7 +52,7 @@ export const langTranslations = [
52
52
[ 'Updated' , 'Aktualisiert' ] ,
53
53
[ 'just now' , 'gerade jetzt' ] ,
54
54
[ 'one minute ago' , 'vor einer Minute' ] ,
55
- [ ' other {' , 'other {vor' ] ,
55
+ [ / o t h e r { / g , 'other {vor ' ] ,
56
56
[ 'minutes ago' , 'Minuten' ] ,
57
57
] ,
58
58
} ,
@@ -91,12 +91,12 @@ export async function setupI18nConfig(useLocalize = true) {
91
91
92
92
// Add e2e specs for each lang.
93
93
for ( const { lang, translation } of langTranslations ) {
94
- await writeFile ( `./src/app.${ lang } .e2e-spec.ts` , `
94
+ await writeFile ( `./e2e/ src/app.${ lang } .e2e-spec.ts` , `
95
95
import { browser, logging, element, by } from 'protractor';
96
96
97
97
describe('workspace-project App', () => {
98
98
const getParagraph = (name: string) => element(by.css('app-root p#' + name)).getText();
99
- beforeEach(() => browser.get(browser.baseUrl); );
99
+ beforeEach(() => browser.get(browser.baseUrl));
100
100
afterEach(async () => {
101
101
// Assert that there are no errors emitted from the browser
102
102
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
@@ -112,7 +112,7 @@ export async function setupI18nConfig(useLocalize = true) {
112
112
expect(getParagraph('locale')).toEqual('${ lang } '));
113
113
114
114
it('should display localized date', () =>
115
- expect(getParagraph('date')).toEqual('${ translation . plural } '));
115
+ expect(getParagraph('date')).toEqual('${ translation . date } '));
116
116
117
117
it('should display pluralized message', () =>
118
118
expect(getParagraph('plural')).toEqual('${ translation . plural } '));
@@ -190,13 +190,13 @@ export async function setupI18nConfig(useLocalize = true) {
190
190
if ( lang != sourceLocale ) {
191
191
await copyFile ( 'src/locale/messages.xlf' , `src/locale/messages.${ lang } .xlf` ) ;
192
192
for ( const replacements of translationReplacements ) {
193
- await replaceInFile ( `src/locale/messages.${ lang } .xlf` , replacements [ 0 ] , replacements [ 1 ] ) ;
193
+ await replaceInFile ( `src/locale/messages.${ lang } .xlf` , replacements [ 0 ] , replacements [ 1 ] as string ) ;
194
194
}
195
195
}
196
196
}
197
197
198
- if ( useLocalize ) {
199
- // Install the localize package.
198
+ // Install the localize package if using ivy
199
+ if ( ! getGlobalVariable ( 'argv' ) [ 've' ] ) {
200
200
let localizeVersion = '@angular/localize@' + readNgVersion ( ) ;
201
201
if ( getGlobalVariable ( 'argv' ) [ 'ng-snapshots' ] ) {
202
202
localizeVersion = require ( '../../ng-snapshot/package.json' ) . dependencies [ '@angular/localize' ] ;
@@ -209,6 +209,13 @@ export default async function () {
209
209
// Setup i18n tests and config.
210
210
await setupI18nConfig ( false ) ;
211
211
212
+ // Legacy option usage with the en-US locale needs $localize when using ivy
213
+ // Legacy usage did not need to process en-US and typically no i18nLocale options were present
214
+ // This will currently be the overwhelmingly common scenario for users updating existing projects
215
+ if ( ! getGlobalVariable ( 'argv' ) [ 've' ] ) {
216
+ await appendToFile ( 'src/polyfills.ts' , `import '@angular/localize/init';` ) ;
217
+ }
218
+
212
219
// Build each locale and verify the output.
213
220
for ( const { lang, translation, outputPath } of langTranslations ) {
214
221
await ng ( 'build' , `--configuration=${ lang } ` ) ;
0 commit comments