]> git.proxmox.com Git - mirror_novnc.git/blame - po/po2js
Make Cursor.detach() safe to call when not attached
[mirror_novnc.git] / po / po2js
CommitLineData
3cdc603a
PO
1#!/usr/bin/env node
2/*
3 * ps2js: gettext .po to noVNC .js converter
84586c0f 4 * Copyright (C) 2018 The noVNC Authors
3cdc603a
PO
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
2b5f94fa
JD
20const getopt = require('node-getopt');
21const fs = require('fs');
22const po2json = require("po2json");
3cdc603a 23
2b5f94fa 24const opt = getopt.create([
776024a0 25 ['h', 'help', 'display this help'],
3cdc603a
PO
26]).bindHelp().parseSystem();
27
28if (opt.argv.length != 2) {
776024a0
PO
29 console.error("Incorrect number of arguments given");
30 process.exit(1);
3cdc603a
PO
31}
32
2b5f94fa 33const data = po2json.parseFileSync(opt.argv[0]);
3cdc603a 34
776024a0 35const bodyPart = Object.keys(data).filter(msgid => msgid !== "").map((msgid) => {
2a7c6d20 36 if (msgid === "") return;
2b5f94fa 37 const msgstr = data[msgid][1];
2a7c6d20
SR
38 return " " + JSON.stringify(msgid) + ": " + JSON.stringify(msgstr);
39}).join(",\n");
3cdc603a 40
2b5f94fa 41const output = "{\n" + bodyPart + "\n}";
3cdc603a
PO
42
43fs.writeFileSync(opt.argv[1], output);