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 810dcbd commit 078c880
Showing 1 changed file with 4 additions and 38 deletions.
42 changes: 4 additions & 38 deletions lib/package/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,12 @@ ${ res.data }
}
}

// XXX
async #resolveConflict ( poFile, message, translatedMessage ) {

// plural form
if ( message.pluralId ) {
if ( JSON.stringify( message.translations ) === JSON.stringify( translatedMessage.translations ) ) return;
// translations not changed
if ( JSON.stringify( message.translations ) === JSON.stringify( translatedMessage.translations ) ) return;

console.log( `Translation memory conflict found:
console.log( `Translation memory conflict found:
[en] message:
${ message.id }
Expand All @@ -284,46 +282,14 @@ ${ JSON.stringify( translatedMessage.translations, null, 4 ) }
[${ poFile.language }]: new translations:
${ JSON.stringify( message.translations, null, 4 ) }
` );
}

// singular form
else {
if ( message.singularTranslation === translatedMessage.translations[ message.singularIndex ] ) return;

console.log( `Translation memory conflict found:
[en] message:
${ message.id }
[${ poFile.language }]: old translations:
${ translatedMessage.translations[ message.singularIndex ] }
[${ poFile.language }]: new translations:
${ message.singularTranslation }
` );
}

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 singular form
if ( !message.pluralId ) {
translatedMessage.translations[ message.singularIndex ] = message.singularTranslation;
}

// merge plural foel
else {
translatedMessage.translations = message.translations;
}

this.#storeMessage( poFile.language, {
"id": translatedMessage.msgid,
"translations": translatedMessage.translations,
} );
this.#storeMessage( poFile.language, message );
}
else {
message.setTranslations( translatedMessage.translations );
Expand Down

0 comments on commit 078c880

Please sign in to comment.