Skip to content
This repository has been archived by the owner on May 19, 2022. It is now read-only.

Commit

Permalink
fix: make i18next component use the same code as $t for getting tranl…
Browse files Browse the repository at this point in the history
…ations

When loading translations dynamically the i18next component would not update correctly, but this.$t would.
This makes i18next component use the same code to get the translations so it will update.
  • Loading branch information
Ray Bateman authored and Ray Bateman committed Jan 30, 2020
1 parent 6949579 commit 98666b2
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ export default {
},
render(h, { props, data, children, parent }) {
const i18next = parent.$i18n;
if (!i18next) {
const $t = parent.$t.bind(parent);
if (!i18next || !$t) {
return h(props.tag, data, children);
}

const { path } = props;
const options = props.options || {};

const REGEXP = i18next.i18next.services.interpolator.regexp;
const format = i18next.t(path, {
const i18nextOptions = {
...options,
interpolation: { prefix: '#$?', suffix: '?$#' }
});
};
const format = $t(path, i18nextOptions);
const tchildren = [];

format.split(REGEXP).reduce((memo, match, index) => {
Expand Down

0 comments on commit 98666b2

Please sign in to comment.