Comparing version 0.8.1 to 0.8.2
52
i18n.js
@@ -6,3 +6,3 @@ /** | ||
* | ||
* @version 0.8.1 | ||
* @version 0.8.2 | ||
*/ | ||
@@ -70,3 +70,3 @@ | ||
i18n.version = '0.8.1'; | ||
i18n.version = '0.8.2'; | ||
@@ -376,24 +376,4 @@ i18n.configure = function i18nConfigure(opt) { | ||
// test for parsable interval string | ||
if ((/\|/).test(msg)) { | ||
msg = parsePluralInterval(msg, count); | ||
} | ||
// replace the counter | ||
// parses translation and replaces all digets '%d' by `count` | ||
// this also replaces extra strings '%%s' to parseble '%s' for last step | ||
msg = vsprintf(msg, [parseInt(count, 10)]); | ||
// if the msg string contains {{Mustache}} patterns we render it as a mini tempalate | ||
if ((/{{.*}}/).test(msg)) { | ||
msg = Mustache.render(msg, namedValues); | ||
} | ||
// if we have extra arguments with strings to get replaced, | ||
// an additional substition injects those strings afterwards | ||
if ((/%/).test(msg) && args && args.length > 0) { | ||
msg = vsprintf(msg, args); | ||
} | ||
return msg; | ||
// head over to postProcessing | ||
return postProcess(msg, namedValues, args, count); | ||
}; | ||
@@ -546,4 +526,3 @@ | ||
var postProcess = function(msg, namedValues, args, counter) { | ||
var count = counter || false; | ||
var postProcess = function(msg, namedValues, args, count) { | ||
@@ -556,3 +535,3 @@ // test for parsable interval string | ||
// replace the counter | ||
if (count) { | ||
if (typeof count === 'number') { | ||
msg = vsprintf(msg, [parseInt(count, 10)]); | ||
@@ -711,5 +690,7 @@ } | ||
var acceptedLanguageIndex = acceptedLanguages.indexOf(lang); | ||
if (acceptedLanguages.indexOf(fallback) < 0) { | ||
acceptedLanguages.splice(acceptedLanguageIndex + 1, 0, fallback); | ||
var fallbackIndex = acceptedLanguages.indexOf(fallback); | ||
if(fallbackIndex > -1) { | ||
acceptedLanguages.splice(fallbackIndex, 1); | ||
} | ||
acceptedLanguages.splice(acceptedLanguageIndex + 1, 0, fallback); | ||
} | ||
@@ -1025,2 +1006,6 @@ | ||
}; | ||
// Fix object path. | ||
var fixObject = function() { | ||
return {}; | ||
}; | ||
// Are we going to need to re-traverse the tree when the mutator is invoked? | ||
@@ -1037,2 +1022,6 @@ var reTraverse = false; | ||
if (allowBranching) { | ||
// Fix `object` if `object` is not Object. | ||
if (null === object || typeof object !== 'object') { | ||
object = fixObject(); | ||
} | ||
// If we are allowed to, create a new object along the path. | ||
@@ -1052,2 +1041,7 @@ object[index] = {}; | ||
}; | ||
// Generate a fixer for the current level. | ||
fixObject = function() { | ||
object[index] = {}; | ||
return object[index]; | ||
}; | ||
@@ -1054,0 +1048,0 @@ // Return a reference to the next deeper level in the locale tree. |
{ | ||
"name": "i18n", | ||
"description": "lightweight translation module with dynamic json storage", | ||
"version": "0.8.1", | ||
"version": "0.8.2", | ||
"homepage": "http://github.com/mashpie/i18n-node", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -400,3 +400,3 @@ # i18n | ||
"one": "%d кошка", | ||
"few": "%d или", | ||
"few": "%d кошки", | ||
"many": "%d кошек", | ||
@@ -413,3 +413,3 @@ "other": "%d кошка", | ||
__n('%s cat', 1); // --> 1 кошка | ||
__n('%s cat', 2); // --> 2 или | ||
__n('%s cat', 2); // --> 2 кошки | ||
__n('%s cat', 5); // --> 5 кошек | ||
@@ -458,3 +458,3 @@ __n('%s cat', 6); // --> 6 кошек | ||
// fr --> 2 chat | ||
// ru --> 2 или ru uses "__few__" when ending on "1" | ||
// ru --> 2 кошки ru uses "__few__" when ending on "1" | ||
@@ -952,2 +952,4 @@ // results for "5" in (most use "others") | ||
* 0.8.2: | ||
* __fixed__: typos, objectNotation mutator #226, accept-language headers with fallback #228 | ||
* 0.8.1: | ||
@@ -954,0 +956,0 @@ * __hotfix__: fixes `i18n.setLocale()` recursion bug on nested res-/req-objects [sails#3631](https://github.com/balderdashy/sails/pull/3631) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1017
320009
1414