{"id":17279684,"url":"https://github.com/ortham/jed-gettext-parser","last_synced_at":"2025-12-12T04:02:14.306Z","repository":{"id":20479987,"uuid":"23757925","full_name":"Ortham/jed-gettext-parser","owner":"Ortham","description":"JavaScript gettext .mo file parsing for Jed.","archived":false,"fork":false,"pushed_at":"2023-03-03T17:36:46.000Z","size":167,"stargazers_count":14,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T03:18:07.078Z","etag":null,"topics":[],"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/Ortham.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2014-09-07T10:59:49.000Z","updated_at":"2024-11-12T11:49:33.000Z","dependencies_parsed_at":"2023-07-13T15:16:40.061Z","dependency_job_id":null,"html_url":"https://github.com/Ortham/jed-gettext-parser","commit_stats":{"total_commits":92,"total_committers":5,"mean_commits":18.4,"dds":0.5978260869565217,"last_synced_commit":"0992d8fe4a536f007ffc54a5bc98e89b6f2edf0a"},"previous_names":["wrinklyninja/jed-gettext-parser"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fjed-gettext-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fjed-gettext-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fjed-gettext-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ortham%2Fjed-gettext-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ortham","download_url":"https://codeload.github.com/Ortham/jed-gettext-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248848939,"owners_count":21171489,"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":[],"created_at":"2024-10-15T09:18:16.746Z","updated_at":"2025-12-12T04:02:14.007Z","avatar_url":"https://github.com/Ortham.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Jed Gettext Parser\n==================\n\nJavaScript Gettext `.mo` file parsing for [Jed](https://github.com/slexaxton/Jed/).\n\n![CI](https://github.com/Ortham/jed-gettext-parser/workflows/CI/badge.svg?branch=master\u0026event=push)\n\n## Introduction\n\n[Gettext](https://www.gnu.org/software/gettext/) is an old translation standard with implementations in many languages. It's one that localisation-aware programmers and translators are likely to be familiar with.\n\n[Jed](https://github.com/slexaxton/Jed/) provides a very nice interface for translation using Gettext in Javascript.\n\nJed doesn't supply Gettext translation file parsers, so this library can act as the bridge between Gettext binary files and Jed.\n\n*Note: Jed Gettext Parser is made to work with Jed, but is a third-party library. Please direct any support queries to this repository's issue tracker, and [the author](https://github.com/Ortham).*\n\n## Install\n\nJed Gettext Parser can be loaded as a browser global, an AMD module, or in Node. It requires support for:\n\n* [Typed Arrays](http://caniuse.com/#feat=typedarrays) ([polyfill](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js))\n* [Encoding API](http://caniuse.com/#feat=textencoder) ([polyfill](https://github.com/inexorabletash/text-encoding))\n\nNode.js supports both since version 11.0.0.\n\n##### Browser Global\n\n```\n\u003cscript src=\"jedGettextParser.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n// Use jedGettextParser\n\u003c/script\u003e\n```\n\n##### AMD Module\n\n```\nrequire(['jedGettextParser'], function(jedGettextParser) {\n    // Use jedGettextParser\n});\n```\n\n##### Node\n\n```\nnpm install jed-gettext-parser\n```\n\n```\nvar jedGettextParser = require('jed-gettext-parser');\n// Use jedGettextParser\n```\n\n## Usage\n\nOnce you've loaded Jed and Jed Gettext Parser, they can can be used together:\n\n```\nvar moBuffer = new ArrayBuffer();\n// Fill the moBuffer with the contents of a .mo file in whatever way you like.\n\n// locale_data is an object holding locale data as expected by Jed.\nvar locale_data = jedGettextParser.mo.parse(moBuffer);\n\n// Now load using Jed.\nvar i18n = new Jed({\n    'locale_data': locale_data,\n    'domain': 'messages'\n});\n```\n\n#### API\n\nThe library currently exposes only one function:\n\n```\nvar data = jedGettextParser.mo.parse(buffer[, options]);\n```\n\n* `data`: an object that can be used as the value of Jed's `locale_data` initialisation option.\n* `buffer`: an `ArrayBuffer` object that holds the contents of the `.mo` file to parse.\n* `options`: an object that can be optionally provided to specify some settings.\n\nThe `options` object has the following structure (default values given):\n\n```\nvar options = {\n    encoding: undefined,\n    domain: 'messages'\n}\n```\n\n* `encoding`: The encoding to use when reading the `.mo` file. If undefined, the encoding given in the `.mo` file will be used. Otherwise, valid values are those given in the [Encoding API specification](http://encoding.spec.whatwg.org/#names-and-labels).\n* `domain`: The domain under which the translation data should be stored.\n\nIf an issue is encountered during parsing, an `Error` object describing the problem will be thrown.\n\n## Motivation\n\nThere are two types of Gettext translation files: the `.po` files contain human-readable text that can be easily edited by translators, and the `.mo` files contain equivalent binary data. Some Gettext implementations use one, the other, or both.\n\nWhile developing a [Chromium Embedded Framework](https://code.google.com/p/chromiumembedded)-based application ([LOOT](github.com/loot/loot)) which required localisation of strings in the C++ and the Javascript code, I decided that parsing the `.mo` localisation files in each language separately was the neatest and simplest way of achieving this. The only Javascript `.mo` file parser I could find was [gettext-parser](https://github.com/andris9/gettext-parser), and it's Node-only, so I wrote this little library.\n\nI used [gettext-parser](https://github.com/andris9/gettext-parser) to cross-check my understanding of the Gettext mo file [spec](https://www.gnu.org/software/gettext/manual/html_node/MO-Files.html), and as inspiration for this library's API, so thanks to Andris Reinman for writing it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortham%2Fjed-gettext-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fortham%2Fjed-gettext-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fortham%2Fjed-gettext-parser/lists"}