Home > AI > Frontend > react-i18next >

change lanuage manually

If you are using class component:

Step 1: change language

import React from 'react';
// use this
import { withTranslation } from 'react-i18next';

function MyComponent({ t, i18n }) {
  return <p>{t('my translated text')}</p>
}

// wrap the component
export default withTranslation()(MyComponent);


// if you want to load this component (don't need to change name)
import MyComponent from "./MyComponent"

Step 2: translation

import {Trans} from 'react-i18next'

<Trans>words_need_to_be_translated</Trans>

If you are using function component:

Leave a Reply