Localise your NodeJS app easily with i18n

danielnewell profile image Daniel Newell Updated on ・2 min read

So, you have a NodeJS app, but you only have access to a small subset of people: those who speak your language. Or maybe you have translations, but they are inefficient to implement and take up valuable time you can be using for fixing issues or adding features. In this article, you will learn how to implement Localazy to your NodeJS project.

Localazy is a translation management platform and it's a great option for developers because of two key features:

  • It comes with ShareTM allowing you to automatically translate your app into 80+ languages for free by sharing translations with other developers.
  • With its CLI, it can be easily integrated into any workflow. And we are using the CLI today.

By the way, this tool is free. Pretty cool, right?

Part 1 - Getting Ready

Create a Localazy account and follow prompts. Create an app, add your languages, and add translators.

Now, install.

Create a file called localazy.json and paste the following. Make sure to gather your keys!


  "writeKey": "your-apps-write-key", 
  "readKey": "your-apps-read-key",

  "upload": {
    "type": "json",
    "files": "locales/en.json"

  "download": {
    "files": "locales/${lang}.json"

Now, we can upload translations. Create en.json and edit as needed.

"appName": "Your Cool App",
"error": "An error has occurred.",
"Hello": "Hello {{name}}"

Now run localazy upload and you should see your translation strings on your home screen. You can use automatic or manual translations. Automatic translations may not be the most accurate, but are a start. When complete, use localazy download to gather edited files.

Part 2 - Development

Install i18n via npm. In your code add the following.

const i18n = require('i18n')
  locales: ['en', 'es', 'de'] // your languages
  directory: path.join(__dirname, '/locales'),
  register: global
function translate (p, l, ph) {
  return __({ phrase: p, locale: l}, ph)

Now, to translate anything, use the translate() function, like so:

console.log(translate('hello', 'de', { name: 'Daniel' }))

Implement this to fit your code, and you are complete!

If you run into issues, please leave a message and I will fix it as soon as possible.

Edited on 15 September: Basic style changes and fixed an oversight

Posted on by:


Forget all the hassle and make your app available in 80 languages free of charge with translation platform built for developers.


markdown guide