How to start with i18next in the node application
I'm JS developer with 13 years of professional experience. I'm always happy to teach my craft.
Search for a command to run...
I'm JS developer with 13 years of professional experience. I'm always happy to teach my craft.
No comments yet. Be the first to comment.
I’ve been working in programming for the last 16 years. Let’s see what changes I see in our industry that are enabled by generative AI. Rapid prototyping The last few months, I’ve been working on a set of WordPress plugins, related to event organizat...
Writing unit tests takes time and effort. Nonetheless, many teams insist on writing them anyway—that’s because of the benefits they bring to a project. Those benefits are mainly the following: fast feedback—unit tests speed up each iteration of twea...

Pure functions are the perfect case for unit testing. For a given input, we always expect the same output—there is no internal state involved. Let’s take a look at a few examples and some simple tests that check if the methods work as expected. Jasmi...

Let’s say you have a job interview in a few days. How should you prepare for it so that you can make an informed decision about joining the company, as well as make sure that your interests are taken care of? Prepare your questions An interview is a ...

Creating example projects is a common way of showing your skills to potential employers. Let’s take a look at what’s important to keep in mind when building personal projects with an eye toward impressing prospective employers. Simplicity Building ap...

This article will show how to start i18next in a node project.
i18next is one of the libraries I included in my list of 5 interesting internationalization libraries. On the project page, it's called internationalization-framework, and indeed it looked the most complete from the libraries I checked.
To start, let's create a new package:
$ npm init -y
To make sure we can use es modules, let's add to package.json:
...
"type": "module",
...
We can install i18next as a normal dependency with:
$ npm install --save i18next
npm WARN i18next-vanilla@1.0.0 No description
npm WARN i18next-vanilla@1.0.0 No repository field.
+ i18next@20.4.0
added 1 package from 1 contributor and audited 3 packages in 0.658s
found 0 vulnerabilities
The minimal code needed to experiment with the library is index.js:
import i18next from "i18next";
i18next
.init({
lng: "en",
resources: {
en: {
translation: {
hello_world: "hello world",
},
},
},
})
.then((t) => {
console.log(t("hello_world"));
});
The code works as expected:
$ node index.js
hello world
In this article, we have started playing with i18next. Stay tuned for the following parts!