Skip to content

Commit

Permalink
feat: cloud translation
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Feb 13, 2024
1 parent dc19542 commit 60cc055
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/package/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ create table if not exists translation (
language text noy null,
msgid text not null,
msgid_plural text not null,
fuzzy bool NOT NULL,
translations json not null,
primary key ( language, msgid, msgid_plural )
);
Expand All @@ -33,13 +32,11 @@ INSERT INTO translation
language,
msgid,
msgid_plural,
fuzzy,
translations
)
VALUES
( ?, ?, ?, ?, ? )
( ?, ?, ?, ? )
ON CONFLICT ( language, msgid, msgid_plural ) DO UPDATE SET
fuzzy = EXCLUDED.fuzzy,
translations = EXCLUDED.translations
`.prepare(),

Expand Down Expand Up @@ -161,7 +158,7 @@ export default class {

// message is fully translated
if ( message.isTranslated ) {
if ( message.isDisFuzzy ) continue;
if ( message.isFuzzy ) continue;

this.#storeMessage( poFile.language, message );
}
Expand Down Expand Up @@ -198,9 +195,9 @@ export default class {
message.isFuzzy = true;
message.setTranslations( [ res.data ] );

console.log( `Auto translated:
${ message.id }
${ res.data }
console.log( `Cloud translation:
- ${ message.id }
- ${ res.data }
` );
}
Expand Down Expand Up @@ -236,7 +233,6 @@ ${ res.data }
language,
message.id,
message.pluralId || "",
message.isDisFuzzy,
message.translations,
] );
}
Expand Down

0 comments on commit 60cc055

Please sign in to comment.