pax_global_header00006660000000000000000000000064127777565230014537gustar00rootroot0000000000000052 comment=64ba134fc294d6ad60de3ea487ddc1f76c489a2b po2json-0.4.5/000077500000000000000000000000001277775652300131375ustar00rootroot00000000000000po2json-0.4.5/.gitignore000066400000000000000000000000321277775652300151220ustar00rootroot00000000000000node_modules npm-debug.logpo2json-0.4.5/.npmignore000066400000000000000000000000171277775652300151340ustar00rootroot00000000000000/node_modules/ po2json-0.4.5/.travis.yml000066400000000000000000000001101277775652300152400ustar00rootroot00000000000000language: node_js node_js: - 6 - 5 - 4 - 0.12 - 0.11 - 0.10 po2json-0.4.5/AUTHORS000066400000000000000000000004571277775652300142150ustar00rootroot00000000000000# Authors ordered by first contribution. Illimar Tambek Mike Edwards gilles Asbjørn Sloth Tønnesen Zach Carter Dan MacTough Evan Moses Dima Kurguzov po2json-0.4.5/History.md000066400000000000000000000060211277775652300151210ustar00rootroot000000000000000.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) po2json-0.4.5/LICENSE000066400000000000000000000024151277775652300141460ustar00rootroot00000000000000Pure Javascript implementation of Uniforum message translation. Copyright (C) 2008 Joshua I. Miller , 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 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 po2json-0.4.5/README.md000066400000000000000000000165741277775652300144330ustar00rootroot00000000000000# po2json [![Build Status](https://secure.travis-ci.org/mikeedwards/po2json.png?branch=master)](http://travis-ci.org/mikeedwards/po2json) [![Dependency Status](https://david-dm.org/mikeedwards/po2json.png?theme=shields.io)](https://david-dm.org/mikeedwards/po2json) [![devDependency Status](https://david-dm.org/mikeedwards/po2json/dev-status.png?theme=shields.io)](https://david-dm.org/mikeedwards/po2json#info=devDependencies) [![NPM](https://nodei.co/npm/po2json.png)](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. po2json-0.4.5/bin/000077500000000000000000000000001277775652300137075ustar00rootroot00000000000000po2json-0.4.5/bin/po2json000077500000000000000000000020621277775652300152270ustar00rootroot00000000000000#!/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); po2json-0.4.5/bower.json000066400000000000000000000004031277775652300151450ustar00rootroot00000000000000{ "name": "po2json", "version": "0.3.2", "ignore": [ "**/.*", "test", "lib", "*.md", ".json", ".yml", "package.json", "*.js" ], "keywords": [ "i18n", "l10n", "gettext", "po" ], "license": "LGPL" } po2json-0.4.5/index.js000066400000000000000000000002171277775652300146040ustar00rootroot00000000000000module.exports = { parse: require('./lib/parse'), parseFile: require('./lib/parseFile'), parseFileSync: require('./lib/parseFileSync') };po2json-0.4.5/lib/000077500000000000000000000000001277775652300137055ustar00rootroot00000000000000po2json-0.4.5/lib/parse.js000066400000000000000000000065241277775652300153640ustar00rootroot00000000000000/** * 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; } po2json-0.4.5/lib/parseFile.js000066400000000000000000000011511277775652300161530ustar00rootroot00000000000000var 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 )); }); }); };po2json-0.4.5/lib/parseFileSync.js000066400000000000000000000005301277775652300170100ustar00rootroot00000000000000var 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 ); };po2json-0.4.5/package.json000066400000000000000000000030171277775652300154260ustar00rootroot00000000000000{ "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" } } po2json-0.4.5/test/000077500000000000000000000000001277775652300141165ustar00rootroot00000000000000po2json-0.4.5/test/fixtures/000077500000000000000000000000001277775652300157675ustar00rootroot00000000000000po2json-0.4.5/test/fixtures/en-empty.json000066400000000000000000000021221277775652300204150ustar00rootroot00000000000000{ "": { "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 ", "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" ] }po2json-0.4.5/test/fixtures/en-empty.po000066400000000000000000000016371277775652300200740ustar00rootroot00000000000000# 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 \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 "" po2json-0.4.5/test/fixtures/en-mf-fallback-to-msgid.json000066400000000000000000000006711277775652300231460ustar00rootroot00000000000000{ "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" }po2json-0.4.5/test/fixtures/en-no-header.json000066400000000000000000000000741277775652300211250ustar00rootroot00000000000000{ "Hello World": [ null, "Hello World" ] }po2json-0.4.5/test/fixtures/en-no-header.po000066400000000000000000000000751277775652300205730ustar00rootroot00000000000000# Very minimal .po msgid "Hello World" msgstr "Hello World" po2json-0.4.5/test/fixtures/ja-jed1.x.json000066400000000000000000000004461277775652300203470ustar00rootroot00000000000000{"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"]}}} po2json-0.4.5/test/fixtures/ja.json000066400000000000000000000012501277775652300172520ustar00rootroot00000000000000{ "": { "project-id-version": "VERSION", "po-revision-date": "2016-08-08 14:08+0000", "last-translator": "FULL NAME ", "language-team": "LANGUAGE TEAM ", "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"] ] } po2json-0.4.5/test/fixtures/ja.po000077500000000000000000000012461277775652300167270ustar00rootroot00000000000000msgid "" msgstr "" "Project-Id-Version: VERSION\n" "PO-Revision-Date: 2016-08-08 14:08+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE TEAM \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" po2json-0.4.5/test/fixtures/pl-jed.json000066400000000000000000000020561277775652300200400ustar00rootroot00000000000000{ "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", "", "", "" ] } } } po2json-0.4.5/test/fixtures/pl-jed1.x.json000066400000000000000000000017061277775652300203700ustar00rootroot00000000000000{ "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" ] } } } po2json-0.4.5/test/fixtures/pl-mf.json000066400000000000000000000005271277775652300177010ustar00rootroot00000000000000{ "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" }po2json-0.4.5/test/fixtures/pl-mf.po000066400000000000000000000020421277775652300173400ustar00rootroot00000000000000# 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 \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" po2json-0.4.5/test/fixtures/pl.json000066400000000000000000000022301277775652300172720ustar00rootroot00000000000000{ "": { "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 ", "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", "", "", "" ] } po2json-0.4.5/test/fixtures/pl.po000066400000000000000000000024151277775652300167440ustar00rootroot00000000000000# 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 \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] "" po2json-0.4.5/test/po2json_test.js000066400000000000000000000110331277775652300171030ustar00rootroot00000000000000var 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(); } }