Я перепробовал все возможные варианты встроенного приложения response-i18next, Reaction-redux и машинописного текста.
Ниже приведен мой файл index.js:
import * as enTranslations from "./assets/locales/en";
import * as frTranslations from "./assets/locales/fr";
const resources = {
en: { messages: enTranslations }
};
i18next
.use(initReactI18next)
.init({
resources,
fallbackLng: "en",
debug: true,
// have a common namespace used around the full app
ns: ["translations"],
defaultNS: "translations",
namespaceSeparator: '.',
keySeparator: false, // we use content as keys
interpolation: {
escapeValue: false
},
lng: "en",
}).then(() => {
ReactDOM.render(
<I18nextProvider i18n={i18next}>
<Provider store={store}>
<CookiesProvider>
<App />
</CookiesProvider>
</Provider>
</I18nextProvider>,
document.getElementById('root')
)
});
Мой код app.js:
export default compose(withTranslation("translations"), connect(
mapStateToProps,
mapDispatchToProps
))(App);
Метод визуализации моего компонента и код экспорта:
export default compose(
withTranslation('translations'),
connect(mapStateToProps, mapDispatchToProps)
)(UserComponent);
Метод визуализации:
render() {
const { t } = this.props;
return (
<h1>{CLIENTS_HEADER_TITLE} {t('title')}</h1>
);
Но я всегда вижу напечатанный ключ вместо значения ключа,Я не нашел ни одного примера с использованиемact-redux.
Я использую "Reaction-i18next": "^ 11.0.1", и я получаю ошибку отсутствующего ключа.