aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/pogen/package.json3
-rw-r--r--packages/pogen/src/po2ts.ts6
-rw-r--r--packages/pogen/src/pogen.ts27
-rw-r--r--pnpm-lock.yaml13
4 files changed, 33 insertions, 16 deletions
diff --git a/packages/pogen/package.json b/packages/pogen/package.json
index 04c7ba1c0..5f6b99664 100644
--- a/packages/pogen/package.json
+++ b/packages/pogen/package.json
@@ -15,6 +15,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
- "@types/node": "^17.0.17"
+ "@types/node": "^17.0.17",
+ "glob": "^7.2.0"
}
}
diff --git a/packages/pogen/src/po2ts.ts b/packages/pogen/src/po2ts.ts
index ac85b9b76..e11443f4f 100644
--- a/packages/pogen/src/po2ts.ts
+++ b/packages/pogen/src/po2ts.ts
@@ -22,12 +22,10 @@
import * as po2json from "po2json";
import * as fs from "fs";
import * as path from "path";
+import glob = require("glob");
export function po2ts(): void {
- const files = fs
- .readdirSync("./src/i18n")
- .filter((x) => x.endsWith(".po"))
- .map((x) => path.join("./src/i18n/", x));
+ const files = glob.sync("src/i18n/*.po");
if (files.length === 0) {
console.error("no .po files found in src/i18n/");
diff --git a/packages/pogen/src/pogen.ts b/packages/pogen/src/pogen.ts
index 7d128ce7a..72b7c81d7 100644
--- a/packages/pogen/src/pogen.ts
+++ b/packages/pogen/src/pogen.ts
@@ -1,4 +1,8 @@
import { potextract } from "./potextract.js";
+import * as child_process from "child_process";
+import * as fs from "fs";
+import glob = require("glob");
+import { po2ts } from "./po2ts.js";
function usage(): never {
console.log("usage: pogen <extract|merge|emit>");
@@ -14,6 +18,29 @@ export function main() {
case "extract":
potextract();
break;
+ case "merge": {
+ const packageJson = JSON.parse(
+ fs.readFileSync("./package.json", { encoding: "utf-8" }),
+ );
+
+ const poDomain = packageJson.pogen?.domain;
+ if (!poDomain) {
+ console.error("missing 'pogen.domain' field in package.json");
+ process.exit(1);
+ }
+ const files = glob.sync("src/i18n/*.po");
+ console.log(files);
+ for (const f of files) {
+ console.log(`merging ${f}`);
+ child_process.execSync(
+ `msgmerge -o '${f}' '${f}' 'src/i18n/${poDomain}.pot'`,
+ );
+ }
+ break;
+ }
+ case "emit":
+ po2ts();
+ break;
default:
console.error(`unknown subcommand '${subcommand}'`);
usage();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index d1832bf90..83228dbc5 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -150,10 +150,12 @@ importers:
packages/pogen:
specifiers:
'@types/node': ^17.0.17
+ glob: ^7.2.0
po2json: ^0.4.5
typescript: ^4.5.5
dependencies:
'@types/node': 17.0.17
+ glob: 7.2.0
devDependencies:
po2json: 0.4.5
typescript: 4.5.5
@@ -8201,7 +8203,6 @@ packages:
/balanced-match/1.0.2:
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
- dev: true
/base/0.11.2:
resolution: {integrity: sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==}
@@ -8356,7 +8357,6 @@ packages:
dependencies:
balanced-match: 1.0.2
concat-map: 0.0.1
- dev: true
/braces/2.3.2:
resolution: {integrity: sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==}
@@ -9196,7 +9196,6 @@ packages:
/concat-map/0.0.1:
resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=}
- dev: true
/concat-stream/1.6.2:
resolution: {integrity: sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw==}
@@ -11769,7 +11768,6 @@ packages:
/fs.realpath/1.0.0:
resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=}
- dev: true
/fsevents/1.2.13:
resolution: {integrity: sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw==}
@@ -11974,7 +11972,6 @@ packages:
minimatch: 3.0.5
once: 1.4.0
path-is-absolute: 1.0.1
- dev: true
/global-dirs/3.0.0:
resolution: {integrity: sha512-v8ho2DS5RiCjftj1nD9NmnfaOzTdud7RRnVd9kFNOjqZbISlx5DQ+OrTkywgd0dIt7oFCvKetZSHoHcP3sDdiA==}
@@ -12655,7 +12652,6 @@ packages:
dependencies:
once: 1.4.0
wrappy: 1.0.2
- dev: true
/inherits/2.0.1:
resolution: {integrity: sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=}
@@ -12667,7 +12663,6 @@ packages:
/inherits/2.0.4:
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
- dev: true
/ini/1.3.8:
resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==}
@@ -14169,7 +14164,6 @@ packages:
resolution: {integrity: sha512-tUpxzX0VAzJHjLu0xUfFv1gwVp9ba3IOuRAVH2EGuRW8a5emA2FlACLqiT/lDVtS1W+TGNwqz3sWaNyLgDJWuw==}
dependencies:
brace-expansion: 1.1.11
- dev: true
/minimist/1.2.5:
resolution: {integrity: sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==}
@@ -14754,7 +14748,6 @@ packages:
resolution: {integrity: sha1-WDsap3WWHUsROsF9nFC6753Xa9E=}
dependencies:
wrappy: 1.0.2
- dev: true
/onetime/5.1.2:
resolution: {integrity: sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==}
@@ -15162,7 +15155,6 @@ packages:
/path-is-absolute/1.0.1:
resolution: {integrity: sha1-F0uSaHNVNP+8es5r9TpanhtcX18=}
engines: {node: '>=0.10.0'}
- dev: true
/path-key/2.0.1:
resolution: {integrity: sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=}
@@ -19951,7 +19943,6 @@ packages:
/wrappy/1.0.2:
resolution: {integrity: sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=}
- dev: true
/write-file-atomic/3.0.3:
resolution: {integrity: sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==}