From a585f69af6a498009eca0c8b405b78d9c4b6ef65 Mon Sep 17 00:00:00 2001 From: zdm Date: Wed, 14 Feb 2024 11:31:56 +0200 Subject: [PATCH] fix: tramslations --- lib/package/localization.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/package/localization.js b/lib/package/localization.js index 3300a690..69b5ccee 100644 --- a/lib/package/localization.js +++ b/lib/package/localization.js @@ -268,7 +268,7 @@ export default class { } // XXX - if ( message.pluralId && translatedMessage.pluralId && message.pluralId !== translatedMessage.pluralId ) { + if ( message.pluralId && translatedMessage.msgid_plural && message.pluralId !== translatedMessage.msgid_plural ) { console.error( `Plural form conflict found` ); process.exit( 1 ); @@ -290,13 +290,20 @@ ${ JSON.stringify( message.translations, null, 4 ) } const choise = await utils.confirm( "What translations do you want to use?", [ "n", "o" ] ); if ( choise === "n" ) { + if ( !message.pluralId ) { + translatedMessage.translations[ 0 ] = message.translations[ 0 ]; + } + else { + translatedMessage.translations = message.translations; + } - // XXX - this.#storeMessage( poFile.language, message ); + this.#storeMessage( poFile.language, { + "id": translatedMessage.msgid, + "pluralId": translatedMessage.msgid_plural, + "translations": translatedMessage.translations, + } ); } else { - - // XXX message.setTranslations( translatedMessage.translations ); } }