diff options
Diffstat (limited to 'node_modules/po2json')
29 files changed, 1197 insertions, 0 deletions
diff --git a/node_modules/po2json/.gitignore b/node_modules/po2json/.gitignore new file mode 100644 index 000000000..5171c5408 --- /dev/null +++ b/node_modules/po2json/.gitignore @@ -0,0 +1,2 @@ +node_modules +npm-debug.log
\ No newline at end of file diff --git a/node_modules/po2json/.npmignore b/node_modules/po2json/.npmignore new file mode 100644 index 000000000..2ccbe4656 --- /dev/null +++ b/node_modules/po2json/.npmignore @@ -0,0 +1 @@ +/node_modules/ diff --git a/node_modules/po2json/.travis.yml b/node_modules/po2json/.travis.yml new file mode 100644 index 000000000..2cf583e2f --- /dev/null +++ b/node_modules/po2json/.travis.yml @@ -0,0 +1,8 @@ +language: node_js +node_js: + - 6 + - 5 + - 4 + - 0.12 + - 0.11 + - 0.10 diff --git a/node_modules/po2json/AUTHORS b/node_modules/po2json/AUTHORS new file mode 100644 index 000000000..c0ce7494c --- /dev/null +++ b/node_modules/po2json/AUTHORS @@ -0,0 +1,10 @@ +# Authors ordered by first contribution. + +Illimar Tambek <illimar@sliptree.com> +Mike Edwards <michael.edwards@huffingtonpost.com> +gilles <gilles.devaux@gmail.com> +Asbjørn Sloth Tønnesen <ast@veridu.com> +Zach Carter <zack.carter@gmail.com> +Dan MacTough <danmactough@gmail.com> +Evan Moses +Dima Kurguzov diff --git a/node_modules/po2json/History.md b/node_modules/po2json/History.md new file mode 100644 index 000000000..0f64eddb9 --- /dev/null +++ b/node_modules/po2json/History.md @@ -0,0 +1,95 @@ +0.4.1 / 2016-04-13 +================== + * Updated documentation for Jed > 1.1.0 + * Use msgid_plural when there is no translation + +0.4.1 / 2015-03-01 +================== + * Updated Jed-format code and test to deal with the new plural form + +0.4.0 / 2015-03-01 +================== + * Added Jed > 1.1.0 compatible format (Evan Moses) + +0.3.0 / 2014-07-16 +================== + * Added command line flags for fuzzy, pretty, format, and domain (Szigetvári Áron) + * Deals with fallback-to-msgid for fuzzy entries without the fuzzy flag (Szigetvári Áron) + +0.2.4 / 2014-07-15 +================== + + * Fixed fuzzy flag (mahata) + +0.2.3 / 2014-01-26 +================== + + * Raised minimum node version requirement to 0.8 + * Raised lodash version to ~2.4.1 + * Clean up documentations + +0.2.0 / 2013-11-08 +================== + +**NB! This release is NOT backwards-compatible!** It has the following **braking changes**: + + * `po2json.parse_po` has been replaced with `po2json.parse` + * `po2json.parse` has been replaced with `po2json.parseFile` + * `po2json.parseSync` has been replaced with `po2json.parseFileSync` + +Other changes in this release: + + * The library has been competely rewritten, it now uses the [gettext-parser](https://github.com/andris9/gettext-parser) module to parse PO files. (Illimar Tambek) + * Tests have been completely rewritten (Illimar Tambek) + * Fixed issue with double-escaping quotes (Illimar Tambek) + * Option to skip/include fuzzy translations (Illimar Tambek) + + +0.0.7 / 2012-10-26 +================== + + * Fixed linting bugs and added a better fr.po fixture (Mike Edwards) + * Add tests for po2json.parse and po2json.parseSync (Dan MacTough) + * updated README.md with version history (Mike Edwards) + * updated history (Mike Edwards) + +0.0.6 / 2012-10-22 +================== + + * Add AUTHORS to identify contributors (Dan MacTough) + * Update README with revision history and basic examples (Dan MacTough) + +0.0.5 / 2012-10-19 +================== + + * cut out fake README example from grunt boilerplate (Mike Edwards) + * fixed README.md markdown (Mike Edwards) + * fixes tests (Mike Edwards) + * added first test for parse_po (Mike Edwards) + * Added boilerplate using grunt init (Mike Edwards) + * Changed exports.parse to use node's convetional error-first callback style. Added exports.parseSync for synchronous parsing. (Dan MacTough) + +0.0.4 / 2012-09-18 +================== + + * Properly escape linebreaks (Zach Carter) + * Update package.json (Mike Edwards) + * package.json: define main module (Asbjørn Sloth Tønnesen) + +0.0.2 / 2012-07-03 +================== + + * fix package, fix pretty print return, remove debug logs (gilles) + * upped version (Mike Edwards) + +0.0.1 / 2012-06-06 +================== + + * Added build status to README (Mike Edwards) + * Removed built=ints from the dependencies (Mike Edwards) + * Added a .travis file for continuous integration (Mike Edwards) + * Added usage note to README.md (Mike Edwards) + * First working script! (Mike Edwards) + * Added new git repo (Mike Edwards) + * initial commit (Mike Edwards) + * Initial commit (Mike Edwards) diff --git a/node_modules/po2json/LICENSE b/node_modules/po2json/LICENSE new file mode 100644 index 000000000..59a64e748 --- /dev/null +++ b/node_modules/po2json/LICENSE @@ -0,0 +1,28 @@ +Pure Javascript implementation of Uniforum message translation. +Copyright (C) 2008 Joshua I. Miller <unrtst@cpan.org>, all rights reserved + +This program is free software; you can redistribute it and/or modify it +under the terms of the GNU Library General Public License as published +by the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. + +PO parser from http://jsgettext.berlios.de/lib/Gettext.js +adapted for Node.js and modified to be more like po2json.pl +- Zach Carter <zcarter@cse.usf.edu> + +Further adapted to be used inside a node.js environment instead of the command line. Import with a require statement: +var po2json = require('po2json.js') +po2json.parse('filename', function(result) { + on parse complete callaback, result is the json string. +}); +- Daniel Roberts <danielrobertsdesign@gmail.com> diff --git a/node_modules/po2json/README.md b/node_modules/po2json/README.md new file mode 100644 index 000000000..434b7474e --- /dev/null +++ b/node_modules/po2json/README.md @@ -0,0 +1,211 @@ +# po2json + +[](http://travis-ci.org/mikeedwards/po2json) +[](https://david-dm.org/mikeedwards/po2json) +[](https://david-dm.org/mikeedwards/po2json#info=devDependencies) + +[](https://nodei.co/npm/po2json/) + +Convert PO files to Javascript objects or JSON strings. The result is Jed-compatible. + +## Getting Started +Install the module with: `npm install po2json` + +### As a library +``` +var po2json = require('po2json'); +``` + +### As an executable +``` +po2json translation.po translation.json +``` + +## Documentation + +### Methods + +po2json has 3 methods, all of which take exactly the same options. The main function is `parse` which actually does the parsing to JSON. The 2 others - `parseFile` and `parseFileSync` are convenience functions to directly read PO data from a file and convert it to JSON. + +Parse a PO buffer to JSON + +* `po2json.parse(buf[, options])` + * `buf` - a _po_ file as a Buffer or an unicode string. + * `options` - an optional object with the following possible parameters: + * `fuzzy` Whether to include fuzzy translation in JSON or not. Should be either `true` or `false`. Defaults to `false`. + * `stringify` If `true`, returns a JSON string. Otherwise returns a plain Javascript object. Defaults to `false`. + * `pretty` If `true`, the resulting JSON string will be pretty-printed. Has no effect when `stringify` is `false`. Defaults to `false` + * `format` Defaults to `raw`. + * `raw` produces a "raw" JSON output + * `jed` produces an output that is 100% compatible with Jed < 1.1.0 + * `jed1.x` produces an output that is 100% compatible with Jed >= 1.1.0 + * `mf` produces simple key:value output. + * `domain` - the domain the messages will be wrapped inside. Only has effect if `format: 'jed'`. + +Parse a PO file to JSON + +* `po2json.parseFile(fileName[,options], cb)` + * `fileName` - path to the po file + * `options` - same as for `po2json.parse` + * `cb` - a function that receives 2 arguments: `err` and `jsonData` + +Parse a PO file to JSON (synchronous) + +* `po2json.parseFileSync(fileName[, options])` + * `fileName` - path to the po file + * `options` - same as for `po2json.parse` + +#### fallback-to-msgid +If `fallback-to-msgid` is set, for those entries that would be omitted +(fuzzy entries without the fuzzy flag) and for those that are empty, +the msgid will be used as translation in the json file. +If the entry is plural, msgid_plural will be used for msgstr[1]. +This means that this option makes sense only for those languages +that have nplurals=2. + +### Command Line Arguments + +po2json in command-line parametrization support added to allow override +default options. + +* --pretty, -p: same as pretty = true in function options +* --fuzzy, -F: same as fuzzy = true in function options +* --format, -f: Output format (raw, jed, jed1.x, or mf) +* --domain, -d: same as domain in function options + +Note: `'format': 'mf'` means the json format used by messageFormatter in github.com/SlexAxton/messageformat.js +This system does any pluralization within the string, so only msgstr[0] is used with these format, in a simple "key": "value" form. + +## Examples + +### Basic usage with PO data as a buffer/string +``` +var po2json = require('po2json'), + fs = require('fs'); +fs.readFile('messages.po', function (err, buffer) { + var jsonData = po2json.parse(buffer); + // do something interesting ... +}); +``` + +### Parse a PO file directly - Asynchronous Usage +``` +var po2json = require('po2json'); +po2json.parseFile('messages.po', function (err, jsonData) { + // do something interesting ... +}); +``` + +### Parse a PO file directly - Synchronous Usage +``` +var po2json = require('po2json'); +var jsonData = ''; +try { + jsonData = po2json.parseFileSync('messages.po'); + // do something interesting ... +} catch (e) {} +``` + +### Parse a PO file to Jed format +``` +var po2json = require('po2json'), + Jed = require('jed'); +po2json.parseFile('messages.po', { format: 'jed' }, function (err, jsonData) { + var i18n = new Jed( jsonData ); +}); +``` + +### Running tests +``` +npm test +``` + +## Contributing +In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [grunt](https://github.com/gruntjs/grunt). + +## Release History +### 0.4.2 / 2015-04-13 + * Updated documentation for Jed > 1.1.0 + * Use msgid_plural when there is no translation + +### 0.4.1 / 2015-03-01 + * Updated Jed-format code and test to deal with the new plural form + +### 0.4.0 / 2015-03-01 + * Added Jed > 1.1.0 compatible format (Evan Moses) + +### 0.3.0 / 2014-07-16 + * Added command line flags for fuzzy, pretty, format, and domain (Szigetvári Áron) + * Deals with fallback-to-msgid for fuzzy entries without the fuzzy flag (Szigetvári Áron) + +### 0.2.4 / 2014-07-15 + + * Fixed fuzzy flag (mahata) + +### 0.2.3 / 2014-01-26 + + * Raised minimum node version requirement to 0.8 + * Raised lodash version to ~2.4.1 + * Clean up documentations + +### 0.2.0 / 2013-11-08 + +**NB! This release is NOT backwards-compatible!** It has the following **breaking changes**: + + * `po2json.parse_po` has been replaced with `po2json.parse` + * `po2json.parse` has been replaced with `po2json.parseFile` + * `po2json.parseSync` has been replaced with `po2json.parseFileSync` + +Other changes in this release: + + * The library has been competely rewritten, it now uses the [gettext-parser](https://github.com/andris9/gettext-parser) module to parse PO files. (Illimar Tambek) + * Tests have been completely rewritten (Illimar Tambek) + * Fixed issue with double-escaping quotes (Illimar Tambek) + * Option to skip/include fuzzy translations (Illimar Tambek) + +### 0.0.7 / 2012-10-26 + + * Fixed linting bugs and added a better fr.po fixture (Mike Edwards) + * Add tests for po2json.parse and po2json.parseSync (Dan MacTough) + * updated README.md with version history (Mike Edwards) + * updated history (Mike Edwards) + +### 0.0.6 / 2012-10-22 + + * Add AUTHORS to identify contributors (Dan MacTough) + * Update README with revision history and basic examples (Dan MacTough) + +### 0.0.5 / 2012-10-19 + + * cut out fake README example from grunt boilerplate (Mike Edwards) + * fixed README.md markdown (Mike Edwards) + * fixes tests (Mike Edwards) + * added first test for parse_po (Mike Edwards) + * Added boilerplate using grunt init (Mike Edwards) + * Changed exports.parse to use node's convetional error-first callback style. Added exports.parseSync for synchronous parsing. (Dan MacTough) + +### 0.0.4 / 2012-09-18 + + * Properly escape linebreaks (Zach Carter) + * Update package.json (Mike Edwards) + * package.json: define main module (Asbjørn Sloth Tønnesen) + +### 0.0.2 / 2012-07-03 + + * fix package, fix pretty print return, remove debug logs (gilles) + * upped version (Mike Edwards) + +### 0.0.1 / 2012-06-06 + + * Added build status to README (Mike Edwards) + * Removed built=ints from the dependencies (Mike Edwards) + * Added a .travis file for continuous integration (Mike Edwards) + * Added usage note to README.md (Mike Edwards) + * First working script! (Mike Edwards) + * Added new git repo (Mike Edwards) + * initial commit (Mike Edwards) + * Initial commit (Mike Edwards) + +## License +Copyright (c) 2012 Joshua I. Miller +Licensed under the GNU, Library, General, Public, License licenses. diff --git a/node_modules/po2json/bin/po2json b/node_modules/po2json/bin/po2json new file mode 100755 index 000000000..9eab18831 --- /dev/null +++ b/node_modules/po2json/bin/po2json @@ -0,0 +1,53 @@ +#!/usr/bin/env node + +var po2json = require('../'), + fs = require('fs'), + assert = require('assert'), + argv = process.argv; + +var opts = require("nomnom") + .script('po2json') + .option('pretty', { + abbr: 'p', + flag: true, + help: 'pretty-print JSON' + }) + .option('fuzzy', { + abbr: 'F', + flag: true, + help: 'include fuzzy messages' + }) + .option('format', { + abbr: 'f', + default: 'raw', + help: 'output format, one of: raw, jed, jed1.x, mf (messageformat)' + }) + .option('domain', { + abbr: 'd', + default: 'messages', + help: 'domain' + }) + .option('fallback-to-msgid', { + flag: true, + help: 'Use msgid if translation is missing (nplurals must match)' + }) + .option('input', { + position: 0, + required: true, + list: false, + help: 'input file' + }) + .option('output', { + position: 1, + required: true, + list: false, + help: 'output file' + }) + .parse(); + +opts.stringify = true; + +var result = po2json.parseFileSync(opts.input, opts), + stream = fs.createWriteStream(opts.output, {}); + +stream.write(result); diff --git a/node_modules/po2json/bower.json b/node_modules/po2json/bower.json new file mode 100644 index 000000000..8fa9a6680 --- /dev/null +++ b/node_modules/po2json/bower.json @@ -0,0 +1,21 @@ +{ + "name": "po2json", + "version": "0.3.2", + "ignore": [ + "**/.*", + "test", + "lib", + "*.md", + ".json", + ".yml", + "package.json", + "*.js" + ], + "keywords": [ + "i18n", + "l10n", + "gettext", + "po" + ], + "license": "LGPL" +} diff --git a/node_modules/po2json/index.js b/node_modules/po2json/index.js new file mode 100644 index 000000000..5be58883e --- /dev/null +++ b/node_modules/po2json/index.js @@ -0,0 +1,5 @@ +module.exports = { + parse: require('./lib/parse'), + parseFile: require('./lib/parseFile'), + parseFileSync: require('./lib/parseFileSync') +};
\ No newline at end of file diff --git a/node_modules/po2json/lib/parse.js b/node_modules/po2json/lib/parse.js new file mode 100644 index 000000000..5cb1f6ad7 --- /dev/null +++ b/node_modules/po2json/lib/parse.js @@ -0,0 +1,108 @@ +/** + * Parse PO buffer to JSON + * + * @param {Buffer|String} buffer - Buffer PO object or unicode string with PO data + * @param {Object} [options] + * @return {Object|String} Translation JSON + */ + +module.exports = function(buffer, options) { + + // Setup options and load in defaults + options = options || {}; + var defaults = { + pretty: false, + fuzzy: false, + stringify: false, + format: 'raw', + domain: 'messages', + charset: 'utf8' + }; + + for (var property in defaults) { + options[property] = 'undefined' !== typeof options[property] ? options[property] : defaults[property]; + } + + // Parse the PO file + var parsed = require('gettext-parser').po.parse( buffer, defaults.charset ); + + // Create gettext/Jed compatible JSON from parsed data + var result = {}, + contexts = parsed.translations; + + Object.keys(contexts).forEach(function (context) { + var translations = parsed.translations[context]; + var pluralForms = parsed.headers ? parsed.headers['plural-forms'] : ''; + + Object.keys(translations).forEach(function (key, i) { + var t = translations[key], + translationKey = context.length ? context + '\u0004' + key : key, + fuzzy = t.comments && t.comments.flag && t.comments.flag.match(/fuzzy/) !== null; + + if (!fuzzy || options.fuzzy) { + if (options.format === 'mf') { + result[translationKey] = t.msgstr[0]; + } else if (options.format === 'jed1.x') { + result[translationKey] = [ t.msgid_plural ? t.msgid_plural : null ].concat(t.msgstr); + } else { + if(pluralForms == 'nplurals=1; plural=0;') { + msgstr = t.msgid_plural ? [t.msgstr] : t.msgstr + result[translationKey] = [ t.msgid_plural ? t.msgid_plural : null ].concat(msgstr); + } else { + result[translationKey] = [ t.msgid_plural ? t.msgid_plural : null ].concat(t.msgstr); + } + } + } + + // In the case of fuzzy or empty messages, use msgid(/msgid_plural) + if (options['fallback-to-msgid'] && (fuzzy && !options.fuzzy || t.msgstr[0] === '')) { + if (options.format === 'mf') { + result[translationKey] = key; + } else { + result[translationKey] = [ t.msgid_plural ? t.msgid_plural : null ] + .concat(t.msgid_plural ? [key, t.msgid_plural] : [key]); + } + } + + }); + }); + + // Attach headers (overwrites any empty translation keys that may have somehow gotten in) + if (parsed.headers) { + result[''] = parsed.headers; + } + + if (options.format === 'mf') { + delete result['']; + } + + // Make JSON fully Jed-compatible + if (options.format.indexOf('jed') === 0) { + var jed = { + domain: options.domain, + locale_data: {} + }; + if (options.format === 'jed1.x'){ + for (var key in result) { + if (result.hasOwnProperty(key) && key !== ''){ + for (var i = 2; i < result[key].length; i++){ + if ('' === result[key][i]){ + result[key][i] = result[key][0]; + } + } + result[key].shift(); + } + } + } + jed.locale_data[options.domain] = result; + jed.locale_data[options.domain][''] = { + domain: options.domain, + plural_forms: result['']['plural-forms'], + lang: result['']['language'] + }; + + result = jed; + } + + return options.stringify ? JSON.stringify( result, null, options.pretty ? ' ' : null ) : result; +} diff --git a/node_modules/po2json/lib/parseFile.js b/node_modules/po2json/lib/parseFile.js new file mode 100644 index 000000000..af7dc6911 --- /dev/null +++ b/node_modules/po2json/lib/parseFile.js @@ -0,0 +1,28 @@ +var fs = require("fs"); + +/** + * Asynchronously parse a PO file to JSON + * + * @param {String} fileName - File name + * @param {Object} [options] + * @param {Function} cb - Callback function, takes 2 arguments: err and result + */ + +module.exports = function(fileName, options, cb) { + options = options || {}; + + if (typeof options === 'function') { + cb = options; + options = {}; + } + + fs.realpath(fileName, function (err, realFile) { + if (err) return cb(err); + + fs.readFile(realFile, function (err, data) { + if (err) return cb(err); + + cb(null, require("./parse")( data, options )); + }); + }); +};
\ No newline at end of file diff --git a/node_modules/po2json/lib/parseFileSync.js b/node_modules/po2json/lib/parseFileSync.js new file mode 100644 index 000000000..2110254ce --- /dev/null +++ b/node_modules/po2json/lib/parseFileSync.js @@ -0,0 +1,15 @@ +var fs = require("fs"); + +/** + * Synchronously parse a PO file to JSON + * + * @param {String} fileName - File name + * @param {Object} [options] + * @return {Object|String} Translation JSON + */ + +module.exports = function(fileName, options) { + var data = fs.readFileSync(fs.realpathSync(fileName)); + + return require("./parse")( data, options ); +};
\ No newline at end of file diff --git a/node_modules/po2json/package.json b/node_modules/po2json/package.json new file mode 100644 index 000000000..b62511662 --- /dev/null +++ b/node_modules/po2json/package.json @@ -0,0 +1,79 @@ +{ + "name": "po2json", + "description": "Convert PO files to JSON", + "version": "0.4.5", + "homepage": "https://github.com/mikeedwards/po2json", + "author": { + "name": "Joshua I. Miller", + "email": "unrtst@cpan.org" + }, + "contributors": [ + { + "name": "Zach Carter", + "email": "zcarter@cse.usf.edu" + }, + { + "name": "Daniel Roberts", + "email": "danielrobertsdesign@gmail.com" + }, + { + "name": "Mike Edwards", + "email": "michael.edwards@huffingtonpost.com" + }, + { + "name": "Illimar Tambek", + "email": "illimar@sliptree.com" + }, + { + "name": "mahata", + "email": "mahata777@gmail.com" + }, + { + "name": "Szigetvári Áron" + }, + { + "name": "rafalt-iRonin" + }, + { + "name": "Alex Petty", + "email": "pettyalex@gmail.com" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/mikeedwards/po2json.git" + }, + "bugs": { + "url": "https://github.com/mikeedwards/po2json/issues" + }, + "licenses": [ + { + "type": "GNU Library General Public License", + "url": "http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html" + } + ], + "bin": { + "po2json": "bin/po2json" + }, + "main": "./lib/po2json", + "engines": { + "node": ">= 0.8.0" + }, + "scripts": { + "test": "nodeunit test/" + }, + "devDependencies": { + "nodeunit": "*", + "jed": "~1.0.2" + }, + "keywords": [ + "i18n", + "l10n", + "gettext", + "po" + ], + "dependencies": { + "nomnom": "1.8.1", + "gettext-parser": "1.1.0" + } +} diff --git a/node_modules/po2json/test/fixtures/en-empty.json b/node_modules/po2json/test/fixtures/en-empty.json new file mode 100644 index 000000000..4216a1c05 --- /dev/null +++ b/node_modules/po2json/test/fixtures/en-empty.json @@ -0,0 +1,40 @@ +{ + "": { + "project-id-version": "po2json", + "pot-creation-date": "2012-10-26 12:00+0000", + "po-revision-date": "2013-11-08 09:09+0200", + "last-translator": "Illimar Tambek <illimar.tambek@gmail.com>", + "language-team": "po2json", + "mime-version": "1.0", + "plural-forms": "nplurals=2; plural=(n != 1);", + "content-type": "text/plain; charset=UTF-8", + "content-transfer-encoding": "8bit", + "x-generator": "Poedit 1.5.7", + "language": "en" + }, + "Hello, world!\n": [ + null, + "Hello, world!\n" + ], + "string context\u0004the contextual phrase": [ + null, + "the contextual phrase" + ], + "this is the first line\nthis is the next one\nbut this is the last\n": [ + null, + "this is the first line\nthis is the next one\nbut this is the last\n" + ], + "one product": [ + "%d products", + "one product", + "%d products" + ], + "A sentence with \"quotation\" marks.": [ + null, + "A sentence with \"quotation\" marks." + ], + "A fuzzy translation": [ + null, + "A fuzzy translation" + ] +}
\ No newline at end of file diff --git a/node_modules/po2json/test/fixtures/en-empty.po b/node_modules/po2json/test/fixtures/en-empty.po new file mode 100644 index 000000000..b2cb6bd55 --- /dev/null +++ b/node_modules/po2json/test/fixtures/en-empty.po @@ -0,0 +1,45 @@ +# English empty translation for po2json text fixture. +# +msgid "" +msgstr "" +"Project-Id-Version: po2json\n" +"POT-Creation-Date: 2012-10-26 12:00+0000\n" +"PO-Revision-Date: 2013-11-08 09:09+0200\n" +"Last-Translator: Illimar Tambek <illimar.tambek@gmail.com>\n" +"Language-Team: po2json\n" +"MIME-Version: 1.0\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.7\n" +"Language: en\n" + +#: test.js:1 +msgid "Hello, world!\n" +msgstr "" + +#: test.js:2 +msgctxt "string context" +msgid "the contextual phrase" +msgstr "" + +#: test.js:3 +msgid "" +"this is the first line\n" +"this is the next one\n" +"but this is the last\n" +msgstr "" + +#: test.js:4 +msgid "one product" +msgid_plural "%d products" +msgstr[0] "" +msgstr[1] "" + +#: test.js:5 +msgid "A sentence with \"quotation\" marks." +msgstr "" + +#: test.js:6 +msgid "A fuzzy translation" +msgstr "" diff --git a/node_modules/po2json/test/fixtures/en-mf-fallback-to-msgid.json b/node_modules/po2json/test/fixtures/en-mf-fallback-to-msgid.json new file mode 100644 index 000000000..8f4d790ba --- /dev/null +++ b/node_modules/po2json/test/fixtures/en-mf-fallback-to-msgid.json @@ -0,0 +1,9 @@ +{ + "Hello, world!\n": "Hello, world!\n", + "this is the first line\nthis is the next one\nbut this is the last\n": + "this is the first line\nthis is the next one\nbut this is the last\n", + "A sentence with \"quotation\" marks.": "A sentence with \"quotation\" marks.", + "one product": "one product", + "string context\u0004the contextual phrase": "the contextual phrase", + "A fuzzy translation": "A fuzzy translation" +}
\ No newline at end of file diff --git a/node_modules/po2json/test/fixtures/en-no-header.json b/node_modules/po2json/test/fixtures/en-no-header.json new file mode 100644 index 000000000..f933eb8eb --- /dev/null +++ b/node_modules/po2json/test/fixtures/en-no-header.json @@ -0,0 +1,6 @@ +{ + "Hello World": [ + null, + "Hello World" + ] +}
\ No newline at end of file diff --git a/node_modules/po2json/test/fixtures/en-no-header.po b/node_modules/po2json/test/fixtures/en-no-header.po new file mode 100644 index 000000000..7b57ae104 --- /dev/null +++ b/node_modules/po2json/test/fixtures/en-no-header.po @@ -0,0 +1,4 @@ +# Very minimal .po + +msgid "Hello World" +msgstr "Hello World" diff --git a/node_modules/po2json/test/fixtures/ja-jed1.x.json b/node_modules/po2json/test/fixtures/ja-jed1.x.json new file mode 100644 index 000000000..880341632 --- /dev/null +++ b/node_modules/po2json/test/fixtures/ja-jed1.x.json @@ -0,0 +1 @@ +{"domain":"messages","locale_data":{"messages":{"":{"domain":"messages","plural_forms":"nplurals=1; plural=0;","lang":"ja"},"♂ Male":["男性"],"partner application":["パートナーアプリ"],"result":["検索結果"],"For %s person starting at %s":["For %1$s people starting at %2$s"]}}} diff --git a/node_modules/po2json/test/fixtures/ja.json b/node_modules/po2json/test/fixtures/ja.json new file mode 100644 index 000000000..a562b0646 --- /dev/null +++ b/node_modules/po2json/test/fixtures/ja.json @@ -0,0 +1,17 @@ +{ + "": { + "project-id-version": "VERSION", + "po-revision-date": "2016-08-08 14:08+0000", + "last-translator": "FULL NAME <EMAIL@ADDRESS>", + "language-team": "LANGUAGE TEAM <EMAIL@ADDRESS>", + "language": "ja", + "mime-version": "1.0", + "content-type": "text/plain; charset=UTF-8", + "content-transfer-encoding": "8bit", + "plural-forms": "nplurals=1; plural=0;" + }, + "♂ Male": [ null, "男性" ], + "partner application": [ "partner applications", [ "パートナーアプリ" ] ], + "result": [ "results", [ "検索結果" ] ], + "For %s person starting at %s": [ "For %s people starting at %s", ["For %1$s people starting at %2$s"] ] +} diff --git a/node_modules/po2json/test/fixtures/ja.po b/node_modules/po2json/test/fixtures/ja.po new file mode 100755 index 000000000..e590422a5 --- /dev/null +++ b/node_modules/po2json/test/fixtures/ja.po @@ -0,0 +1,27 @@ +msgid "" +msgstr "" +"Project-Id-Version: VERSION\n" +"PO-Revision-Date: 2016-08-08 14:08+0000\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE TEAM <EMAIL@ADDRESS>\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "♂ Male" +msgstr "男性" + +msgid "partner application" +msgid_plural "partner applications" +msgstr[0] "パートナーアプリ" + +msgid "result" +msgid_plural "results" +msgstr[0] "検索結果" + +msgid "For %s person starting at %s" +msgid_plural "For %s people starting at %s" +msgstr[0] "For %1$s people starting at %2$s" + diff --git a/node_modules/po2json/test/fixtures/pl-jed.json b/node_modules/po2json/test/fixtures/pl-jed.json new file mode 100644 index 000000000..43f8c4133 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl-jed.json @@ -0,0 +1,40 @@ +{ + "domain": "messages", + "locale_data": { + "messages": { + "": { + "domain": "messages", + "plural_forms": "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);", + "lang": "pl" + }, + "Hello, world!\n": [ + null, + "Witaj, świecie!\n" + ], + "this is the first line\nthis is the next one\nbut this is the last\n": [ + null, + "to jest pierwsza linia\nto jest następny\nale to jest ostatnia\n" + ], + "one product": [ + "%d products", + "jeden produkt", + "%d produkty", + "%d produktów" + ], + "A sentence with \"quotation\" marks.": [ + null, + "Zdanie w \"cudzysłowie\"." + ], + "string context\u0004the contextual phrase": [ + null, + "zwrot kontekstowe" + ], + "a product": [ + "%d products", + "", + "", + "" + ] + } + } +} diff --git a/node_modules/po2json/test/fixtures/pl-jed1.x.json b/node_modules/po2json/test/fixtures/pl-jed1.x.json new file mode 100644 index 000000000..630ac3a77 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl-jed1.x.json @@ -0,0 +1,34 @@ +{ + "domain": "messages", + "locale_data": { + "messages": { + "": { + "domain": "messages", + "plural_forms": "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);", + "lang": "pl" + }, + "Hello, world!\n": [ + "Witaj, świecie!\n" + ], + "this is the first line\nthis is the next one\nbut this is the last\n": [ + "to jest pierwsza linia\nto jest następny\nale to jest ostatnia\n" + ], + "one product": [ + "jeden produkt", + "%d produkty", + "%d produktów" + ], + "A sentence with \"quotation\" marks.": [ + "Zdanie w \"cudzysłowie\"." + ], + "string context\u0004the contextual phrase": [ + "zwrot kontekstowe" + ], + "a product": [ + "", + "%d products", + "%d products" + ] + } + } +} diff --git a/node_modules/po2json/test/fixtures/pl-mf.json b/node_modules/po2json/test/fixtures/pl-mf.json new file mode 100644 index 000000000..19a3550f4 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl-mf.json @@ -0,0 +1,7 @@ +{ + "Hello, world!\n": "Witaj, świecie!\n", + "this is the first line\nthis is the next one\nbut this is the last\n": + "to jest pierwsza linia\nto jest następny\nale to jest ostatnia\n", + "A sentence with \"quotation\" marks.": "Zdanie w \"cudzysłowie\".", + "string context\u0004the contextual phrase": "zwrot kontekstowe" +}
\ No newline at end of file diff --git a/node_modules/po2json/test/fixtures/pl-mf.po b/node_modules/po2json/test/fixtures/pl-mf.po new file mode 100644 index 000000000..f954710a8 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl-mf.po @@ -0,0 +1,44 @@ +# Polish translation for po2json text fixture. +# +msgid "" +msgstr "" +"Project-Id-Version: po2json\n" +"POT-Creation-Date: 2012-10-26 12:00+0000\n" +"PO-Revision-Date: 2013-11-08 09:09+0200\n" +"Last-Translator: Illimar Tambek <illimar.tambek@gmail.com>\n" +"Language-Team: po2json\n" +"MIME-Version: 1.0\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.7\n" +"Language: pl\n" + +#: test.js:1 +msgid "Hello, world!\n" +msgstr "Witaj, świecie!\n" + +#: test.js:2 +msgctxt "string context" +msgid "the contextual phrase" +msgstr "zwrot kontekstowe" + +#: test.js:3 +msgid "" +"this is the first line\n" +"this is the next one\n" +"but this is the last\n" +msgstr "" +"to jest pierwsza linia\n" +"to jest następny\n" +"ale to jest ostatnia\n" + +#: test.js:5 +msgid "A sentence with \"quotation\" marks." +msgstr "Zdanie w \"cudzysłowie\"." + +#: test.js:6 +#, fuzzy +msgid "A fuzzy translation" +msgstr "Tłumaczenie rozmyta" diff --git a/node_modules/po2json/test/fixtures/pl.json b/node_modules/po2json/test/fixtures/pl.json new file mode 100644 index 000000000..8530ad456 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl.json @@ -0,0 +1,43 @@ +{ + "": { + "project-id-version": "po2json", + "pot-creation-date": "2012-10-26 12:00+0000", + "po-revision-date": "2013-11-08 09:09+0200", + "last-translator": "Illimar Tambek <illimar.tambek@gmail.com>", + "language-team": "po2json", + "mime-version": "1.0", + "plural-forms": "nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);", + "content-type": "text/plain; charset=UTF-8", + "content-transfer-encoding": "8bit", + "x-generator": "Poedit 1.5.7", + "language": "pl" + }, + "Hello, world!\n": [ + null, + "Witaj, świecie!\n" + ], + "this is the first line\nthis is the next one\nbut this is the last\n": [ + null, + "to jest pierwsza linia\nto jest następny\nale to jest ostatnia\n" + ], + "one product": [ + "%d products", + "jeden produkt", + "%d produkty", + "%d produktów" + ], + "A sentence with \"quotation\" marks.": [ + null, + "Zdanie w \"cudzysłowie\"." + ], + "string context\u0004the contextual phrase": [ + null, + "zwrot kontekstowe" + ], + "a product": [ + "%d products", + "", + "", + "" + ] +} diff --git a/node_modules/po2json/test/fixtures/pl.po b/node_modules/po2json/test/fixtures/pl.po new file mode 100644 index 000000000..4fda5f7a6 --- /dev/null +++ b/node_modules/po2json/test/fixtures/pl.po @@ -0,0 +1,58 @@ +# Polish translation for po2json text fixture. +# +msgid "" +msgstr "" +"Project-Id-Version: po2json\n" +"POT-Creation-Date: 2012-10-26 12:00+0000\n" +"PO-Revision-Date: 2013-11-08 09:09+0200\n" +"Last-Translator: Illimar Tambek <illimar.tambek@gmail.com>\n" +"Language-Team: po2json\n" +"MIME-Version: 1.0\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.5.7\n" +"Language: pl\n" + +#: test.js:1 +msgid "Hello, world!\n" +msgstr "Witaj, świecie!\n" + +#: test.js:2 +msgctxt "string context" +msgid "the contextual phrase" +msgstr "zwrot kontekstowe" + +#: test.js:3 +msgid "" +"this is the first line\n" +"this is the next one\n" +"but this is the last\n" +msgstr "" +"to jest pierwsza linia\n" +"to jest następny\n" +"ale to jest ostatnia\n" + +#: test.js:4 +msgid "one product" +msgid_plural "%d products" +msgstr[0] "jeden produkt" +msgstr[1] "%d produkty" +msgstr[2] "%d produktów" + +#: test.js:5 +msgid "A sentence with \"quotation\" marks." +msgstr "Zdanie w \"cudzysłowie\"." + +#: test.js:6 +#, fuzzy +msgid "A fuzzy translation" +msgstr "Tłumaczenie rozmyta" + +#: test.js:7 +msgid "a product" +msgid_plural "%d products" +msgstr[0] "" +msgstr[1] "" +msgstr[2] "" diff --git a/node_modules/po2json/test/po2json_test.js b/node_modules/po2json/test/po2json_test.js new file mode 100644 index 000000000..4239749b1 --- /dev/null +++ b/node_modules/po2json/test/po2json_test.js @@ -0,0 +1,158 @@ +var po2json = require(".."), + fs = require("fs"), + Jed = require("jed"); + +module.exports["parse"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with Jed format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'jed' }); + test.deepEqual(parsed, this.json); + test.doesNotThrow(function() { new Jed(parsed) }, Error) + test.done(); + } +}; + +module.exports["parse with Jed1.x format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-jed1.x.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'jed1.x' }); + test.deepEqual(parsed, this.json); + test.doesNotThrow(function() { new Jed(parsed) }, Error) + test.done(); + } +}; + +module.exports["parse with MessageFormatter format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/pl-mf.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl-mf.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'mf' }); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with MessageFormatter format + fallback-to-msgid"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-mf-fallback-to-msgid.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'mf', 'fallback-to-msgid': true }); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with fallback-to-msgid"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-empty.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-empty.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { 'fallback-to-msgid': true }); + test.deepEqual(parsed, this.json); + test.done(); + } +} +module.exports["parseFile"] = { + setUp: function(callback){ + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parseFile: function(test){ + var self = this; + po2json.parseFile(__dirname + "/fixtures/pl.po", null, function (err, parsed) { + test.deepEqual(parsed, self.json); + test.done(); + }); + } +} + +module.exports["parseFileSync"] = { + setUp: function(callback){ + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/pl.json", "utf-8")); + callback(); + }, + + parseFileSync: function(test){ + var parsed = po2json.parseFileSync(__dirname + "/fixtures/pl.po"); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with Plural-Forms == nplurals=1; plural=0;"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/ja.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/ja.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with Plural-Forms == nplurals=1; plural=0; and with Jed1.x format"] = { + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/ja.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/ja-jed1.x.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po, { format: 'jed1.x' }); + test.deepEqual(parsed, this.json); + test.done(); + } +} + +module.exports["parse with no headers"] ={ + setUp: function(callback){ + this.po = fs.readFileSync(__dirname + "/fixtures/en-no-header.po"); + this.json = JSON.parse(fs.readFileSync(__dirname + "/fixtures/en-no-header.json", "utf-8")); + callback(); + }, + + parse: function(test){ + var parsed = po2json.parse(this.po); + test.deepEqual(parsed, this.json); + test.done(); + } +} |