i18ncloud
  • Introduction
  • Getting Started
  • React
    • Getting Started
    • Keys and Values
  • Commands
    • i18ncloud init
    • i18ncloud Push
    • i18ncloud Pull
    • i18ncloud Language
    • i18ncloud Key
Powered by GitBook
On this page
  • Navigate to the React Project Folder
  • Installing using npm
  • Initialization
  • Usage
  • Test Project

Was this helpful?

  1. React

Getting Started

PreviousGetting StartedNextKeys and Values

Last updated 5 years ago

Was this helpful?

To use this Tool within a React project, we first need to assure that the initial setup has already been made. So that it can work properly: install the next dependencies.

Navigate to the React Project Folder

Before using any CLI commands, make sure to navigate to the React project folder and install the package .

Installing using npm

#Using npm
npm install @i18ncloud/react

Initialization

There are 2 different options within Initialization:

  • Create a new App;

  • Clone the data from an existing one.

Create a New App

Using init, the CLI will prompt the auth service questions. And, once those were answered, we will then choose which languages will be added to the project.

Usage

Before using our Tool, the languages should be imported through importing i18n folder created after running init. This should be in the following path: <appFolder>/src. This import can be found in your index.js or App.js.

import './i18n';

You will also need to import the method useTranslation from react-i18next.

import { useTranslation } from 'react-i18next';

After these two steps, all you have to do is create the constants t and i18n from the useTranslation function

const { t, i18n } = useTranslation();

And use them in your project with the same syntax, from react-i18n-cloud

{t('key_name')}

Test Project

Check our test project in github.

@i18ncloud/react
GitHub - i18ncloud/test-i18ncloud-react: This project uses i18ncloud.com to manage internationalization on a react app.GitHub
Logo