i18next Guide (WIP)

Basic Example


Locale: 

Hello World! This is a basic example.

Code

1import PropTypes from 'prop-types';
2import { withTranslation } from '../../i18n';
3
4const BasicExample = ({ t }) => (
5  <div>
6    <p>{t('greeting')}</p>
7  </div>
8);
9
10BasicExample.propTypes = {
11  t: PropTypes.func.isRequired,
12};
13
14export default withTranslation('basic')(BasicExample);
15

basic/en.json

{
  "greeting": "Hello World! This is a basic example."
}

basic/de.json

{
  "greeting": "Hallo Welt! Dies ist ein grundlegendes Beispiel."
}

basic/ru.json

{
  "greeting": "Здравствуйте, мир! Это основной пример."
}