]>
Commit | Line | Data |
---|---|---|
3cdc603a PO |
1 | #!/usr/bin/env node |
2 | /* | |
3 | * ps2js: gettext .po to noVNC .js converter | |
4 | * Copyright (C) 2016 Pierre Ossman | |
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 | ||
20 | var getopt = require('node-getopt'); | |
21 | var fs = require('fs'); | |
22 | var po2json = require("po2json"); | |
23 | ||
24 | opt = getopt.create([ | |
25 | ['h' , 'help' , 'display this help'], | |
26 | ]).bindHelp().parseSystem(); | |
27 | ||
28 | if (opt.argv.length != 2) { | |
29 | console.error("Incorrect number of arguments given"); | |
30 | process.exit(1); | |
31 | } | |
32 | ||
33 | var data = po2json.parseFileSync(opt.argv[0]); | |
34 | ||
35 | var output = | |
36 | "/*\n" + | |
37 | " * Translations for " + data[""]["language"] + "\n" + | |
38 | " *\n" + | |
39 | " * This file was autotomatically generated from " + opt.argv[0] + "\n" + | |
40 | " * DO NOT EDIT!\n" + | |
41 | " */\n" + | |
42 | "\n" + | |
43 | "Language = {\n"; | |
44 | ||
45 | for (msgid in data) { | |
46 | if (msgid === "") | |
47 | continue; | |
48 | ||
49 | msgstr = data[msgid][1]; | |
50 | output += " " + JSON.stringify(msgid) + ": " + | |
51 | JSON.stringify(msgstr) + ",\n"; | |
52 | } | |
53 | ||
54 | output += "};\n"; | |
55 | ||
56 | fs.writeFileSync(opt.argv[1], output); |