Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including node-translate with all npm packages installed. Try it out:

var nodeTranslate = require("node-translate")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-translate v0.0.4

A translation library for NodeJS that wraps node-polyglot

Node Translate Build Status

A translation library for NodeJS that wraps node-polyglot


To build a local version for use or development:

git clone
cd node-translate
npm install

Installing as a node module:

npm install node-translate --save


Look at the example.js file to see a simple example of the library.

Run it with npm start

For more examples of the format of the locale files, look in ./locales/

module.exports = {
  "title": "Hello, World"


Create a new instance of the i18n library.

var i18n = require('node-translate');

Require the relevant locale files in a associative array with the key being the name of the locale and the value being the output of the respective locale file.

  'en-gb': require('./locales/en-gb'),
  'fr': require('./locales/fr')

Set the initial locale to use by providing the locale name. The first specified required locale is used as the current locale by default.


Now simply call the translation method with the key to translate.


The t method is compatible with polyglot so takes an optional second parameter for parsing variables into the translation string.

i18n.t('title', {name: "string"})

Chaining setters is also permitted.

i18n.requireLocales({'de': require('./locales/de')}).setLocale('de');

Running Tests

To run the Jest tests just type:

npm test

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free