@@ -55,6 +55,8 @@ export default async function() {
55
55
56
56
// Enable localization for all locales
57
57
appArchitect [ 'build' ] . options . localize = true ;
58
+ // Always error on missing translations.
59
+ appArchitect [ 'build' ] . options . i18nMissingTranslation = 'error' ;
58
60
59
61
// Add locale definitions to the project
60
62
// tslint:disable-next-line: no-any
@@ -102,9 +104,15 @@ export default async function() {
102
104
}
103
105
104
106
// Build each locale and verify the output.
105
- await ng ( 'build' , '--i18n-missing-translation' , 'error' ) ;
107
+ // NOTE: this should not fail in general, but multi-locale translation is currently disabled.
108
+ // TODO: remove expectToFail when functionality is re-enabled.
109
+ await expectToFail ( ( ) => ng ( 'build' ) ) ;
106
110
for ( const { lang, translation } of langTranslations ) {
111
+ // NOTE: remove this extra single build once the above expectToFail is removed.
112
+ await ng ( 'build' , '-c' , lang ) ;
113
+
107
114
await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , translation ) ;
115
+ await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , 'registerLocaleData' ) ;
108
116
await expectToFail ( ( ) => expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , '$localize`' ) ) ;
109
117
await expectFileNotToExist ( `${ baseDir } /${ lang } /main-es2015.js` ) ;
110
118
await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , lang ) ;
@@ -142,9 +150,13 @@ export default async function() {
142
150
}
143
151
}
144
152
153
+ // Verify locale data registration (currently only for single locale builds)
154
+ await ng ( 'build' , '--optimization' , 'false' , '-c' , 'fr' , '--i18n-missing-translation' , 'error' ) ;
155
+ await expectFileToMatch ( `${ baseDir } /fr/main.js` , 'registerLocaleData' ) ;
156
+
145
157
// Verify missing translation behaviour.
146
158
await appendToFile ( 'src/app/app.component.html' , '<p i18n>Other content</p>' ) ;
147
159
await ng ( 'build' , '--i18n-missing-translation' , 'ignore' ) ;
148
160
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' ) ) ;
161
+ await expectToFail ( ( ) => ng ( 'build' ) ) ;
150
162
}
0 commit comments