Skip to content

Commit

Permalink
Merge 36f0400 into 36dad75
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Mar 7, 2018
2 parents 36dad75 + 36f0400 commit 12390a6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/I18n.js
Expand Up @@ -32,10 +32,7 @@ export default class I18n extends Component {
const language = this.i18n.languages && this.i18n.languages[0];
const ready = !!language && this.namespaces.every(ns => this.i18n.hasResourceBundle(language, ns));

this.state = {
i18nLoadedAt: null,
ready
};
this.state = { ready };

this.onI18nChanged = this.onI18nChanged.bind(this);
this.getI18nTranslate = this.getI18nTranslate.bind(this);
Expand Down Expand Up @@ -101,7 +98,6 @@ export default class I18n extends Component {
if (!this.mounted) return;

this.t = this.getI18nTranslate();
this.setState({ i18nLoadedAt: new Date() });
}

getI18nTranslate() {
Expand All @@ -122,7 +118,11 @@ export default class I18n extends Component {
}, 100);
}

return children(this.t, { i18n: this.i18n, t: this.t });
return children(this.t, {
i18n: this.i18n,
t: this.t,
ready
});
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/translate.js
Expand Up @@ -63,9 +63,14 @@ export default function translate(namespaceArg, options = {}) {
return React.createElement(
I18n,
{ ns: this.namespaces, ...this.options, ...this.props, ...{ i18n: this.i18n } },
(t, context) => React.createElement(
(t, { ready, ...context }) => React.createElement(
WrappedComponent,
{ ...this.props, ...extraProps, ...context }
{
tReady: ready,
...this.props,
...extraProps,
...context
}
)
);
}
Expand Down
2 changes: 1 addition & 1 deletion test/translate.render.wait.spec.js
Expand Up @@ -21,7 +21,7 @@ const context = {
i18n: newI18n
};

describe.only('translate wait', () => {
describe('translate wait', () => {
const TestElement = ({ t }) => {
return (
<div>{t('key1')}</div>
Expand Down

0 comments on commit 12390a6

Please sign in to comment.