2
2
2chu2019-11-02 10:59:59
JavaScript
2chu, 2019-11-02 10:59:59

Returns undefIned when i18next.t() is called?

I get undefined on output. What is the problem? Usage example

import i18next from 'i18next';

export function balancePage() {
  console.log(i18next.t('payment_table_label_status')) //undefined
}

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

const resources = {
  en: {
    translation: {
      payment_table_label_status: 'status'
    }
  },
  ru: {
    translation: {
      payment_table_label_status: 'статус'
    }
  }
}

export default i18n
  .use(initReactI18next)
  .init({
    resources,
    lng: 'ru',
    keySeparator: false,
    interpolation: {
      escapeValue: false
    }
  });

In index.tsx I import i18n

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Dozmorov, 2019-11-04
@Dozalex

The keys are not identical. tabel and table

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question