@@ -68,6 +68,32 @@ async function getSerializer(format: Format, sourceLocale: string, basePath: str
68
68
}
69
69
}
70
70
71
+ function normalizeFormatOption ( options : ExtractI18nBuilderOptions ) {
72
+ let format ;
73
+ if ( options . i18nFormat !== Format . Xlf ) {
74
+ format = options . i18nFormat ;
75
+ } else {
76
+ format = options . format ;
77
+ }
78
+
79
+ switch ( format ) {
80
+ case Format . Xlf :
81
+ case Format . Xlif :
82
+ case Format . Xliff :
83
+ format = Format . Xlf ;
84
+ break ;
85
+ case Format . Xlf2 :
86
+ case Format . Xliff2 :
87
+ format = Format . Xlf2 ;
88
+ break ;
89
+ case undefined :
90
+ format = Format . Xlf ;
91
+ break ;
92
+ }
93
+
94
+ return format ;
95
+ }
96
+
71
97
class NoEmitPlugin {
72
98
apply ( compiler : webpack . Compiler ) : void {
73
99
compiler . hooks . shouldEmit . tap ( 'angular-no-emit' , ( ) => false ) ;
@@ -90,24 +116,7 @@ export async function execute(
90
116
await context . getBuilderNameForTarget ( browserTarget ) ,
91
117
) ;
92
118
93
- if ( options . i18nFormat !== Format . Xlf ) {
94
- options . format = options . i18nFormat ;
95
- }
96
-
97
- switch ( options . format ) {
98
- case Format . Xlf :
99
- case Format . Xlif :
100
- case Format . Xliff :
101
- options . format = Format . Xlf ;
102
- break ;
103
- case Format . Xlf2 :
104
- case Format . Xliff2 :
105
- options . format = Format . Xlf2 ;
106
- break ;
107
- case undefined :
108
- options . format = Format . Xlf ;
109
- break ;
110
- }
119
+ const format = normalizeFormatOption ( options ) ;
111
120
112
121
// We need to determine the outFile name so that AngularCompiler can retrieve it.
113
122
let outFile = options . outFile || getI18nOutfile ( options . format ) ;
@@ -142,7 +151,7 @@ export async function execute(
142
151
} ,
143
152
buildOptimizer : false ,
144
153
i18nLocale : options . i18nLocale || i18n . sourceLocale ,
145
- i18nFormat : options . format ,
154
+ i18nFormat : format ,
146
155
i18nFile : outFile ,
147
156
aot : true ,
148
157
progress : options . progress ,
@@ -245,7 +254,7 @@ export async function execute(
245
254
246
255
// Serialize all extracted messages
247
256
const serializer = await getSerializer (
248
- options . format ,
257
+ format ,
249
258
i18n . sourceLocale ,
250
259
config . context || projectRoot ,
251
260
useLegacyIds ,
0 commit comments