@@ -31,9 +31,10 @@ export default async function() {
31
31
32
32
// Set configurations for each locale.
33
33
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!' },
35
37
{ lang : 'fr' , translation : 'Bonjour i18n!' } ,
36
- { lang : 'de' , translation : 'Hallo i18n!' } ,
37
38
] ;
38
39
39
40
await updateJsonFile ( 'angular.json' , workspaceJson => {
@@ -54,7 +55,11 @@ export default async function() {
54
55
] ;
55
56
56
57
// 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' ;
58
63
59
64
// Add locale definitions to the project
60
65
// tslint:disable-next-line: no-any
@@ -102,7 +107,7 @@ 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
+ await ng ( 'build' ) ;
106
111
for ( const { lang, translation } of langTranslations ) {
107
112
await expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , translation ) ;
108
113
await expectToFail ( ( ) => expectFileToMatch ( `${ baseDir } /${ lang } /main.js` , '$localize`' ) ) ;
@@ -142,9 +147,13 @@ export default async function() {
142
147
}
143
148
}
144
149
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
+
145
154
// Verify missing translation behaviour.
146
155
await appendToFile ( 'src/app/app.component.html' , '<p i18n>Other content</p>' ) ;
147
156
await ng ( 'build' , '--i18n-missing-translation' , 'ignore' ) ;
148
157
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' ) ) ;
150
159
}
0 commit comments