{"_id":"i18n-2","_rev":"205526","name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","dist-tags":{"latest":"0.7.3"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"time":{"modified":"2021-06-03T13:14:35.000Z","created":"2013-01-14T22:35:34.282Z","0.7.3":"2018-09-05T18:14:54.097Z","0.7.2":"2017-10-03T20:28:02.203Z","0.7.1":"2017-08-03T23:32:38.882Z","0.7.0":"2017-06-09T11:14:53.736Z","0.6.3":"2016-01-15T08:21:50.287Z","0.6.2":"2015-11-21T20:00:03.955Z","0.6.0":"2015-11-13T13:47:17.401Z","0.4.6":"2014-02-01T15:00:01.292Z","0.4.5":"2013-04-09T01:12:04.633Z","0.4.4":"2013-02-11T18:47:24.410Z","0.4.3":"2013-02-11T00:58:52.105Z","0.4.2":"2013-01-29T17:22:17.122Z","0.4.1":"2013-01-14T23:13:37.199Z","0.4.0":"2013-01-14T22:35:34.282Z"},"users":{"maobean":true,"pav":true,"afzaalace":true,"awzm":true,"paintedbicycle":true,"rwky":true,"hengkiardo":true,"i.vispyanskiy":true,"hecto932":true,"ssljivic":true,"omar84":true,"rapomon":true},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"versions":{"0.7.3":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.7.3","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"debug":"^3.1.0","sprintf-js":"^1.1.1"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"89798524fb2052f6f5df701093c3ed54c1042cd7","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.7.3","_npmVersion":"6.3.0","_nodeVersion":"10.8.0","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"c0dfd7793c7ae2c0d6ea00552dc6ee8651154d25","size":10931,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.7.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.7.3.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/i18n-2_0.7.3_1536171293957_0.19822823308141158"},"_hasShrinkwrap":false,"publish_time":1536171294097,"_cnpm_publish_time":1536171294097},"0.7.2":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.7.2","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"debug":"^3.1.0","sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"9c77e01a772bfa0b86fab8716619860098d90d6f","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.7.2","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"7efb1a7adc67869adea0688951577464aa793aaf","size":11067,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.7.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.7.2.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/i18n-2-0.7.2.tgz_1507062481250_0.6064362993929535"},"publish_time":1507062482203,"_hasShrinkwrap":false,"_cnpm_publish_time":1507062482203},"0.7.1":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.7.1","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"e811754dc5d51f8ff363ce856c25a5cfdcf75dc4","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.7.1","_npmVersion":"5.0.3","_nodeVersion":"8.1.4","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"1c3f2f30c52a33ea28b75e7ca672fe6ce3b3e99b","size":10889,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.7.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.7.1.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/i18n-2-0.7.1.tgz_1501803157865_0.899416972650215"},"publish_time":1501803158882,"_hasShrinkwrap":false,"_cnpm_publish_time":1501803158882},"0.7.0":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.7.0","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"21bdd5cd573dd4ea5a13ecac85bc87e7bcebd639","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.7.0","_shasum":"493bbec27e0ea96df819e8860d08aeca3604a221","_from":".","_npmVersion":"4.2.0","_nodeVersion":"8.0.0","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"493bbec27e0ea96df819e8860d08aeca3604a221","size":10893,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.7.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.7.0.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/i18n-2-0.7.0.tgz_1497006892603_0.946484403219074"},"publish_time":1497006893736,"_cnpm_publish_time":1497006893736,"_hasShrinkwrap":false},"0.6.3":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.6.3","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"b99fd69469d0f014c1a2015800aa206d8ed23998","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.6.3","_shasum":"57ac6185e3ea47cffe993cd7a5c14b40df364b39","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.4.1","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"57ac6185e3ea47cffe993cd7a5c14b40df364b39","size":10850,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.6.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.6.3.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1452846110287,"_cnpm_publish_time":1452846110287,"_hasShrinkwrap":false},"0.6.2":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.6.2","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"bfc1569158e22e586a59c01030b1586e162940c2","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.6.2","_shasum":"d318e3d87eb49b922b0d05d92c61b32f07647836","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.1.0","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"d318e3d87eb49b922b0d05d92c61b32f07647836","size":10837,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.6.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.6.2.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1448136003955,"_cnpm_publish_time":1448136003955,"_hasShrinkwrap":false},"0.6.0":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.6.0","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"git+ssh://git@github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":"^0.1.5"},"devDependencies":{"expresso":">=0.9.2","js-yaml":"^3.4.3"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"license":"MIT","gitHead":"289f9a17114a12e7a0f4c68a5e446b5d81419096","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.6.0","_shasum":"e592912776af0df13543685c4bb4cb287f79ca5e","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.2","_npmUser":{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},"dist":{"shasum":"e592912776af0df13543685c4bb4cb287f79ca5e","size":10713,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.6.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.6.0.tgz"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1447422437401,"_cnpm_publish_time":1447422437401,"_hasShrinkwrap":false},"0.4.6":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.6","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"_id":"i18n-2@0.4.6","dist":{"shasum":"f3d708d5afdddd0133008dd9701a845e415540a7","size":7562,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.6.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.6.tgz"},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1391266801292,"_cnpm_publish_time":1391266801292,"_hasShrinkwrap":false},"0.4.5":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.5","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.5","dist":{"shasum":"98f3be652456f8c746dd6e2ccaf00807adda6812","size":7302,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.5.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.5.tgz"},"_from":".","_npmVersion":"1.2.15","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1365469924633,"_cnpm_publish_time":1365469924633,"_hasShrinkwrap":false},"0.4.4":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.4","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.4","dist":{"shasum":"0007522bbc272856cec7cd11d1d23f562b53458c","size":7177,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.4.tgz"},"_from":".","_npmVersion":"1.2.2","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1360608444410,"_cnpm_publish_time":1360608444410,"_hasShrinkwrap":false},"0.4.3":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.3","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.3","dist":{"shasum":"9e6f960c28048b217aa0cd6cc8c26596b041c56d","size":7188,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.3.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1360544332105,"_cnpm_publish_time":1360544332105,"_hasShrinkwrap":false},"0.4.2":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.2","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.2","dist":{"shasum":"08a8fdf3cf771a985e9962a547dcd39b57719a9d","size":7137,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.2.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1359480137122,"_cnpm_publish_time":1359480137122,"_hasShrinkwrap":false},"0.4.1":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.1","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.1","dist":{"shasum":"ff39c585116e271cfb9dbde53e4be45ec6a23d01","size":7109,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.1.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1358205217199,"_cnpm_publish_time":1358205217199,"_hasShrinkwrap":false},"0.4.0":{"name":"i18n-2","description":"lightweight simple translation module with dynamic json storage","version":"0.4.0","homepage":"http://github.com/jeresig/i18n-node-2","repository":{"type":"git","url":"http://github.com/jeresig/i18n-node-2.git"},"author":{"name":"John Resig","email":"jeresig@gmail.com"},"main":"./index","directories":{"lib":"."},"dependencies":{"sprintf":">=0.1.1"},"devDependencies":{"expresso":">=0.9.2"},"engines":{"node":">=0.4.0"},"scripts":{"test":"expresso test/*"},"readmeFilename":"README.md","_id":"i18n-2@0.4.0","dist":{"shasum":"4a535a28bfed5f29d5b8cd02c356f4353a65eafd","size":7078,"noattachment":false,"key":"/i18n-2/-/i18n-2-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/i18n-2/download/i18n-2-0.4.0.tgz"},"_npmVersion":"1.1.65","_npmUser":{"name":"jeresig","email":"jeresig@gmail.com"},"maintainers":[{"name":"gjuchault","email":"gabriel.juchault@gmail.com"},{"name":"jeresig","email":"jeresig@gmail.com"},{"name":"klicher","email":"kristoffer.lr@gmail.com"}],"publish_time":1358202934282,"_cnpm_publish_time":1358202934282,"_hasShrinkwrap":false}},"readme":"# Node.js: i18n-2\n\n * Designed to work out-of-the-box with Express.js\n * Lightweight simple translation module with dynamic json storage.\n * Uses common __('...') syntax in app and templates.\n * Stores language files in json files compatible to [webtranslateit](http://webtranslateit.com/) json format.\n * Adds new strings on-the-fly when first used in your app.\n * No extra parsing needed.\n\n## Installation\n\nRun the following:\n```\nnpm install i18n-2\n```\n## Simple Example\n\nNote: If you plan on using the module with Express.js, please view [Using with Express.js](#using-with-expressjs), below.\n```javascript\n// Load Module and Instantiate\nvar i18n = new (require('i18n-2'))({\n    // setup some locales - other locales default to the first locale\n    locales: ['en', 'de']\n});\n\n// Use it however you wish\nconsole.log( i18n.__(\"Hello!\") );\n```\n## API:\n\n### `new i18n(options)`\n\nThe `i18n` function is the return result from calling `require('i18n-2')`. You use this to instantiate an `I18n` instance and set any configuration options. You'll probably only do this if you're not using the `expressBind` method.\n\n### `i18n.expressBind(app, options)`\n\nYou'll use this method to attach the i18n functionality to the request object inside Express.js. The app argument should be your Express.js app and the options argument should be the same as if you were calling `new i18n(options)`. See **\"Using with Express.js\"** at the end of this README for more details.\n\n### `__(string, [...])`\n\nTranslates a string according to the current locale. Also supports sprintf syntax, allowing you to replace text, using the node-sprintf module.\n\nFor example:\n```javascript\nvar greeting = i18n.__('Hello %s, how are you today?', 'Marcus');\n```\nthis puts **Hello Marcus, how are you today?**. You might also add endless arguments or even nest it.\n```javascript\nvar greeting = i18n.__('Hello %s, how are you today? How was your %s?',\n    'Marcus', i18n.__('weekend'));\n```\nwhich puts **Hello Marcus, how are you today? How was your weekend?**\n\nYou might even use dynamic variables. They get added to the current locale file if they do not yet exist.\n```javascript\nvar greetings = ['Hi', 'Hello', 'Howdy'];\nfor (var i = 0; i < greetings.length; i++) {\n    console.log( i18n.__(greetings[i]) );\n};\n```\nwhich outputs:\n\n    Hi\n    Hello\n    Howdy\n\nYou can also use nested object :\n```json\n{\n    \"foo\": {\n        \"bar\": \"ok\"\n    }\n}\n```\nAnd use dot notation to access the value :\n```javascript\ni18n.__('foo.bar');\n```\n### `__n(one, other, count, [...])`\n\nDifferent plural forms are supported as a response to `count`:\n```javascript\nvar singular = i18n.__n('%s cat', '%s cats', 1);\nvar plural = i18n.__n('%s cat', '%s cats', 3);\n```\nthis gives you **1 cat** and **3 cats**. As with `__(...)` these could be nested:\n```javascript\nvar singular = i18n.__n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 1, 'tree');\nvar plural = i18n.__n('There is one monkey in the %%s', 'There are %d monkeys in the %%s', 3, 'tree');\n```\nputting **There is one monkey in the tree** or **There are 3 monkeys in the tree**.\n\nYou may also use in your locale object/file :\n```json\n{\n    \"catEat\": {\n        \"one\": \"%d cat eat the %s\",\n        \"other\": \"%d cat eat the %s\"\n    }\n}\n```\nand use `__n()` as you would use `__()` (directly, or from locale) :\n```javascript\nvar singular = i18n.__n('catEat', 1, 'mouse');\nvar plural = i18n.__n('catEat', 10, 'mouse');\n```\n### `getLocale()`\n\nReturns a string containing the current locale. If no locale has been specified then it default to the value specified in `defaultLocale`.\n\n### `setLocale(locale)`\n\nSets a locale to the specified string. If the locale is unknown, the locale defaults to the one specified by `defaultLocale`. For example if you have locales of 'en' and 'de', and a `defaultLocale` of 'en', then call `.setLocale('ja')` it will be equivalent to calling `.setLocale('en')`.\n\n### `setLocaleFromQuery([request])`\n\nTo be used with Express.js or another framework that provides a `request` object. Generally you would want to use this by setting the `query` option to `true`.\n\nThis method takes in an Express.js request object, looks at the query property, and specifically at the `lang` parameter. Reading the value of that parameter will then set the locale.\n\nFor example:\n```\nexample.com/?lang=de\n```\nWill then do:\n```javascript\nsetLocale('de')\n```\n### `setLocaleFromSessionVar([request])`\n\nTo be used with Express.js or another framework that provides a `request` object. Generally you would want to use this by setting the `session` option to `true`.\n\nThis methods takes in an Express.js request object, looks at the variable `locale` (you may override this behaviour by changing the option `sessionVarName`, which defaults to `locale`) contained in the `session` object, and it will set the locale to that value.\n\nFor example, if the session is :\n{ user: { ... }, locale: 'de' }\n\nThen `setLocaleFromSessionVar` will do `setLocale('de')`\n\n### `setLocaleFromSubdomain([request])`\n\nTo be used with Express.js or another framework that provides a `request` object. Generally you would want to use this by setting the `subdomain` option to `true`.\n\nThis method takes in an Express.js request object, looks at the hostname, and extracts the sub-domain. Reading the value of the subdomain the locale is then set.\n\nFor example:\n```\nde.example.com\n```\nWill then do:\n```javascript\nsetLocale('de')\n```\n### `setLocaleFromCookie([request])`\n\nTo be used with Express.js or another framework that provides a `request` object. This method takes a request object, looks at it's cookies property and tries to find a cookie named `cookieName` (default: `lang`).\n\nSee [Using with Express.js](#using-with-expressjs) for a complete example.\n\nFor example:\n```javascript\nconsole.log(req.cookies.lang) //=> 'de'\nsetLocaleFromCookie()\n```\nWill then do:\n```javascript\nsetLocale('de')\n```\n### `setLocaleFromEnvironmentVariable()`\n\nTo be used with some desktop application environment (like [Electron](http://electron.atom.io/) or [NW.js](http://nwjs.io/)) or console. This method tries to get language code from `LANG` environment variable. For example, it get `de` from `de_DE.UTF-8`.\n\nFor example:\n```javascript\nconsole.log(process.env.LANG) //=> 'en_US.UTF-8'\nsetLocaleFromEnvironmentVariable()\n```\nWill then do:\n```javascript\nsetLocale('en')\n```\n### `isPreferredLocale()`\n\nTo be used with Express.js or another framework that provides a `request` object. This method works if a `request` option has been specified when the i18n object was instantiated.\n\nThis method returns true if the locale specified by `getLocale` matches a language desired by the browser's `Accept-language` header.\n\n## Configuration\n\nWhen you instantiate a new i18n object there are a few options that you can pass in. The only required option is `locales`.\n\n### `locales`\n\nYou can pass in the locales in two ways: As an array of strings or as an object of objects. For example:\n```javascript\nlocales: ['en', 'de']\n```\nThis will set two locales (en and de) and read in the JSON contents of both translation files. (By default this is equal to \"./locales/NAME.js\", you can configure this by changing the `directory` and `extension` options.) Additionally when you pass in an array of locales the first locale is automatically set as the `defaultLocale`.\n\nYou can also pass in an object, like so:\n```\nlocales: {\n    \"en\": {\n        \"Hello\": \"Hello\"\n    },\n    \"de\": {\n        \"Hello\": \"Hallo\"\n    }\n}\n```\nIn this particular case no files will ever be read when doing a translation. This is ideal if you are loading your translations from a different source. Note that no `defaultLocale` is set when you pass in an object, you'll need to set it yourself.\n\n### `defaultLocale`\n\nYou can explicitly define a default locale to be used in cases where `.setLocale(locale)` is used with an unknown locale. For example if you have locales of 'en' and 'de', and a `defaultLocale` of 'en', then call `.setLocale('ja')` it will be equivalent to calling `.setLocale('en')`.\n\n### `directory` and `extension`\n\nThese default to `\"./locales\"` and `\".js\"` accordingly. They are used for saving and reading the locale data files (see the `locales` option for more information on how this works).\n\nWhen your server is in production mode it will read these files only once and then cache the result. It will not write any updated strings when in production mode.\n\nWhen in development, or testing, mode the files will be read on every instantiation of the `i18n` object. Additionally newly-detected strings will be automatically added, and written out, to the locale JSON files.\n\nA generated `en.js` inside `./locales/` may look something like:\n```json\n{\n    \"Hello\": \"Hello\",\n    \"Hello %s, how are you today?\": \"Hello %s, how are you today?\",\n    \"weekend\": \"weekend\",\n    \"Hello %s, how are you today? How was your %s.\": \"Hello %s, how are you today? How was your %s.\",\n    \"Hi\": \"Hi\",\n    \"Howdy\": \"Howdy\",\n    \"%s cat\": {\n        \"one\": \"%s cat\",\n        \"other\": \"%s cats\"\n    },\n    \"There is one monkey in the %%s\": {\n        \"one\": \"There is one monkey in the %%s\",\n        \"other\": \"There are %d monkeys in the %%s\"\n    },\n    \"tree\": \"tree\"\n}\n```\nthat file can be edited or just uploaded to [webtranslateit](http://docs.webtranslateit.com/file_formats/) for any kind of collaborative translation workflow.\n\n### `base`\n\nYou can specify a function that will be used to extract base file name for each locale. It may be used for instance to keep in the locales only region-specific translations and move all what's shared to the base files.\n\nIt will take effect only when `locales` are provided as an array and `base` is a function that returns a string value. You can skip this mechanism for particular locale if `base` returns no value.\n\nEach locale is merged with its base (if found) such that locale translations override the base. If the base file does not exist or is not parsable - it will not be created.\n\nFollowing example takes `de.js` and `en.js` as bases respectively for each locale:\n```javascript\nlocales: ['at-de', 'de-de', 'at-en', 'de-en'],\nbase: function(locale) {\n    return locale.slice(-2);\n}\n```\n### `parse(data, [indent])` and `dump(data)`\n\nOptional custom methods to override `JSON.parse()` and `JSON.stringify()`, respectively. One possible use for this is to allow for file formats other than JSON. For example:\n```javascript\nvar i18n = new (require('i18n-2'))({\n    locales: ['en', 'de'],\n    extension: '.yaml',\n    parse: function (data) {\n        return require('js-yaml').safeLoad(data);\n    },\n    dump: function (data) {\n        return require('js-yaml').safeDump(data);\n    }\n});\n```\n### `request`, `subdomain`, `query` and `session`\n\nThese options are to be used with Express.js or another framework that provides a `request` object. In order to use the `subdomain` and `query` options you must specify the `request` option, passing in the Express.js `request` object.\n\nIf you pass in a `request` object a new `i18n` property will be attached to it, containing the i18n instance.\n\nNote that you probably won't need to use `request` directly, if you use `expressBind` it is taken care of automatically.\n\nSetting the `subdomain` option to `true` will run the `setLocaleFromSubdomain` method automatically on every request.\n\nSetting the `session` option to `true` will run the `setLocaleFromSessionVar` method automatically on every request.\n\nBy default the `query` option is set to true. Setting the `query` option to `false` will stop the `setLocaleFromQuery` method from running automatically on every request.\n\n### `register`\n\nCopy the `__`, `__n`, `getLocale`, and `isPreferredLocale` methods over to the object specified by the `register` property.\n```javascript\nvar obj = {};\nnew i18n({ 'register': obj })\nconsole.log( obj.__(\"Hello.\") );\n```\n### `devMode`\n\nBy default the `devMode` property is automatically set to be `false` if Node.js is in production mode and `true` otherwise. You can override this by setting a different value to the `devMode` option.\n\n### `indent`\n\nSets the indent string for `JSON.stringify` when updating the locale files. Defaults to a tab character. Might be useful when you use a source formatter in your project.\n\n## Using with Express.js\n\n### Load and Configure\n\nIn your app.js:\n```javascript\n// load modules\nvar express = require('express'),\n    i18n = require('i18n-2');\n\n// Attach the i18n property to the express request object\n// And attach helper methods for use in templates\ni18n.expressBind(app, {\n    // setup some locales - other locales default to en silently\n    locales: ['en', 'de'],\n    // change the cookie name from 'lang' to 'locale'\n    cookieName: 'locale'\n});\n\n// This is how you'd set a locale from req.cookies.\n// Don't forget to set the cookie either on the client or in your Express app.\napp.use(function(req, res, next) {\n    req.i18n.setLocaleFromCookie();\n    next();\n});\n\n// Set up the rest of the Express middleware\napp.use(app.router);\napp.use(express.static(__dirname + '/public'));\n```\n### Inside Your Express View\n```javascript\nmodule.exports = {\n    index: function(req, res) {\n        res.render(\"index\", {\n            title: req.i18n.__(\"My Site Title\"),\n            desc: req.i18n.__(\"My Site Description\")\n        });\n    }\n};\n```\n### Inside Your Templates\n\n(This example uses the Swig templating system.)\n```\n{% extends \"page.swig\" %}\n\n{% block content %}\n<h1>{{ __(\"Welcome to:\") }} {{ title }}</h1>\n<p>{{ desc }}</p>\n{% endblock %}\n```\n\n## Debugging\n\n`i18n-2` uses the [debug module](https://github.com/visionmedia/debug) to output debug messages to the console. To output all debug messages, set the `DEBUG` environment variable:\n\n```\nDEBUG=i18n-2:*\n```\nThis will output debugging messages from the module.\n\n## Changelog\n\n* 0.6.0: added setLocaleFromEnvironmentVariable()\n* 0.5.0: base files for locales\n* 0.4.7: configurable indent for locale json files\n* 0.4.6: bug fixes, new feature (dot notation & `__n` supporting object locales)\n* 0.4.5: a number of bug fixes\n* 0.4.4: fix typo\n* 0.4.3: fix issue with preferredLocale failing on useragents with no accept lang header\n* 0.4.2: fix some issues with cache init\n* 0.4.1: rename locale query string param to lang\n* 0.4.0: made settings contained, and scoped, to a single object (complete re-write by jeresig)\n* 0.3.5: fixed some issues, prepared refactoring, prepared publishing to npm finally\n* 0.3.4: merged pull request #13 from Fuitad/master and updated README\n* 0.3.3: merged pull request from codders/master and modified for backward compatibility. Usage and tests pending\n* 0.3.2: merged pull request #7 from carlptr/master and added tests, modified fswrite to do sync writes\n* 0.3.0: added configure and init with express support (calling guessLanguage() via 'accept-language')\n* 0.2.0: added plurals\n* 0.1.0: added tests\n* 0.0.1: start\n","_attachments":{},"homepage":"http://github.com/jeresig/i18n-node-2","bugs":{"url":"https://github.com/jeresig/i18n-node-2/issues"},"license":"MIT"}