react-i18next icon indicating copy to clipboard operation
react-i18next copied to clipboard

Set component prop?

Open st3phan opened this issue 10 years ago • 2 comments

Any pointers on when I need something like below?

I'm having trouble with the async aspect on i18next when I need to set a component prop. i18next is sometimes not yet ready before I set this prop. Or is this outside the scope of this repo?

i18n.js

import i18n from 'i18next/lib';
import XHR from 'i18next-xhr-backend/lib';

i18n
    .use(XHR)
    .init({
        debug: true,
        lang: 'nl',
        fallbackLng: 'nl',
        defaultNS: 'translation',
        interpolation: {
            escapeValue: false
        }
  });

export default i18n;

form.js

import i18next from './i18n.js'; // instance

export default React.createClass({
    render() {
        <Input
            name="name"
            placeholder={i18next.t('placeholder')}
        />
    };
});

st3phan avatar Jan 17 '16 12:01 st3phan

basically you don't use react-i18next. react-i18next solves this when you use the hoc (higher order component) -> https://github.com/i18next/react-i18next#translate-hoc

jamuhl avatar Jan 17 '16 12:01 jamuhl

can this be closed?

jamuhl avatar Jan 22 '16 12:01 jamuhl