Stephan Hofmann Stephan Hofmann - 1 month ago 34x
React JSX Question

React-Native - i18n separate files

I use the i18n module ( It works great but I want to split the translations into seperate files. I came accross a nice blog post ( which shows the usecase like I want to do.

// src/config/locales/en.js
const en = {
welcome: 'welcome',
export default en;

// src/config/locales/es.js
const es = {
welcome: 'bienvenido',
export default es;

import I18n from 'react-native-i18n';

import es from './locales/es';
import en from './locales/en';

I18n.fallbacks = true;

I18n.translations = {
en: en,
es: es,

export default I18n;

//usage in components
import I18n from '../config/i18n';

render() {
return (

I got an error: "Cannot read property 't' of undefined". I am a newbie in react in general. What did I wrong?


The code from my question works like a charm. I just have wrong brackets in my import on the top

change from:

import { I18n } from '../config/i18n'


import I18n from '../config/i18n'