Skip to content

Commit

Permalink
fix: tramslations
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 14, 2024
1 parent c9e29e5 commit d0204fc
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions lib/package/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ CREATE TABLE IF NOT EXISTS translation (
msgid text NOT NULL,
msgid_plural text NOT NULL,
translations json NOT NULL,
PRIMARY KEY ( language, msgid, msgid_plural )
PRIMARY KEY ( language, msgid )
);
`,

Expand All @@ -37,11 +37,12 @@ INSERT INTO translation
)
VALUES
( ?, ?, ?, ? )
ON CONFLICT ( language, msgid, msgid_plural ) DO UPDATE SET
ON CONFLICT ( language, msgid ) DO UPDATE SET
msgid_plural = EXCLUDED.msgid_plural,
translations = EXCLUDED.translations
`.prepare(),

"getTranslations": sql`SELECT translations FROM translation WHERE language = ? AND msgid = ? AND msgid_plural = ?`.prepare(),
"getTranslations": sql`SELECT translations FROM translation WHERE language = ? AND msgid = ?`.prepare(),
};

export default class {
Expand Down Expand Up @@ -173,7 +174,6 @@ export default class {
//
poFile.language,
message.id,
message.pluralId || "",
] ).data;

// message is fully translated
Expand Down Expand Up @@ -226,17 +226,6 @@ export default class {
this.#dbh.exec( SQL.schema );
}

#storeMessage ( language, message ) {
this.#dbh.do( SQL.updateTranslations, [

//
language,
message.id,
message.pluralId || "",
message.translations,
] );
}

async #preTranslate ( poFile, message ) {
const res = await cloudTranslationApi.translate( poFile.language, message.id );

Expand Down Expand Up @@ -265,6 +254,7 @@ export default class {
}
}

// XXX
async #resolveConflict ( poFile, message, translatedMessage ) {
const translatedMessageHash = JSON.stringify( translatedMessage.translations ),
messageHash = JSON.stringify( message.translations );
Expand Down Expand Up @@ -292,4 +282,16 @@ ${ JSON.stringify( message.translations, null, 4 ) }
}
}
}

// XXX
#storeMessage ( language, message ) {
this.#dbh.do( SQL.updateTranslations, [

//
language,
message.id,
message.pluralId || "",
message.translations,
] );
}
}

0 comments on commit d0204fc

Please sign in to comment.