{"id":19339693,"url":"https://github.com/rubenv/pofile","last_synced_at":"2025-04-04T10:05:20.525Z","repository":{"id":12661785,"uuid":"15333625","full_name":"rubenv/pofile","owner":"rubenv","description":"Parse and serialize Gettext PO files.","archived":false,"fork":false,"pushed_at":"2023-10-27T19:47:56.000Z","size":282,"stargazers_count":64,"open_issues_count":8,"forks_count":25,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-28T09:03:25.242Z","etag":null,"topics":["gettext","javascript","nodejs","po-files"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubenv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-20T08:34:53.000Z","updated_at":"2024-09-26T13:57:37.000Z","dependencies_parsed_at":"2022-08-31T04:22:49.234Z","dependency_job_id":"cd23123d-d583-4b01-9805-7853a1067267","html_url":"https://github.com/rubenv/pofile","commit_stats":{"total_commits":150,"total_committers":25,"mean_commits":6.0,"dds":"0.43999999999999995","last_synced_commit":"9bd87ca6e7e54d0735eeff7742e1123c0029b6b7"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpofile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpofile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpofile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpofile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenv","download_url":"https://codeload.github.com/rubenv/pofile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247151390,"owners_count":20892320,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gettext","javascript","nodejs","po-files"],"created_at":"2024-11-10T03:23:25.400Z","updated_at":"2025-04-04T10:05:20.486Z","avatar_url":"https://github.com/rubenv.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pofile - gettext .po parsing for JavaScript\n\n\u003e Parse and serialize Gettext PO files.\n\n[![Build Status](https://travis-ci.org/rubenv/pofile.png?branch=master)](https://travis-ci.org/rubenv/pofile)\n\n## Usage\nAdd pofile to your project:\n\n### Installation (Node.JS, browser via Browserified)\n```\nnpm install --save pofile\n```\n\nReference it in your code:\n\n```js\nvar PO = require('pofile');\n```\n\n### Installation (via bower)\n```\nbower install --save pofile\n```\n\nAdd it to your HTML file:\n\n```html\n\u003cscript src=\"bower_components/pofile/dist/pofile.js\"\u003e\u003c/script\u003e\n```\n\nReference it in your code:\n\n```js\nvar PO = require('pofile');\n```\n\n### Loading and parsing\n\nYou can create a new empty PO file by using the class:\n\n```js\nvar po = new PO();\n```\n\nOr by loading a file (Node.JS only):\n\n```js\nPO.load('text.po', function (err, po) {\n    // Handle err if needed\n    // Do things with po\n});\n```\n\nOr by parsing a string:\n\n```js\nvar po = PO.parse(myString);\n```\n\n### The PO class\n\nThe `PO` class exposes three members:\n\n* `comments`: An array of comments (found at the header of the file).\n* `headers`: A dictionary of the headers.\n* `items`: An array of `PO.Item` objects, each of which represents a string\n  from the gettext catalog.\n\nThere are two methods available:\n\n* `save`: Accepts a filename and callback, writes the po file to disk.\n\n```js\npo.save('out.po', function (err) {\n    // Handle err if needed\n});\n```\n\n* `toString`: Serializes the po file to a string.\n\n### The PO.Item class\n\nThe `PO.Item` class exposes the following members:\n\n* `msgid`: The message id.\n* `msgid_plural`: The plural message id (null if absent).\n* `msgstr`: An array of translated strings. Items that have no plural msgid\n  only have one element in this array.\n* `references`: An array of reference strings.\n* `comments`: An array of string translator comments.\n* `extractedComments`: An array of string extracted comments.\n* `flags`: A dictionary of the string flags. Each flag is mapped to a key with\n  value true. For instance, a string with the fuzzy flag set will have\n  `item.flags.fuzzy == true`.\n* `msgctxt`: Context of the message, an arbitrary string, can be used for disambiguation.\n\n\n## Contributing\n\nIn lieu of a formal styleguide, take care to maintain the existing coding\nstyle. Add unit tests for any new or changed functionality. Lint and test your\ncode using [Grunt](http://gruntjs.com/).\n\n## Credits\n\nOriginally based on node-po (written by Michael Holly). Rebranded because\nnode-po is unmaintained and because this library is no longer limited to\nNode.JS: it works in the browser too.\n\n### Changes compared to node-po\n\n* Proper handling of async methods that won't crash your Node.JS process when\n  something goes wrong.\n* Support for parsing string flags (e.g. fuzzy).\n* A test suite.\n* Browser support (through Browserified and bower).\n\n### Migrating from node-po\n\nYou'll need to update the module reference: `require('pofile')` instead of\n`require('node-po')`.\n\nAt the initial release, node-po and pofile have identical APIs, with one small\nexception: the `save` and `load` methods now take a callback that has an `err`\nparameter: `(err)` for `save` and `(err, po)` for `load`. This is similar to\nNode.JS conventions.\n\nChange code such as:\n\n```js\nPO.load('text.po', function (po) {\n```\n\nTo:\n\n```js\nPO.load('text.po', function (err, po) {\n    // Handle err if needed\n```\n\n## License \n\n    (The MIT License)\n\n    Copyright (C) 2013-2017 by Ruben Vermeersch \u003cruben@rocketeer.be\u003e\n    Copyright (C) 2012 by Michael Holly\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpofile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenv%2Fpofile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpofile/lists"}