node-gettext
Advanced tools
Comparing version 0.2.6 to 0.2.7
{ | ||
"name": "node-gettext", | ||
"description": "Gettext client for Node.js to use .mo files for I18N", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"author" : "Andris Reinman", | ||
@@ -28,3 +28,3 @@ "maintainers":[ | ||
"dependencies": { | ||
"iconv":"*" | ||
"iconv":"1.1.3" | ||
}, | ||
@@ -31,0 +31,0 @@ "devDependencies": { |
@@ -30,16 +30,28 @@ # node-gettext | ||
### Add a language - addTextdomain(domain, file) | ||
### Add a language | ||
Language data needs to be file contents in the Buffer format (can be either a .MO or .PO file) | ||
*addTextdomain(domain, file)* | ||
*addTextdomain(domain[, file_contents])* | ||
Language data needs to be in the Buffer format - it can be either contents of a *MO* or *PO* file. | ||
var file_contents = fs.readFileSync("et.mo"); | ||
gt.addTextdomain("et", file_contents); | ||
*addTextdomain(domain[, fileContents])* | ||
or load a .PO file | ||
Load from a *MO* file | ||
var file_contents = fs.readFileSync("et.po"); | ||
gt.addTextdomain("et", file_contents); | ||
var fileContents = fs.readFileSync("et.mo"); | ||
gt.addTextdomain("et", fileContents); | ||
or load from a *PO* file | ||
var fileContents = fs.readFileSync("et.po"); | ||
gt.addTextdomain("et", fileContents); | ||
If you do not include the file contents, then a blank language template object | ||
is created which can be edited with *setTranslation*, *deleteTranslation* methods etc. | ||
Plural rules are automatically detected from the language code | ||
gt.addTextdomain("et"); | ||
gt.setTranslation("et", false, "hello!", "tere!"); | ||
### Check or change default language | ||
@@ -55,2 +67,4 @@ | ||
## Translation methods | ||
### Load a string from default language file | ||
@@ -124,3 +138,3 @@ | ||
The parameters for the gettext functions are the same as with regular gettext objects, except that the `msgid` parameter is not needed. | ||
The parameters for the gettext functions are the same as with regular gettext methods, except that the `msgid` parameter is not needed. | ||
@@ -135,9 +149,13 @@ ## Manage translations | ||
Use an array for plurals | ||
gt.setTranslation("et", "", "%s comments", ["%s kommentaar", "%s kommentaari"]); | ||
### Remove a translation | ||
*deleteTranslation(domain, context, msgid, translation)* | ||
*deleteTranslation(domain, context, msgid)* | ||
gt.setTranslation("et", "", "Hello", "Tere"); | ||
gt.deleteTranslation("et", "", "Hello"); | ||
### List possible context names | ||
### List available contexts | ||
@@ -148,3 +166,3 @@ *listContextNames([domain])* | ||
### List possible translation keys | ||
### List translation keys for a context | ||
@@ -157,5 +175,5 @@ *listKeys([domain], [context])* | ||
## Compile MO | ||
### Compile to MO | ||
Compile current translation table to a MO file | ||
Compile current translation table to a *MO* file | ||
@@ -166,5 +184,5 @@ *compileMO([domain])* | ||
## Compile PO | ||
### Compile to PO | ||
Compile current translation table to a PO file | ||
Compile current translation table to a *PO* file | ||
@@ -171,0 +189,0 @@ *compilePO([domain])* |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
87339
0
188
1
+ Addediconv@1.1.3(transitive)
- Removediconv@3.0.1(transitive)
Updatediconv@1.1.3