Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

internationalization

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

internationalization - npm Package Compare versions

Comparing version 0.0.6 to 0.0.7

28

index.js
// Generated by CoffeeScript 1.8.0
(function() {
var Template, bundleAsJavascript, debug, findBestMatch, fs, getAcceptLanguage, javascript, langs, load, loadSingle, middleware, parse, path, templateCache, translate, translatePlural,
var Template, bundleAsJavascript, debug, findBestMatch, fs, getAcceptLanguage, javascript, langs, load, loadSingle, middleware, parse, path, setLangs, templateCache, translate, translatePlural,
__slice = [].slice;

@@ -54,2 +54,6 @@

setLangs = function(dict) {
return langs = dict;
};
getAcceptLanguage = function(header) {

@@ -89,9 +93,14 @@ return header.split(',').map(function(item) {

translate = function() {
var key, lang, template, vars, _ref, _ref1;
var idx, key, lang, template, vars, _ref, _ref1, _ref2, _ref3;
lang = arguments[0], key = arguments[1], vars = 3 <= arguments.length ? __slice.call(arguments, 2) : [];
template = ((_ref = langs[lang]) != null ? _ref[key] : void 0) || key;
idx = key.indexOf(":");
if (idx !== -1) {
template = ((_ref = langs[lang]) != null ? (_ref1 = _ref[key.substr(0, idx)]) != null ? _ref1[key.substr(idx + 1)] : void 0 : void 0) || key.substr(idx + 1);
} else {
template = ((_ref2 = langs[lang]) != null ? _ref2[key] : void 0) || key;
}
if (!vars.length) {
return template;
}
if (!template in templateCache) {
if (!(template in templateCache)) {
templateCache[template] = new Template(template);

@@ -102,3 +111,3 @@ }

} else {
return (_ref1 = templateCache[template]).render.apply(_ref1, vars);
return (_ref3 = templateCache[template]).render.apply(_ref3, [null].concat(__slice.call(vars)));
}

@@ -116,3 +125,3 @@ };

middleware = function(_arg) {
var cookie, directory, fallback, _langs;
var cookie, directory, env, fallback, _langs;
cookie = _arg.cookie, directory = _arg.directory, fallback = _arg.fallback;

@@ -122,2 +131,3 @@ if (!directory) {

}
env = process.env.NODE_ENV || "development";
if (cookie == null) {

@@ -136,2 +146,5 @@ cookie = 'lang';

var lang;
if (env === "development") {
load(directory);
}
if (req.query['set-lang']) {

@@ -223,5 +236,6 @@ lang = req.query['set-lang'];

findBestMatch: findBestMatch,
bundleAsJavascript: bundleAsJavascript
bundleAsJavascript: bundleAsJavascript,
setLangs: setLangs
};
}).call(this);
{
"name": "internationalization",
"version": "0.0.6",
"version": "0.0.7",
"description": "i18n",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -15,6 +15,9 @@ # internationalization

files under then same directory will be merged(file name does not matter)
```
locales
├── en
│   └── index.ini
│   ├── foo.ini
│   └── bar.ini
└── zh

@@ -38,2 +41,13 @@ └── index.ini

### namespace
```jade
span= _("profile:Hello {username}", {username: username})
```
```ini
[profile]
Hello {username} = Guten Tag {username}
```
## generate/update language files(TBD)

@@ -40,0 +54,0 @@

Sorry, the diff of this file is not supported yet

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