Skip to content

Commit

Permalink
fix: translations
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 17, 2024
1 parent 45e4b36 commit d608940
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions lib/package/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -284,16 +280,38 @@ ${ 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" ] );

if ( answer === "exit" ) {
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;
}
Expand Down

0 comments on commit d608940

Please sign in to comment.