7 Easy Steps to Localize Your React Native App

7 Easy Steps to Localize Your React Native App

It’s not a matter of if, but when. Let’s see how. It is true that any translation library that works for React will also do the trick for React Native. There are about 5 or 6 main options that you could choose from, but after counting up the pros and cons of each one, we decided to go with i18next.

Which Library Should You Choose?

It is true that any translation library that works for React will also do the trick for React Native. There are about 5 or 6 main options that you could choose from, but after counting up the pros and cons of each one, we decided to go with i18next.

i18next is a free library that offers a quick “getting started” routine, as well as some nice plug-n-play features that you might find useful and opt for later.

Let’s get started!

1. Install i18next

npm install i18next --save

2. Create empty translation file for English

Create a file and put it in a folder that works best for you (e.g. /translations/en.tsx), where you will later add translation files for all your supported languages. It should, for now, look something like this:

const translation = {};
export default translation;

3. Initialize the library and supply it with the file you just created

Add this code somewhere at the top of your root component:

import i18n from 'i18next';
  import { initReactI18next } from 'react-i18next';

  import en from './translation/en';
  i18n
  .use(initReactI18next)
  .init({
    lng: 'en',
    fallbackLng: 'en',
    debug: true,
    interpolation: {
      escapeValue: false,
    },
    resources: {
      en: {
        translation: en,
      },
    },
  });

The initialization is pretty straightforward, but can take in quite a few configuration options based on your needs. You can see all of them here.

But right now, we can already go ahead and try it out:

import i18next from 'i18next';

  render() {
    return (
      <Text>{i18next.t('Hello world!')}</Text>
    )
  }

javascript react-native localization

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Hire Dedicated React Native Developer

Have you ever thought of having your own app that runs smoothly over multiple platforms? React Native is an open-source cross-platform mobile application framework which is a great option to create mobile apps for both Android and iOS. **[Hire...

React Native Mobile App Development

Skenix is providing React Native Development Services with qualified React Native App Developers. Get the best React Native App Development Services.

React Native Redux | How To Use Redux In React Native

React Native Redux Example Tutorial From Scratch. We connect the React Native app to Redux store to save and retrieve the application data.

Build a simple React Native Pokemon app with React-Navigation

As we start learning new technologies we want to start building something or work on a simple project to get a better understanding of the technology.