summaryrefslogtreecommitdiff
path: root/packages/pogen/src/po2ts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/pogen/src/po2ts.ts')
-rw-r--r--packages/pogen/src/po2ts.ts62
1 files changed, 34 insertions, 28 deletions
diff --git a/packages/pogen/src/po2ts.ts b/packages/pogen/src/po2ts.ts
index d0f4ed34d..ac85b9b76 100644
--- a/packages/pogen/src/po2ts.ts
+++ b/packages/pogen/src/po2ts.ts
@@ -23,38 +23,44 @@ import * as po2json from "po2json";
import * as fs from "fs";
import * as path from "path";
-const files = fs
- .readdirSync("./src/i18n")
- .filter((x) => x.endsWith(".po"))
- .map((x) => path.join("./src/i18n/", x));
-
-if (files.length === 0) {
- console.error("no .po files found in src/i18n/");
- process.exit(1);
-}
+export function po2ts(): void {
+ const files = fs
+ .readdirSync("./src/i18n")
+ .filter((x) => x.endsWith(".po"))
+ .map((x) => path.join("./src/i18n/", x));
-console.log(files);
+ if (files.length === 0) {
+ console.error("no .po files found in src/i18n/");
+ process.exit(1);
+ }
-const chunks: string[] = [];
+ console.log(files);
-for (const filename of files) {
- const m = filename.match(/([a-zA-Z0-9-_]+).po/);
+ const chunks: string[] = [];
- if (!m) {
- console.error("error: unexpected filename (expected <lang>.po)");
- process.exit(1);
- }
+ for (const filename of files) {
+ const m = filename.match(/([a-zA-Z0-9-_]+).po/);
- const lang = m[1];
- const pojson = po2json.parseFileSync(filename, {
- format: "jed1.x",
- fuzzy: true,
- });
- const s =
- "strings['" + lang + "'] = " + JSON.stringify(pojson, null, " ") + ";\n\n";
- chunks.push(s);
-}
+ if (!m) {
+ console.error("error: unexpected filename (expected <lang>.po)");
+ process.exit(1);
+ }
+
+ const lang = m[1];
+ const pojson = po2json.parseFileSync(filename, {
+ format: "jed1.x",
+ fuzzy: true,
+ });
+ const s =
+ "strings['" +
+ lang +
+ "'] = " +
+ JSON.stringify(pojson, null, " ") +
+ ";\n\n";
+ chunks.push(s);
+ }
-const tsContents = chunks.join("");
+ const tsContents = chunks.join("");
-fs.writeFileSync("src/i18n/strings.ts", tsContents);
+ fs.writeFileSync("src/i18n/strings.ts", tsContents);
+}