Installations
npm install jed-gettext-parser
Releases
Unable to fetch releases
Developer
Ortham
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.14.2
NPM Version
9.5.0
Statistics
14 Stars
99 Commits
6 Forks
3 Watching
1 Branches
2 Contributors
Updated on 12 Nov 2024
Languages
JavaScript (96.13%)
HTML (2.5%)
Shell (1.37%)
Total Downloads
Cumulative downloads
Total Downloads
100,561
Last day
-11.1%
24
Compared to previous day
Last week
75.7%
181
Compared to previous week
Last month
56.8%
552
Compared to previous month
Last year
-12%
5,622
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
5
Jed Gettext Parser
JavaScript Gettext .mo
file parsing for Jed.
Introduction
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.
Jed provides a very nice interface for translation using Gettext in Javascript.
Jed doesn't supply Gettext translation file parsers, so this library can act as the bridge between Gettext binary files and Jed.
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.
Install
Jed Gettext Parser can be loaded as a browser global, an AMD module, or in Node. It requires support for:
Node.js supports both since version 11.0.0.
Browser Global
<script src="jedGettextParser.js"></script>
<script>
// Use jedGettextParser
</script>
AMD Module
require(['jedGettextParser'], function(jedGettextParser) {
// Use jedGettextParser
});
Node
npm install jed-gettext-parser
var jedGettextParser = require('jed-gettext-parser');
// Use jedGettextParser
Usage
Once you've loaded Jed and Jed Gettext Parser, they can can be used together:
var moBuffer = new ArrayBuffer();
// Fill the moBuffer with the contents of a .mo file in whatever way you like.
// locale_data is an object holding locale data as expected by Jed.
var locale_data = jedGettextParser.mo.parse(moBuffer);
// Now load using Jed.
var i18n = new Jed({
'locale_data': locale_data,
'domain': 'messages'
});
API
The library currently exposes only one function:
var data = jedGettextParser.mo.parse(buffer[, options]);
data
: an object that can be used as the value of Jed'slocale_data
initialisation option.buffer
: anArrayBuffer
object that holds the contents of the.mo
file to parse.options
: an object that can be optionally provided to specify some settings.
The options
object has the following structure (default values given):
var options = {
encoding: undefined,
domain: 'messages'
}
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.domain
: The domain under which the translation data should be stored.
If an issue is encountered during parsing, an Error
object describing the problem will be thrown.
Motivation
There 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.
While developing a Chromium Embedded Framework-based application (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, and it's Node-only, so I wrote this little library.
I used gettext-parser to cross-check my understanding of the Gettext mo file spec, and as inspiration for this library's API, so thanks to Andris Reinman for writing it.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
9 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Reason
Found 0/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/Ortham/jed-gettext-parser/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/Ortham/jed-gettext-parser/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:38
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 5 are checked with a SAST tool
Score
2.9
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to jed-gettext-parser
jed
Gettext Style i18n for Modern JavaScript Apps
tannin
gettext localization library compatible with Jed-formatted locale data
gettext-parser
Parse and compile gettext po and mo files to/from json, nothing more, nothing less
node-gettext
A JavaScript implementation of gettext, a localization framework