<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: i18nexus</title>
    <description>The latest articles on DEV Community by i18nexus (@i18nexus).</description>
    <link>https://dev.to/i18nexus</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F509160%2F82fbcd83-22e3-4fed-887b-630ef5aae051.jpeg</url>
      <title>DEV Community: i18nexus</title>
      <link>https://dev.to/i18nexus</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/i18nexus"/>
    <language>en</language>
    <item>
      <title>Next.js — The Scalable Way to Internationalize Using next-i18next</title>
      <dc:creator>i18nexus</dc:creator>
      <pubDate>Wed, 07 Jul 2021 04:46:46 +0000</pubDate>
      <link>https://dev.to/i18nexus/next-js-scalable-internationalization-using-next-i18next-23bi</link>
      <guid>https://dev.to/i18nexus/next-js-scalable-internationalization-using-next-i18next-23bi</guid>
      <description>&lt;p&gt;In this tutorial, we’re going to learn how to internationalize a Next.js app using &lt;a href="https://github.com/isaachinman/next-i18next" rel="noopener noreferrer"&gt;next-i18next&lt;/a&gt;. To make things even easier, we’re going to use &lt;a href="https://i18nexus.com" rel="noopener noreferrer"&gt;i18nexus&lt;/a&gt; to auto-translate and manage our strings for us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s go! ⚡️&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;Let’s bootstrap together a simple Next.js application using &lt;a href="https://nextjs.org/docs/api-reference/create-next-app" rel="noopener noreferrer"&gt;create-next-app&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-next-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;After typing in a title for our app, we will cd into the app directory and install &lt;a href="https://github.com/isaachinman/next-i18next" rel="noopener noreferrer"&gt;next-i18next&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install next-i18next --save&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Time to internationalize! 🌐&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Configuration
&lt;/h2&gt;

&lt;p&gt;With the release of Next.js v10, we received an awesome built-in solution for handling internationalized routing and locale detection. &lt;code&gt;next-i18next&lt;/code&gt; is designed to work hand-in-hand with this new internationalization support.&lt;/p&gt;

&lt;p&gt;To use &lt;code&gt;next-i18next&lt;/code&gt;, we need to create an i18next config file at the root of our app called &lt;code&gt;next-i18next.config.js&lt;/code&gt;. This will define the languages we want our app to use. Let’s support English and Swedish.&lt;/p&gt;

&lt;p&gt;We need to initialize our &lt;code&gt;defaultLocale&lt;/code&gt; (the default language for our app) and &lt;code&gt;locales&lt;/code&gt; (a list of languages that we want our app to support):&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;next-i18next.config.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  i18n: {
    defaultLocale: 'en',
    locales: ['en', 'sv']
  },
  reloadOnPrerender: process.env.NODE_ENV === 'development'
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It is also recommended to enable the &lt;code&gt;reloadOnPrerender&lt;/code&gt; option in development. When this option is enabled, &lt;code&gt;next-i18next&lt;/code&gt; will reload our translations when we make changes to our translation files.&lt;/p&gt;

&lt;p&gt;Next, we need to add the &lt;code&gt;i18n&lt;/code&gt; property to &lt;code&gt;next.config.js&lt;/code&gt; by simply importing the &lt;code&gt;i18n&lt;/code&gt; object from the i18next config:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;next.config.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { i18n } = require('./next-i18next.config');

