@@ -12,7 +12,7 @@ import fs from 'fs';
12
12
import module from 'module' ;
13
13
import os from 'os' ;
14
14
import path from 'path' ;
15
- import { Schema as BrowserBuilderSchema } from '../builders/browser/schema' ;
15
+ import { Schema as BrowserBuilderSchema , I18NTranslation } from '../builders/browser/schema' ;
16
16
import { Schema as ServerBuilderSchema } from '../builders/server/schema' ;
17
17
import { readTsconfig } from '../utils/read-tsconfig' ;
18
18
import { TranslationLoader , createTranslationLoader } from './load-translations' ;
@@ -233,6 +233,7 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
233
233
} ,
234
234
} ,
235
235
usedFormats ,
236
+ buildOptions . i18nDuplicateTranslation ,
236
237
) ;
237
238
238
239
if ( usedFormats . size > 1 && tsConfig . options . enableI18nLegacyMessageIdFormat !== false ) {
@@ -282,6 +283,7 @@ export function loadTranslations(
282
283
loader : TranslationLoader ,
283
284
logger : { warn : ( message : string ) => void ; error : ( message : string ) => void } ,
284
285
usedFormats ?: Set < string > ,
286
+ duplicateTranslation ?: I18NTranslation ,
285
287
) {
286
288
for ( const file of desc . files ) {
287
289
const loadResult = loader ( path . join ( workspaceRoot , file . path ) ) ;
@@ -308,9 +310,18 @@ export function loadTranslations(
308
310
// Merge translations
309
311
for ( const [ id , message ] of Object . entries ( loadResult . translations ) ) {
310
312
if ( desc . translation [ id ] !== undefined ) {
311
- logger . warn (
312
- `WARNING [${ file . path } ]: Duplicate translations for message '${ id } ' when merging` ,
313
- ) ;
313
+ const duplicateTranslationMessage = `[${ file . path } ]: Duplicate translations for message '${ id } ' when merging.` ;
314
+ switch ( duplicateTranslation ) {
315
+ case I18NTranslation . Ignore :
316
+ break ;
317
+ case I18NTranslation . Error :
318
+ logger . error ( `ERROR ${ duplicateTranslationMessage } ` ) ;
319
+ break ;
320
+ case I18NTranslation . Warning :
321
+ default :
322
+ logger . warn ( `WARNING ${ duplicateTranslationMessage } ` ) ;
323
+ break ;
324
+ }
314
325
}
315
326
desc . translation [ id ] = message ;
316
327
}
0 commit comments