New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18n-abide

Package Overview
Dependencies
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-abide - npm Package Compare versions

Comparing version 0.0.8-beta5 to 0.0.8-beta8

74

lib/i18n.js

@@ -51,2 +51,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public

options = options || {};
if (! options.gettext_alias) options.gettext_alias = 'gettext';

@@ -60,15 +61,11 @@ if (! options.supported_languages) options.supported_languages = ['en-US'];

var existsSync = fs.existsSync || path.existsSync;
logger = options.logger;
var json_file_path = function(locale) {
return path.resolve(
path.join(__dirname, '..', '..', '..'),
options.translation_directory,
path.join(locale, 'messages.json'));
},
debug_locale = localeFrom(options.debug_lang);
function json_file_path(locale) {
return path.resolve(path.join(__dirname, '..', '..', '..'),
options.translation_directory,
path.join(locale, 'messages.json'));
}
options.supported_languages.forEach(function(lang, i) {
options.supported_languages.forEach(function(lang) {
var l = localeFrom(lang);

@@ -79,13 +76,4 @@

try {
// TODO: Have po2json write json files, not .js files
// also https://github.com/mozilla/i18n-abide/issues/15
var rawMessages = fs.readFileSync(json_file_path(l)).toString();
if (rawMessages.length < JS_PRE_LEN + JS_POST_LEN + 1) {
throw new Error('Bad Locale messages.json ' + l);
}
// Chop JSON out of the middle of a JavaScript formatted file
var json_locale_data = JSON.parse(
rawMessages.slice(JS_PRE_LEN, rawMessages.length - JS_POST_LEN));
translations[l] = json_locale_data.messages;
translations[l] = JSON.parse(rawMessages).messages;
} catch (e) {

@@ -118,7 +106,5 @@ // an exception here means that there was a problem with the translation

console.log(langs);
if (lang && lang.toLowerCase && lang.toLowerCase() === debug_lang) {
// What? http://www.youtube.com/watch?v=rJLnGjhPT1Q
lang = DAVID_B_LABYRN;
// What? http://www.youtube.com/watch?v=rJLnGjhPT1Q
lang = DAVID_B_LABYRN;
}

@@ -131,3 +117,3 @@ // Express 2 support

} else {
Object.keys(args).forEach(function(key, i) {
Object.keys(args).forEach(function(key) {
resp.local(key, args[key]);

@@ -166,3 +152,3 @@ });

// default lang in a non gettext environment... fake it
gt = function(a, b) { return a; };
gt = function(a) { return a; };
}

@@ -197,20 +183,20 @@ locals[options.gettext_alias] = gt;

exports.parseAcceptLanguage = parseAcceptLanguage = function(header) {
// pl,fr-FR;q=0.3,en-US;q=0.1
if (! header || ! header.split) {
return [];
// pl,fr-FR;q=0.3,en-US;q=0.1
if (! header || ! header.split) {
return [];
}
var raw_langs = header.split(',');
var langs = raw_langs.map(function(raw_lang) {
var parts = raw_lang.split(';');
var q = 1;
if (parts.length > 1 && parts[1].indexOf('q=') === 0) {
var qval = parseFloat(parts[1].split('=')[1]);
if (isNaN(qval) === false) {
q = qval;
}
}
var raw_langs = header.split(',');
var langs = raw_langs.map(function(raw_lang) {
var parts = raw_lang.split(';');
var q = 1;
if (parts.length > 1 && parts[1].indexOf('q=') === 0) {
var qval = parseFloat(parts[1].split('=')[1]);
if (isNaN(qval) === false) {
q = qval;
}
}
return { lang: parts[0].trim(), quality: q };
});
langs.sort(qualityCmp);
return langs;
return { lang: parts[0].trim(), quality: q };
});
langs.sort(qualityCmp);
return langs;
};

@@ -245,3 +231,3 @@

if (! language || ! language.split) {
return "";
return "";
}

@@ -248,0 +234,0 @@ var parts = language.split('-');

@@ -5,3 +5,3 @@ {

"description": "Express/connect module for Node i18n and l10n support",
"version": "0.0.8beta5",
"version": "0.0.8beta8",
"homepage": "https://github.com/mozilla/i18n-abide",

@@ -22,3 +22,3 @@ "repository": {

"gobbledygook": "0.0.3",
"jsxgettext": "0.0.5",
"jsxgettext": "0.1.2",
"optimist": "0.3.4"

@@ -25,0 +25,0 @@ },

@@ -12,8 +12,22 @@ # i18n-abide

This module is under development, currently being extracted from [BrowserID](https://github.com/mozilla/browserid).
This module is under development, but frozen parts of it power the [Mozilla Persona](https://github.com/mozilla/browserid) service in 40+ languages.
# Pre-requisites
# Tutorial
Mozilla Hacks blog has a three part introduction.
* [Localize Your Node.js Service](https://hacks.mozilla.org/2013/04/localize-your-node-js-service-part-1-of-3-a-node-js-holiday-season-part-9/)
* [Localization community, tools & process](https://hacks.mozilla.org/2013/04/localization-community-tools-process-part-2-of-3-a-node-js-holiday-season-part-10/)
* [Localization in Action](https://hacks.mozilla.org/2013/04/localization-in-action-part-3-of-3-a-node-js-holiday-season-part-11/)
# Pre-requisites for Developers
`npm install` has got your back
# Pre-requisites for String Wranglers
You should install Gnu gettext to get msginit, xgettext, and other tools.
What is a string wrangler? A person or an automated build process that will merge and delete strings between releases.
# Usage

@@ -136,2 +150,2 @@

See docs/USAGE.md for full details.
See docs/USAGE.md for full details.

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc