@@ -12,7 +12,7 @@ import fs from 'fs';
1212import module from 'module' ;
1313import os from 'os' ;
1414import path from 'path' ;
15- import { Schema as BrowserBuilderSchema } from '../builders/browser/schema' ;
15+ import { Schema as BrowserBuilderSchema , I18NTranslation } from '../builders/browser/schema' ;
1616import { Schema as ServerBuilderSchema } from '../builders/server/schema' ;
1717import { readTsconfig } from '../utils/read-tsconfig' ;
1818import { TranslationLoader , createTranslationLoader } from './load-translations' ;
@@ -233,6 +233,7 @@ export async function configureI18nBuild<T extends BrowserBuilderSchema | Server
233233 } ,
234234 } ,
235235 usedFormats ,
236+ buildOptions . i18nDuplicateTranslation ,
236237 ) ;
237238
238239 if ( usedFormats . size > 1 && tsConfig . options . enableI18nLegacyMessageIdFormat !== false ) {
@@ -282,6 +283,7 @@ export function loadTranslations(
282283 loader : TranslationLoader ,
283284 logger : { warn : ( message : string ) => void ; error : ( message : string ) => void } ,
284285 usedFormats ?: Set < string > ,
286+ duplicateTranslation ?: I18NTranslation ,
285287) {
286288 for ( const file of desc . files ) {
287289 const loadResult = loader ( path . join ( workspaceRoot , file . path ) ) ;
@@ -308,9 +310,18 @@ export function loadTranslations(
308310 // Merge translations
309311 for ( const [ id , message ] of Object . entries ( loadResult . translations ) ) {
310312 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+ }
314325 }
315326 desc . translation [ id ] = message ;
316327 }
0 commit comments