{"_id":"polyglot","_rev":"17-760d75ee7e44efb05223a20f2b203f77","name":"polyglot","description":"i18n module for express","dist-tags":{"latest":"0.5.0"},"versions":{"0.2.0":{"name":"polyglot","description":"i18n module for express","keywords":["i18n","L10n","G10n","internationalization","globalization","localization","templates"],"author":{"name":"Ricardo Tomasi","email":"ricardobeat@gmail.com","url":"http://ricardo.cc/"},"repository":{"type":"git","url":"git://github.com/ricardobeat/polyglot.git"},"version":"0.2.0","engines":{"node":">0.4"},"dependencies":{},"devDependencies":{},"_id":"polyglot@0.2.0","_engineSupported":true,"_npmVersion":"1.0.6","_nodeVersion":"v0.4.7","_defaultsLoaded":true,"dist":{"shasum":"dfafaef9546a365be2fa0bf0a6f37d07a7fa8b30","tarball":"https://registry.npmjs.org/polyglot/-/polyglot-0.2.0.tgz","integrity":"sha512-hrDam0bG82ArJG0YEECobp/NPKJ9JnifIgdEyqccu80dKaM6g0XArTyK/Kd/lPIrcgxFm4eXTK2b2GTOxkCmjQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHnlNWX/VKHLeh2W2WCr/2IxbvrRp0zd7Qq9A2Et32z/AiBuogcSRLTtm3DQjVobZIRvErWWscAhcON4cbsheuGPIw=="}]},"scripts":{},"directories":{}},"0.3.0":{"name":"polyglot","description":"i18n module for express","keywords":["i18n","L10n","G11n","internationalization","globalization","localization","templates"],"author":{"name":"Ricardo Tomasi","email":"ricardobeat@gmail.com","url":"http://ricardo.cc/"},"repository":{"type":"git","url":"git://github.com/ricardobeat/polyglot.git"},"version":"0.3.0","engines":{"node":">0.6"},"dependencies":{},"_npmUser":{"name":"ricardobeat","email":"ricardobeat@gmail.com"},"_id":"polyglot@0.3.0","devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.2","_nodeVersion":"v0.6.11","_defaultsLoaded":true,"dist":{"shasum":"61421e2538e01ad14572d729424dff4cdedddc80","tarball":"https://registry.npmjs.org/polyglot/-/polyglot-0.3.0.tgz","integrity":"sha512-92hZ7xPnHNpP8l9z+ltHN5AXaJ6MFCCUiPZxjzT6Haa55fD4BzZV0ftN/gnZ5cUWiyhm1CxZ0juADxnDz9hw7Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDFyLsi3vMRrlFvGOgVmXpOD4HeakyPbQhUfGi/mDWjigIgHofw1aAjIZqyhDwVRUgnueQT7QgkiqsvGBVWotx3dcU="}]},"readme":"","maintainers":[{"name":"ricardobeat","email":"ricardobeat@gmail.com"}],"directories":{}},"0.5.0":{"name":"polyglot","description":"i18n module for express","keywords":["i18n","L10n","G11n","internationalization","globalization","localization","templates"],"author":{"name":"Ricardo Tomasi","email":"ricardobeat@gmail.com","url":"http://ricardo.cc/"},"repository":{"type":"git","url":"git://github.com/ricardobeat/polyglot.git"},"version":"0.5.0","engines":{"node":">0.6"},"dependencies":{},"scripts":{"test":"mocha"},"readme":"Polyglot\n========\n\nPolyglot is an internationalization library for [express](http://github.com/visionmedia/express). It's template-agnostic, based on JSON files, and less than 200 lines of code. Compatible with express 3+.\n\n## Usage\n\nInstall with `npm install polyglot`:\n\n    var i18n = require('polyglot')\n\n    app = express()\n\n    app.use(express.cookieParser())\n    app.use(express.cookieSession())\n    app.use(i18n())\n\n    # register template locals\n    app.locals(i18n.locals)\n\nCheck the [example](https://github.com/ricardobeat/node-polyglot/tree/master/example) app.\n\n### Options\n\n    app.use(i18n({\n        debug   : false    // enable debug messages\n      , default : 'en'     // default language\n      , path    : '/lang'  // path for .json language files\n    }))\n\n### Language files\n\nTranslation files are `.json` files containing the translated strings. The default directory is `/lang`. To add a new language, just create an empty .json file with the language code as it's name (i.e. `de.json`).\n\nSee https://github.com/ricardobeat/node-polyglot/blob/master/example/lang/pt.json\n\nString definitions are automatically added to all available languages by adding the `updateStrings` middleware to your express config:\n\n    app.configure('development', function(){\n        app.use(i18n.updateStrings)\n    })\n\n### Templating / locals\n\nAll the following examples are based on [handlebars](http://github.com/donpark/hbs) templates.\n\nRegistering `app.locals(i18n.locals)` is simply a shortcut for:\n\n    app.locals({\n        __        : i18n.translate\n      , _n        : i18n.plural\n      , languages : i18n.languages\n    })\n\nIn addition to that, `i18n()` registers a middleware which sets `req.lang` and `req.locale` containing the user's settings.\n\nSee the `/example` folder for an implementation using Handlebars helpers.\n\n#### i18n.translate\n\nTakes a string and returns a translation based on your current session preferences (`req.session.lang`)`.\n\n     {{ __('hello') }}\n     // en: 'hello'\n     // pt: 'olá'\n\n#### i18n.plural\n\nTakes `[n, singular, plural]` or `[n, zero, singular, plural]` arguments. Using `i18n.translate` with the same arguments will use plural automatically.\n\n    {{ __(1, \"%s cat\", \"%s cats\") }}\n    // en: '1 cat'\n    // pt: '1 gato'\n\n    {{ __(0, \"no cats\", \"%s cat\", \"%s cats\") }}\n    // en: 'no cats'\n    // pt: 'nenhum gato'\n\n#### i18n.setLanguage\n\nTo change the current language call `i18n.setLanguage`, passing the user's session object and desired language code:\n\n    app.get('/lang/:lang', function(req, res){\n        i18n.setLanguage(req.session, req.params.lang)\n        res.redirect(req.headers.referer || '/')\n    })\n\nAccessing http://yourapp/lang/de will set language to `de`, *if* it is defined in the i18n.languages object.\n\n### Source code and tests\n\nPolyglot is written in coffeescript and distributed in js. [Read the annotated source here](http://ricardobeat.github.com/node-polyglot).\n\nRun tests using `mocha` or `npm test`. You need `coffee-script` and `mocha` installed globally on your machine.\n","_id":"polyglot@0.5.0","dist":{"shasum":"1f734cd4263b86c1a12046a6267ada3235228692","tarball":"https://registry.npmjs.org/polyglot/-/polyglot-0.5.0.tgz","integrity":"sha512-U6nUdVKrSZEHH+FFyZsLzG7vUlGzevD2Oetg6/wuJU5UZz/lHf+bj0DXPKCsbIQ4U/HT9df58b28U7e4GIKa+Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC+JYsjZUlUcSUfl5w5KfuVTfMTEL7zmOsn8ynwCRmohwIhAPjSGOTR0wVCx1b5kgTurCUfktNzJSEby4IWP4cXEb9r"}]},"maintainers":[{"name":"ricardobeat","email":"ricardobeat@gmail.com"}]}},"maintainers":[{"name":"ricardobeat","email":"ricardobeat@gmail.com"}],"time":{"modified":"2022-06-24T06:59:43.527Z","created":"2011-05-14T05:07:46.252Z","0.2.0":"2011-05-14T05:07:46.887Z","0.3.0":"2012-03-20T23:03:24.885Z","0.5.0":"2013-02-16T00:34:52.505Z"},"author":{"name":"Ricardo Tomasi","email":"ricardobeat@gmail.com","url":"http://ricardo.cc/"},"repository":{"type":"git","url":"git://github.com/ricardobeat/polyglot.git"},"users":{"hugovila":true}}