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

node-gettext

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-gettext - npm Package Compare versions

Comparing version 0.2.6 to 0.2.7

4

package.json
{
"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])*

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