Comparing version 2.0.0 to 2.1.0
@@ -65,6 +65,6 @@ "use strict"; | ||
args = getArgs(startOfArgs, arguments) || []; | ||
if (!namedValues || startOfArgs === 3) { | ||
if (startOfArgs === 3 || typeof namedValues !== "object" || namedValues === null ) { | ||
namedValues = {}; | ||
} | ||
namedValues.count = count; | ||
namedValues.count = count; | ||
args.unshift(count); | ||
@@ -71,0 +71,0 @@ if (count > 1) { |
{ | ||
"name": "i18n-core", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Basic i18n translation.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -45,2 +45,4 @@ # i18n-core | ||
## Lookups | ||
The system is based on `lookup` implementations that allow the system to use different sources to get its strings from. The examples before used an object and because of this the former example would be equal to: | ||
@@ -58,3 +60,3 @@ | ||
Then it would be equal the primitive file-system lookup same like this: | ||
Then it would be equal the primitive **file-system** lookup same like this: | ||
@@ -76,3 +78,3 @@ ```JavaScript | ||
In case you need to have several strategies that need to be chained you can use | ||
the chain lookup: | ||
the **chain lookup**: | ||
@@ -87,2 +89,18 @@ ```JavaScript | ||
In case you have an `i18n` object that you want to use as lookup for another `i18` object you can **extend** them: | ||
```JavaScript | ||
var i18nExtend = require("i18n-core/lookup/extend") | ||
var i18nObject = require("i18n-core/lookup/object") | ||
var i18nA = i18n({a: "x"}) | ||
var i18nB = i18n(i18nExtend(i18nA, i18nObject({ | ||
b: 1 | ||
}))) | ||
i18n.__('a') // x | ||
i18n.__('b') // 1 | ||
``` | ||
## Substitution | ||
*i18n-core* does implement basic placeholder replacements like: | ||
@@ -102,2 +120,5 @@ | ||
## Advanced Namespaces | ||
It is possible to chain translation prefixes like this: | ||
@@ -139,2 +160,4 @@ | ||
## Outro | ||
If you have any questions, please post them as issue, thanks! |
@@ -6,3 +6,5 @@ "use strict"; | ||
fs = require("../../lookup/fs"), | ||
expect = code.expect; | ||
path = require("path"), | ||
expect = code.expect, | ||
folder = path.join(__dirname, 'fs'); | ||
@@ -17,2 +19,7 @@ test("custom strategy", function (done) { | ||
test("missing file lookup", function (done) { | ||
expect(fs(folder).get("de.b")).to.equal(undefined); | ||
done(); | ||
}); | ||
test("undefined subkey", function (done) { | ||
@@ -28,3 +35,3 @@ var strategy = {}, | ||
var strategy = {}, | ||
lookup = fs(__dirname); | ||
lookup = fs(folder); | ||
@@ -38,3 +45,3 @@ expect(lookup.get("en.b")).to.equal("c"); | ||
var strategy = {}, | ||
lookup = fs(__dirname); | ||
lookup = fs(folder); | ||
@@ -47,3 +54,3 @@ expect(lookup.get("ja.d")).to.equal(undefined); | ||
var strategy = require("../../lookup/folder/json"), | ||
lookup = fs(__dirname, strategy); | ||
lookup = fs(folder, strategy); | ||
strategy.load = function () { return null; }; | ||
@@ -78,3 +85,3 @@ | ||
mockery.registerMock("fs", existsMock); | ||
var lookup = require("../../lookup/fs")(__dirname); | ||
var lookup = require("../../lookup/fs")(folder); | ||
expect(lookup.get("en")).to.equal(undefined); | ||
@@ -86,3 +93,3 @@ done(); | ||
mockery.registerMock("fs", readMock); | ||
var lookup = require("../../lookup/fs")(__dirname); | ||
var lookup = require("../../lookup/fs")(folder); | ||
expect(lookup.get("en")).to.equal(undefined); | ||
@@ -89,0 +96,0 @@ done(); |
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
27232
22
737
158