diff --git a/lib/package/localization.js b/lib/package/localization.js index 4d1996f8..45313b66 100644 --- a/lib/package/localization.js +++ b/lib/package/localization.js @@ -260,17 +260,13 @@ ${ res.data } } } - // XXX async #resolveConflict ( poFile, message, translatedMessage ) { + + // plural form if ( message.pluralId ) { if ( JSON.stringify( message.translations ) === JSON.stringify( translatedMessage.translations ) ) return; - } - else { - if ( message.singleFormTranslation === translatedMessage.translations[ message.singleFormIndex ] ) return; - } - // XXX - console.log( `Translation memory conflict found: + console.log( `Translation memory conflict found: [en] message: ${ message.id } @@ -284,6 +280,24 @@ ${ JSON.stringify( translatedMessage.translations, null, 4 ) } [${ poFile.language }]: new translations: ${ JSON.stringify( message.translations, null, 4 ) } ` ); + } + + // single form + else { + if ( message.singleFormTranslation === translatedMessage.translations[ message.singleFormIndex ] ) return; + + console.log( `Translation memory conflict found: + +[en] message: +${ message.id } + +[${ poFile.language }]: old translations: +${ translatedMessage.translations[ message.singleFormIndex ] } + +[${ poFile.language }]: new translations: +${ message.singleFormTranslation } +` ); + } const answer = await utils.confirm( "What translations do you want to use?", [ "exit", "new", "old" ] ); @@ -291,9 +305,13 @@ ${ JSON.stringify( message.translations, null, 4 ) } process.exit( 1 ); } else if ( answer === "new" ) { + + // merge single form if ( !message.pluralId ) { translatedMessage.translations[ message.singleFormIndex ] = message.singleFormTranslation; } + + // merge plural foel else { translatedMessage.translations = message.translations; }