@@ -31,9 +31,10 @@ export default async function() {
3131
3232 // Set configurations for each locale.
3333 const langTranslations = [
34- { lang : 'en-US' , translation : 'Hello i18n!' } ,
34+ // TODO: re-enable all locales once localeData support is added.
35+ // { lang: 'en-US', translation: 'Hello i18n!' },
36+ // { lang: 'de', translation: 'Hallo i18n!' },
3537 { lang : 'fr' , translation : 'Bonjour i18n!' } ,
36- { lang : 'de' , translation : 'Hallo i18n!' } ,
3738 ] ;
3839
3940 await updateJsonFile ( 'angular.json' , workspaceJson => {
@@ -54,7 +55,11 @@ export default async function() {
5455 ] ;
5556
5657 // Enable localization for all locales
57- appArchitect [ 'build' ] . options . localize = true ;
58+ // TODO: re-enable all locales once localeData support is added.
59+ // appArchitect['build'].options.localize = true;
60+ appArchitect [ 'build' ] . options . localize = [ 'fr' ] ;
61+ // Always error on missing translations.
62+ appArchitect [ 'build' ] . options . i18nMissingTranslation = 'error' ;
5863
5964 // Add locale definitions to the project
6065 // tslint:disable-next-line: no-any
@@ -102,7 +107,7 @@ export default async function() {
102107 }
103108
104109 // Build each locale and verify the output.
105- await ng ( 'build' , '--i18n-missing-translation' , 'error' ) ;
110+ await ng ( 'build' ) ;
106111 for ( const { lang, translation } of langTranslations ) {
107112 await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , translation ) ;
108113 await expectToFail ( ( ) => expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , '$localize`' ) ) ;
@@ -142,9 +147,13 @@ export default async function() {
142147 }
143148 }
144149
150+ // Verify locale data registration (currently only for single locale builds)
151+ await ng ( 'build' , '--optimization' , 'false' , '--i18n-missing-translation' , 'error' ) ;
152+ await expectFileToMatch ( `${ baseDir } /fr/main.js` , 'registerLocaleData' ) ;
153+
145154 // Verify missing translation behaviour.
146155 await appendToFile ( 'src/app/app.component.html' , '<p i18n>Other content</p>' ) ;
147156 await ng ( 'build' , '--i18n-missing-translation' , 'ignore' ) ;
148157 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' ) ) ;
158+ await expectToFail ( ( ) => ng ( 'build' ) ) ;
150159}
0 commit comments