module.exports = {
  i18n,
  reactStrictMode: true
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;next-i18next&lt;/code&gt; library uses the same &lt;code&gt;i18n&lt;/code&gt; config structure that Next requires. So instead of having to manage the same settings in two places, we simply import the &lt;code&gt;next-i18next&lt;/code&gt; config into &lt;code&gt;next.config.js&lt;/code&gt; as recommended in the &lt;a href="https://github.com/isaachinman/next-i18next" rel="noopener noreferrer"&gt;next-i18next docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;appWithTranslation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;One last step for setting up &lt;code&gt;next-i18next&lt;/code&gt; is to wrap our app with the &lt;code&gt;appWithTranslation&lt;/code&gt; HOC (higher-order component). This component will provide our i18next context to all of our pages. Our &lt;code&gt;_app.js&lt;/code&gt; file should look like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;_app.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '../styles/globals.css';
import { appWithTranslation } from 'next-i18next';

const MyApp = ({ Component, pageProps }) =&amp;gt; &amp;lt;Component {...pageProps} /&amp;gt;

export default appWithTranslation(MyApp);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;And now we’re ready to go! 🚀&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  i18nexus Integration
&lt;/h2&gt;

&lt;p&gt;If you’ve used i18next before but have never used it with i18nexus, you’re in for a treat.&lt;/p&gt;

&lt;p&gt;i18nexus makes managing our translations a million times easier by storing our app texts in the cloud. It even machine translates our strings using DeepL and Google Translate to as many languages as we need. Whenever we’re ready to hire professional translators, we just invite them to our i18nexus project and let them edit the translations!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s do it!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you don’t already have an i18nexus account, go to &lt;a href="https://app.i18nexus.com/sign-up" rel="noopener noreferrer"&gt;i18nexus.com&lt;/a&gt; and sign up for a free account. After naming our project we’ll be directed to our language dashboard:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AK0orZ6tosGWb3GuEYvHZTQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AK0orZ6tosGWb3GuEYvHZTQ.png" alt="i18nexus project dashboard"&gt;&lt;/a&gt;&lt;em&gt;i18nexus project dashboard&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first language tile is our base language, which should match the language we set for the &lt;code&gt;defaultLocale&lt;/code&gt; property in &lt;code&gt;next-i18next.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Next, we’ll click &lt;strong&gt;Add Language&lt;/strong&gt; to select the locales that we want our app to support. Since we already added &lt;code&gt;sv&lt;/code&gt; (Swedish) to our &lt;code&gt;locales&lt;/code&gt; list in &lt;code&gt;next-i18next.config.js&lt;/code&gt;, we’ll select Swedish:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ArELtPG31hB8drpUHG9286A.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ArELtPG31hB8drpUHG9286A.png" alt="Adding Swedish as a supported language"&gt;&lt;/a&gt;&lt;em&gt;Adding Swedish as a supported language&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now let’s click &lt;strong&gt;Open Project&lt;/strong&gt; in the top right corner to go to the Strings Management page where we will be adding our strings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Namespaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the top of the page, there is a dropdown labeled &lt;strong&gt;namespaces&lt;/strong&gt;, which contains one namespace already created for us called “default”.&lt;/p&gt;

&lt;p&gt;It is convention to have one namespace for each Page in your app, as well as a namespace called “common” for common strings that appear on more than one page.&lt;/p&gt;

&lt;p&gt;Let’s rename the “default” namespace to “&lt;strong&gt;common&lt;/strong&gt;”, and then create a namespace called “&lt;strong&gt;home&lt;/strong&gt;” to be used for our Home page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ALj2SPK8UkXThdwdv85rNdg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ALj2SPK8UkXThdwdv85rNdg.png" alt="Managing namespaces"&gt;&lt;/a&gt;&lt;em&gt;Managing namespaces&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; Even though we will not be using the “common” namespace in this walkthrough, it is required. We will discuss why shortly. 🙂&lt;/p&gt;

&lt;p&gt;To add our first string, click &lt;strong&gt;Add String&lt;/strong&gt;. I’m going to add a string in my “home” namespace that says “Hello, and welcome to my app!”:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AeWDEQy6F8LaHJai-JjU6YQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AeWDEQy6F8LaHJai-JjU6YQ.png" alt="Adding a new string with key “welcome_msg”"&gt;&lt;/a&gt;&lt;em&gt;Adding a new string with key “welcome_msg”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;key&lt;/strong&gt; is how we will reference this string in our code.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;value&lt;/strong&gt; is the text that will be rendered in our app.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;details&lt;/strong&gt; field is optional. It is meant to provide any extra information about the context of our string for when we’re ready to bring in professional translators. We can even add an image here for more context.&lt;/p&gt;

&lt;p&gt;After adding the string, we can expand the row to see our automatic translations (using DeepL and Google Translate):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ALp_1QokOCJRGgrM1-dP3Og.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ALp_1QokOCJRGgrM1-dP3Og.png" alt="New strings are automatically translated to all of our supported languages"&gt;&lt;/a&gt;&lt;em&gt;New strings are automatically translated to all of our supported languages&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Connecting our Translations
&lt;/h2&gt;

&lt;p&gt;We’re going to use the &lt;a href="https://www.npmjs.com/package/i18nexus-cli" rel="noopener noreferrer"&gt;i18nexus CLI&lt;/a&gt; to import our i18nexus translations in our Next.js app:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install i18nexus-cli -g&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If we go to the &lt;strong&gt;Export&lt;/strong&gt; tab in i18nexus, we’ll be able to find our project API key:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AWgAJK52fQe7f8fHMAgWXSQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AWgAJK52fQe7f8fHMAgWXSQ.png" alt="i18nexus Export tab"&gt;&lt;/a&gt;&lt;em&gt;i18nexus Export tab&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In our app directory, all we have to do is run &lt;code&gt;i18nexus pull&lt;/code&gt; with our API key and all of our latest translations will be downloaded to our project directory!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;$ i18nexus pull --api-key &amp;lt;YOUR_API_KEY&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now all our translations will be located in &lt;code&gt;public/locales&lt;/code&gt;, which is where &lt;code&gt;next-i18next&lt;/code&gt; expects them.&lt;/p&gt;

&lt;p&gt;We can also add our API key as an environment variable named &lt;code&gt;I18NEXUS_API_KEY&lt;/code&gt; so that we can just use &lt;code&gt;i18nexus pull&lt;/code&gt; without typing your API key every time.&lt;/p&gt;

&lt;p&gt;To do this, we simply create an environment variable file called &lt;code&gt;.env&lt;/code&gt; at the root of our app that contains &lt;code&gt;I18NEXUS_API_KEY=YOUR_API_KEY&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bonus Points:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If we want to automatically pull our latest translations every time we start up our dev server or build our app, all we have to do is update our scripts in &lt;code&gt;package.json&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;package.json&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;...
"scripts": {
   "dev": "i18nexus pull &amp;amp;&amp;amp; next dev",
   "build": "i18nexus pull &amp;amp;&amp;amp; next build",
   "start": "i18nexus pull &amp;amp;&amp;amp; next start"
 }
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;If you do this, you should also install the &lt;code&gt;i18nexus-cli&lt;/code&gt; as a dev dependency:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install i18nexus-cli --save-dev&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Rendering our Translations
&lt;/h2&gt;

&lt;p&gt;Right now our app is just using the boilerplate &lt;code&gt;create-next-app&lt;/code&gt; home page:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2Awr7KI80BrsWJD6BQ7T_SFg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2Awr7KI80BrsWJD6BQ7T_SFg.png" alt="Boilerplate create-next-app"&gt;&lt;/a&gt;&lt;em&gt;Boilerplate create-next-app&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;serverSideTranslations&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our home page we need to import a function called &lt;code&gt;serverSideTranslations&lt;/code&gt; from &lt;code&gt;next-i18next&lt;/code&gt;. This function needs to be run in &lt;code&gt;getStaticProps&lt;/code&gt; on each &lt;strong&gt;page-level&lt;/strong&gt; component. It provides our page with our translations and configuration options as props. We’ll add this to our &lt;code&gt;pages/index.js&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pages/index.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { serverSideTranslations } from 'next-i18next/serverSideTranslations';

export async function getStaticProps({ locale }) {
  return {
    props: {
      ...(await serverSideTranslations(locale, ['home'])),
    }
  } 
}

...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The &lt;code&gt;severSideTranslations&lt;/code&gt; function accepts a locale as the first argument and the namespaces required for this page as the second argument. This ensures that our app only has to load the namespaces needed for the page. The locale is passed down from &lt;code&gt;getStaticProps&lt;/code&gt; by Next.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;useTranslation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Lastly, let’s import the &lt;code&gt;useTranslation&lt;/code&gt; hook from &lt;code&gt;next-i18next&lt;/code&gt;. The &lt;code&gt;useTranslation&lt;/code&gt; hook contains a function called &lt;code&gt;t&lt;/code&gt; that takes a key as an argument and renders the proper translation.&lt;/p&gt;

&lt;p&gt;I’m going to clear out most of the boilerplate that was generated by &lt;code&gt;create-next-app&lt;/code&gt; and just render a single line of text on my Home page. Here’s my entire home page using &lt;code&gt;useTranslation&lt;/code&gt; to render my &lt;code&gt;welcome_msg&lt;/code&gt; string:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;pages/index.js&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from "next/head";
import styles from "../styles/Home.module.css";
import { serverSideTranslations } from "next-i18next/serverSideTranslations";
import { useTranslation } from "next-i18next";

export async function getStaticProps({ locale }) {
  return {
    props: {
      ...(await serverSideTranslations(locale, ["home"]))
    }
  };
}

export default function Home() {
  const { t } = useTranslation();

  return (
    &amp;lt;div className={styles.container}&amp;gt;
      &amp;lt;Head&amp;gt;
        &amp;lt;title&amp;gt;Create Next App&amp;lt;/title&amp;gt;
        &amp;lt;link rel="icon" href="/favicon.ico" /&amp;gt;
      &amp;lt;/Head&amp;gt;

      &amp;lt;main className={styles.main}&amp;gt;
        &amp;lt;h1 className={styles.title}&amp;gt;{t("home:welcome_msg")}&amp;lt;/h1&amp;gt;
      &amp;lt;/main&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Notice that when we use &lt;code&gt;useTranslation&lt;/code&gt;, we need to specify the namespace with the key like so: &lt;code&gt;home:welcome_msg&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The only time we do not need to specify the namespace in &lt;code&gt;useTranslation&lt;/code&gt; is when the key we are referencing is in our &lt;strong&gt;default namespace&lt;/strong&gt;. By default, i18next sets our default namespace to “common”. If you’d like, you can change your default namespace via the &lt;code&gt;defaultNS&lt;/code&gt; config option in &lt;code&gt;next-i18next.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now lets run &lt;code&gt;npm run dev&lt;/code&gt;, and check it out!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACVgKWZo2dZqL7o23Y3fH8g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACVgKWZo2dZqL7o23Y3fH8g.png" alt="Rendering English translation"&gt;&lt;/a&gt;&lt;em&gt;Rendering English translation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We did it!&lt;/strong&gt; 🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  Using Other Languages
&lt;/h2&gt;

&lt;p&gt;Right now, our app is using &lt;code&gt;en&lt;/code&gt; because that is what we set as our &lt;code&gt;defaultLocale&lt;/code&gt; in &lt;code&gt;next.config.js&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you recall, we added Swedish (&lt;code&gt;sv&lt;/code&gt;) to our list of locales. To see our app in Swedish, all we have to do is add &lt;code&gt;/sv&lt;/code&gt; to the end of the URL. If a user’s browser language is set to Swedish, Next will automatically redirect them to the &lt;code&gt;/sv&lt;/code&gt; route. Let’s see what out app looks like in Swedish:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://localhost:3000/sv" rel="noopener noreferrer"&gt;http://localhost:3000/sv&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AhllmyxHlwtXILYMC93teeA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AhllmyxHlwtXILYMC93teeA.png" alt="Rendering Swedish translation"&gt;&lt;/a&gt;&lt;em&gt;Rendering Swedish translation&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Looks like we’re internationalization pros! 😎&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To learn more about internationalized routing and changing to different languages, take a quick read of the Next.js docs &lt;a href="https://nextjs.org/docs/advanced-features/i18n-routing" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  That’s all folks!
&lt;/h2&gt;

&lt;p&gt;You now have a Next.js app fully set up with internationalized routing, i18next integration, and automated translation management with i18nexus!&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>javascript</category>
      <category>localization</category>
    </item>
    <item>
      <title>React Localization with i18next and Google Translate</title>
      <dc:creator>i18nexus</dc:creator>
      <pubDate>Fri, 06 Nov 2020 06:43:29 +0000</pubDate>
      <link>https://dev.to/i18nexus/react-localization-with-i18next-and-google-translate-dn8</link>
      <guid>https://dev.to/i18nexus/react-localization-with-i18next-and-google-translate-dn8</guid>
      <description>&lt;p&gt;We’re going to take a look at localizing a React app with &lt;a href="https://github.com/i18next/react-i18next" rel="noopener noreferrer"&gt;react-i18next&lt;/a&gt; and &lt;a href="https://i18nexus.com" rel="noopener noreferrer"&gt;i18nexus&lt;/a&gt;. i18next is one of the most popular JavaScript localization libraries around, but its power is truly unleashed when used with i18nexus and its awesome API for scalable translation management and Google Translate automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start up the project
&lt;/h2&gt;

&lt;p&gt;I am going to bootstrap together a simple React application using &lt;a href="https://github.com/facebook/create-react-app" rel="noopener noreferrer"&gt;create-react-app&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npx create-react-app my-app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s &lt;code&gt;cd&lt;/code&gt; into the React app directory and install a few i18next packages:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;npm install i18next react-i18next i18next-http-backend i18next-browser-languagedetector --save&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry, these packages are all very lightweight and easy to use. Here’s what they do:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/i18next/i18next/" rel="noopener noreferrer"&gt;i18next&lt;/a&gt;: The base i18next library.&lt;br&gt;
&lt;a href="https://github.com/i18next/react-i18next" rel="noopener noreferrer"&gt;react-i18next&lt;/a&gt;: Gives us React-friendly hooks, components, and functions for i18next.&lt;br&gt;
&lt;a href="https://github.com/i18next/i18next-http-backend" rel="noopener noreferrer"&gt;i18next-http-backend&lt;/a&gt;: Let’s us use AJAX for loading translation files.&lt;br&gt;
&lt;a href="https://github.com/i18next/i18next-browser-languageDetector" rel="noopener noreferrer"&gt;i18next-browser-languagedetector&lt;/a&gt;: Detects your users’ preferred language based on browser settings.&lt;/p&gt;

&lt;p&gt;Let’s start up our development server with npm start&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here we go!&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  i18next + i18nexus = 🔥
&lt;/h2&gt;

&lt;p&gt;Ever since I started using &lt;a href="https://i18nexus.com" rel="noopener noreferrer"&gt;i18nexus&lt;/a&gt;, I haven’t used i18next without it. i18nexus allows us to store our app strings in the cloud and automatically translates them to as many languages as we want. Whenever you’re ready to hire professional translators, you simply invite them to the i18nexus project and you’re done.&lt;/p&gt;

&lt;p&gt;In one word: AWESOME.&lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://app.i18nexus.com/sign-up" rel="noopener noreferrer"&gt;i18nexus.com&lt;/a&gt; and sign up for a free account. After naming your project you’ll be directed to your language dashboard:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2Azgr5uxRCnIgzGrr_niCAwA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2Azgr5uxRCnIgzGrr_niCAwA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first language tile is your base language — the language you’re &lt;em&gt;translating from&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Click “Add Language” to select a language that you want your app to use. You can select as many as you want. I think I’ll select Spanish:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AVg8xnjQZyDAsDpSjNpcFNw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AVg8xnjQZyDAsDpSjNpcFNw.png" alt="Language Selection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s go to the page where we’ll be adding our strings. Click &lt;strong&gt;Open Project&lt;/strong&gt; in the top right corner to be directed to the Strings Management page.&lt;/p&gt;

&lt;p&gt;To add your first string, click &lt;strong&gt;Add String&lt;/strong&gt;. I’m going to add a string that welcomes users to my app:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ANQxJoouR4yNydqtOAi_kGA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ANQxJoouR4yNydqtOAi_kGA.png" alt="**Key**: “welcome_msg” **Value**: “Hello, and welcome to my app!”"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;key&lt;/strong&gt; is how you’ll reference this string in your app.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;value&lt;/strong&gt; is the text that will be displayed in your app.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;details&lt;/strong&gt; field is optional. It is meant to provide any extra information about the context of your string for when you’re ready to bring in professional translators. You can even add an image here for more context!&lt;/p&gt;

&lt;p&gt;After adding the string, you can expand the row to see the auto-translations:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AO-1Bd-1p37uTseAW8w4OCQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2AO-1Bd-1p37uTseAW8w4OCQ.png" alt="Strings automatically translated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s connect to our app
&lt;/h2&gt;

&lt;p&gt;Back in the Export tab, we can find an i18next configuration code snippet to connect our React app to our i18nexus translations. Make sure to copy from the &lt;strong&gt;React&lt;/strong&gt; tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2656%2F1%2A-qGCwjH4BPfeJBq3qyjnOw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F2656%2F1%2A-qGCwjH4BPfeJBq3qyjnOw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s create a file called i18n.js in our src folder, and then paste in the code snippet:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4924%2F1%2AiAIY07wOJjBJzgZpapcSqA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4924%2F1%2AiAIY07wOJjBJzgZpapcSqA.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*Learn more about i18next configuration options &lt;a href="https://www.i18next.com/overview/configuration-options" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This code is asynchronously fetching our strings from the i18nexus API. I’ve never had problems with load speed, but for production environments it is recommended to use the i18nexus CDN and implement browser caching. We won’t go over that in this tutorial, but you can learn more about that &lt;a href="https://i18nexus.com/quick-integration/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’m going to import the i18n.js file in index.js, and then use React’s Suspense component to prevent rendering until the request is complete.&lt;/p&gt;

&lt;p&gt;My index.js file now looks like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React, { Suspense } from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import * as serviceWorker from "./serviceWorker";
import "./i18n.js";

ReactDOM.render(
  &amp;lt;React.StrictMode&amp;gt;
    &amp;lt;Suspense fallback="loading"&amp;gt;
      &amp;lt;App /&amp;gt;
    &amp;lt;/Suspense&amp;gt;
  &amp;lt;/React.StrictMode&amp;gt;,
  document.getElementById("root")
);

serviceWorker.unregister();


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Rendering our strings
&lt;/h2&gt;

&lt;p&gt;When the app loads, it is fetching all of our strings from i18nexus. Right now, my app just has the default create-react-app page with hardcoded strings:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5668%2F1%2AlV2cFW4MU6JdrfjSQcqcpg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5668%2F1%2AlV2cFW4MU6JdrfjSQcqcpg.png" alt="Default create react app screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s replace the text with our own strings!&lt;/p&gt;
&lt;h2&gt;
  
  
  useTranslation
&lt;/h2&gt;

&lt;p&gt;To use our strings, we have to import the &lt;code&gt;useTranslation&lt;/code&gt; hook from react-i18next. This hook returns a function named &lt;code&gt;t&lt;/code&gt; that we can use to get a string by passing the &lt;strong&gt;key&lt;/strong&gt; as the first argument.&lt;/p&gt;

&lt;p&gt;Back in i18nexus, the string I added has the key “welcome_msg”. Let’s render it. My App.js file now looks like this:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React from "react";
import logo from "./logo.svg";
import "./App.css";
import { useTranslation } from "react-i18next";

function App() {
  const { t } = useTranslation();

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
        &amp;lt;p&amp;gt;{t("welcome_msg")}&amp;lt;/p&amp;gt;
      &amp;lt;/header&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And here it is!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5664%2F1%2AC7Erl17P-QfrpvVtEPj1qA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5664%2F1%2AC7Erl17P-QfrpvVtEPj1qA.png" alt="The rendered English string"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Since my personal browser language is set to English, i18next has automatically chosen to render the English version of the string. This is thanks to the i18next-browser-languagedetector library!&lt;/p&gt;

&lt;p&gt;To let the user choose their language, you would simply create a dropdown that calls &lt;code&gt;i18next.changeLanguage(&amp;lt;language_code&amp;gt;)&lt;/code&gt; on change. Of course you can read more about all the i18next functions in the &lt;a href="https://www.i18next.com/" rel="noopener noreferrer"&gt;i18next docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For now, if you want to preview what your app would look like in another language, add the &lt;code&gt;lng&lt;/code&gt; query parameter to the URL. If I load the app with &lt;a href="http://localhost:3000/?lng=es" rel="noopener noreferrer"&gt;http://localhost:3000/?lng=es&lt;/a&gt;, i18next will use the Spanish translations:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACdZ_ctbQrYT-NSprNvnrkA.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACdZ_ctbQrYT-NSprNvnrkA.png" alt="[http://localhost:3000/?lng=es](http://localhost:3000/?lng=es)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;AWESOME!&lt;/p&gt;

&lt;h2&gt;
  
  
  Interpolation
&lt;/h2&gt;

&lt;p&gt;Let’s add another string to i18nexus that uses &lt;strong&gt;interpolation&lt;/strong&gt;. (Learn more about i18next interpolation &lt;a href="https://www.i18next.com/translation-function/interpolation" rel="noopener noreferrer"&gt;here&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;In i18nexus, I’m going to create a string with the value “My name is &lt;code&gt;{{name}}&lt;/code&gt;”. i18next uses double curly braces for interpolation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4392%2F1%2AKzVpA4ZV5gfCbAlxJwOi1Q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F4392%2F1%2AKzVpA4ZV5gfCbAlxJwOi1Q.png" alt="i18nexus even has syntax highlighting for interpolation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s use the &lt;code&gt;t&lt;/code&gt; function with interpolation:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

import React from "react";
import logo from "./logo.svg";
import "./App.css";
import { useTranslation } from "react-i18next";

function App() {
  const { t } = useTranslation();
  const userName = "David";

  return (
    &amp;lt;div className="App"&amp;gt;
      &amp;lt;header className="App-header"&amp;gt;
        &amp;lt;img src={logo} className="App-logo" alt="logo" /&amp;gt;
        &amp;lt;p&amp;gt;{t("welcome_msg")}&amp;lt;/p&amp;gt;
        &amp;lt;p&amp;gt;{t("my_name", { name: userName })}&amp;lt;/p&amp;gt;
      &amp;lt;/header&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

export default App;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;And now we see the interpolated value:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACCtCayec2ufUCZcoCbK-YQ.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2ACCtCayec2ufUCZcoCbK-YQ.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your app has access to all strings and translations immediately after you add them to i18nexus. &lt;strong&gt;I love it&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now I’m going to add German to my project in the i18nexus dashboard:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5472%2F1%2AbrnIeJ5lQQCpwUMg8OWxiw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5472%2F1%2AbrnIeJ5lQQCpwUMg8OWxiw.png" alt="Adding German to my project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you add another language to your i18nexus project, remember to update the &lt;code&gt;supportedLngs&lt;/code&gt; parameter in your i18n.js file by adding the new language code to the array.&lt;/p&gt;

&lt;p&gt;Alternatively, you can copy/paste the code snippet from the Export tab again. I’m just going to manually add “de” to my &lt;code&gt;supportedLngs&lt;/code&gt;:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

i18next
  .use(HttpBackend)
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    fallbackLng: "en",

    ns: ["default"],
    defaultNS: "default",

    supportedLngs: ["en", "es", "de"],

    backend: {
      loadPath: loadPath
    }
  });


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now let’s visit &lt;a href="http://localhost:3000/?lng=de" rel="noopener noreferrer"&gt;http://localhost:3000/?lng=de&lt;/a&gt; to see our app in German:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2A1GeqFy1ZCLtO0Kwkhn81Kg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn-images-1.medium.com%2Fmax%2F5760%2F1%2A1GeqFy1ZCLtO0Kwkhn81Kg.png" alt="[http://localhost:3000/?lng=de](http://localhost:3000/?lng=de)"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Awesome!&lt;/em&gt; (&lt;em&gt;Or should I say&lt;/em&gt; “&lt;em&gt;das ist fantastisch!”)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  To sum it up
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;i18next&lt;/strong&gt; and &lt;strong&gt;i18nexus&lt;/strong&gt; are an amazing duo for scalable localization in React. We have only scratched the surface with the customization available in both i18next and i18nexus, but hopefully this was enough to get you up and going! Feel free to ask any questions in the comments.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>localization</category>
      <category>i18next</category>
    </item>
  </channel>
</rss>
