diff --git a/.travis.yml b/.travis.yml index 97c7f91..db62cff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,3 +5,4 @@ node_js: - "lts/*" script: - make + - make po/starter-kit.pot diff --git a/po/html2po b/po/html2po index 2c92897..8b34fa0 100755 --- a/po/html2po +++ b/po/html2po @@ -45,9 +45,9 @@ try { } var opts = stdio.getopt({ - directory: { key: "d", args: 1, description: "Base directory for input files" }, + directory: { key: "d", args: 1, description: "Base directory for input files", default: "." }, output: { key: "o", args: 1, description: "Output file" }, - from: { key: "f", args: 1, description: "File containing list of input files" }, + from: { key: "f", args: 1, description: "File containing list of input files", default: "" }, }); if (!opts.from && opts.args.length < 1) { diff --git a/po/manifest2po b/po/manifest2po index 5376ef8..9fc9ee5 100755 --- a/po/manifest2po +++ b/po/manifest2po @@ -26,9 +26,9 @@ try { } var opts = stdio.getopt({ - directory: { key: "d", args: 1, description: "Base directory for input files" }, + directory: { key: "d", args: 1, description: "Base directory for input files", default: "." }, output: { key: "o", args: 1, description: "Output file" }, - from: { key: "f", args: 1, description: "File containing list of input files" }, + from: { key: "f", args: 1, description: "File containing list of input files", default: "" }, }); if (!opts.from && opts.args.length < 1) { @@ -70,11 +70,19 @@ function step() { if (path.basename(filename) != "manifest.json") return step(); - fs.readFile(filename, { encoding: "utf-8"}, function(err, data) { + /* Qualify the filename if necessary */ + var full = filename; + if (opts.directory) + full = path.join(opts.directory, filename); + + fs.readFile(full, { encoding: "utf-8"}, function(err, data) { if (err) fatal(err.message); - process_manifest(JSON.parse(data)); + // There are variables which when not substituted can cause JSON.parse to fail + // Dummy replace them. None variable is going to be translated anyway + safe_data = data.replace(/\@.+?\@/gi, 1); + process_manifest(JSON.parse(safe_data)); return step(); }); diff --git a/po/po2json b/po/po2json index d2185a4..67cedde 100755 --- a/po/po2json +++ b/po/po2json @@ -46,10 +46,10 @@ function prepareHeader(header) { } /* A function for the front end */ - statement = header["plural-forms"]; + statement = header["plural-forms"]; if (statement[statement.length - 1] != ';') statement += ';'; - ret = 'function(n) {\nvar nplurals, plural;\n' + statement + '\nreturn plural;\n}'; + ret = 'function(n) {\nvar nplurals, plural;\n' + statement + '\nreturn plural;\n}'; /* Added back in later */ delete header["plural-forms"]; @@ -72,7 +72,7 @@ function prepareHeader(header) { /* Parse and process the po data */ function parse() { filename = opts.args[0]; - po2json.parseFile(opts.args[0], { "fuzzy": true }, function(err, jsonData) { + po2json.parseFile(opts.args[0], { "fuzzy": false }, function(err, jsonData) { var plurals, pos; if (err) @@ -117,7 +117,7 @@ function finish(data) { if (opts.output) { fs.writeFile(opts.output, data, function(err) { if (err) - fatal(err.message); + fatal(err.message); process.exit(0); }); } else {