Building on our Ultimate Guide to Node.js Internationalization, this Node.js tutorial will show you how to create a multilingual web application in Node.js, without the need to install any external localization or internationalization library. Language files will be stored in the JSON data format, which is convertible into JavaScript objects. On top of that, you can easily extend or scale the web application to include the libraries of your choice later on. Let’s proceed to the next section and start with setting up the project.

Setup

Before you get it started, check out the GitHub repository for the complete code for this tutorial. Feel free to clone and run it directly on your local machine as long as you have Node installed.

Node.js

Make sure that you have Node.js installed locally on your machine. You can check it via the following command in the terminal:

node --version

Change the working directory to a root directory of your project. If you are starting from a new project, kindly run the following code to initialize the package setting.

npm init

Fill in the required information. You can skip some of the setting by leaving it blank. After that, it will create a file called package.json based on the information that you have entered.

{
  "name": "multilingual_nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Ng Wai Foong",
  "license": "ISC"
}

#nodejs #javascript

How to Create a Multilingual Web App with NodeJS
50.05 GEEK