Skip to content

Commit

Permalink
rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuhl committed May 30, 2019
1 parent a52dcc7 commit e5bf6c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### 10.11.0

- Restore support passing the defaultNS via I18nextProvider prop [860](https://github.com/i18next/react-i18next/pull/860)

### 10.10.0

- HOC: expose wrapped component as WrappedComponent property [853](https://github.com/i18next/react-i18next/pull/853)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-i18next",
"version": "10.10.0",
"version": "10.11.0",
"description": "Internationalization for react done right. Using the i18next i18n ecosystem.",
"main": "dist/commonjs/index.js",
"types": "src/index.d.ts",
Expand Down
19 changes: 13 additions & 6 deletions react-i18next.js
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@
additionalProps = _objectWithoutProperties(_ref, ["children", "count", "parent", "i18nKey", "tOptions", "values", "defaults", "components", "ns", "i18n", "t"]);

const _ref2 = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
i18nFromContext = _ref2.i18n;
i18nFromContext = _ref2.i18n,
defaultNSFromContext = _ref2.defaultNS;

const i18n = i18nFromProps || i18nFromContext || getI18n();

Expand All @@ -695,7 +696,10 @@

const reactI18nextOptions = _objectSpread({}, getDefaults(), i18n.options && i18n.options.react);

const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent;
const useAsParent = parent !== undefined ? parent : reactI18nextOptions.defaultTransParent; // prepare having a namespace

let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation'];
const defaultValue = defaults || nodesToString('', children, 0, reactI18nextOptions) || reactI18nextOptions.transEmptyNodeValue;
const hashTransKey = reactI18nextOptions.hashTransKey;
const key = i18nKey || (hashTransKey ? hashTransKey(defaultValue) : defaultValue);
Expand All @@ -709,7 +713,7 @@
const combinedTOpts = _objectSpread({}, tOptions, values, interpolationOverride, {
defaultValue,
count,
ns
ns: namespaces
});

const translation = key ? t(key, combinedTOpts) : defaultValue;
Expand All @@ -723,7 +727,8 @@
const i18nFromProps = props.i18n;

const _ref = getHasUsedI18nextProvider() ? React.useContext(I18nContext) : {},
i18nFromContext = _ref.i18n;
i18nFromContext = _ref.i18n,
defaultNSFromContext = _ref.defaultNS;

const i18n = i18nFromProps || i18nFromContext || getI18n();
if (i18n && !i18n.reportNamespaces) i18n.reportNamespaces = new ReportNamespaces();
Expand All @@ -744,7 +749,7 @@
const _props$useSuspense = props.useSuspense,
useSuspense = _props$useSuspense === void 0 ? i18nOptions.useSuspense : _props$useSuspense; // prepare having a namespace

let namespaces = ns || i18n.options && i18n.options.defaultNS;
let namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
namespaces = typeof namespaces === 'string' ? [namespaces] : namespaces || ['translation']; // report namespaces as used

if (i18n.reportNamespaces.addUsedNamespaces) i18n.reportNamespaces.addUsedNamespaces(namespaces); // are we ready? yes if all namespaces in first language are loaded already (either with data or empty object on failed load)
Expand Down Expand Up @@ -855,11 +860,13 @@

function I18nextProvider(_ref) {
let i18n = _ref.i18n,
defaultNS = _ref.defaultNS,
children = _ref.children;
usedI18nextProvider(true);
return React__default.createElement(I18nContext.Provider, {
value: {
i18n
i18n,
defaultNS
}
}, children);
}
Expand Down
Loading

0 comments on commit e5bf6c2

Please sign in to comment.