@@ -41,6 +41,7 @@ export default async function() {
41
41
const appArchitect = appProject . architect || appProject . targets ;
42
42
const serveConfigs = appArchitect [ 'serve' ] . configurations ;
43
43
const e2eConfigs = appArchitect [ 'e2e' ] . configurations ;
44
+ const buildConfigs = appArchitect [ 'build' ] . configurations ;
44
45
45
46
// Make default builds prod.
46
47
appArchitect [ 'build' ] . options . optimization = true ;
@@ -55,6 +56,8 @@ export default async function() {
55
56
56
57
// Enable localization for all locales
57
58
appArchitect [ 'build' ] . options . localize = true ;
59
+ // Always error on missing translations.
60
+ appArchitect [ 'build' ] . options . i18nMissingTranslation = 'error' ;
58
61
59
62
// Add locale definitions to the project
60
63
// tslint:disable-next-line: no-any
@@ -65,6 +68,8 @@ export default async function() {
65
68
} else {
66
69
i18n . locales [ lang ] = `src/locale/messages.${ lang } .xlf` ;
67
70
}
71
+
72
+ buildConfigs [ lang ] = { localize : [ lang ] } ;
68
73
serveConfigs [ lang ] = { browserTarget : `test-project:build:${ lang } ` } ;
69
74
e2eConfigs [ lang ] = {
70
75
specs : [ `./src/app.${ lang } .e2e-spec.ts` ] ,
@@ -102,9 +107,15 @@ export default async function() {
102
107
}
103
108
104
109
// Build each locale and verify the output.
105
- await ng ( 'build' , '--i18n-missing-translation' , 'error' ) ;
110
+ // NOTE: this should not fail in general, but multi-locale translation is currently disabled.
111
+ // TODO: remove expectToFail when functionality is re-enabled.
112
+ await expectToFail ( ( ) => ng ( 'build' ) ) ;
106
113
for ( const { lang, translation } of langTranslations ) {
114
+ // NOTE: remove this extra single build once the above expectToFail is removed.
115
+ await ng ( 'build' , '-c' , lang ) ;
116
+
107
117
await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , translation ) ;
118
+ await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , 'registerLocaleData' ) ;
108
119
await expectToFail ( ( ) => expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , '$localize`' ) ) ;
109
120
await expectFileNotToExist ( `${ baseDir } /${ lang } /main-es2015.js` ) ;
110
121
await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , lang ) ;
@@ -142,9 +153,13 @@ export default async function() {
142
153
}
143
154
}
144
155
156
+ // Verify locale data registration (currently only for single locale builds)
157
+ await ng ( 'build' , '--optimization' , 'false' , '-c' , 'fr' , '--i18n-missing-translation' , 'error' ) ;
158
+ await expectFileToMatch ( `${ baseDir } /fr/main.js` , 'registerLocaleData' ) ;
159
+
145
160
// Verify missing translation behaviour.
146
161
await appendToFile ( 'src/app/app.component.html' , '<p i18n>Other content</p>' ) ;
147
- await ng ( 'build' , '--i18n-missing-translation' , 'ignore' ) ;
162
+ await ng ( 'build' , '--i18n-missing-translation' , 'ignore' , '-c' , 'fr' ) ;
148
163
await expectFileToMatch ( `${ baseDir } /fr/main.js` , / O t h e r c o n t e n t / ) ;
149
- await expectToFail ( ( ) => ng ( 'build' , '--i18n-missing-translation ' , 'error ' ) ) ;
164
+ await expectToFail ( ( ) => ng ( 'build' , '-c ' , 'fr ' ) ) ;
150
165
}
0 commit comments