Skip to content

Commit 365a424

Browse files
committed
release
1 parent 87e658f commit 365a424

File tree

3 files changed

+83
-92
lines changed

3 files changed

+83
-92
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 15.5.3
2+
3+
chore: update `@babel/runtime` [1851](https://github.com/i18next/react-i18next/pull/1851)
4+
15
### 15.5.2
26

37
fix element.ref access issue with react 19 [1846](https://github.com/i18next/react-i18next/pull/1846)

react-i18next.js

Lines changed: 78 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@
163163
});
164164
i18n.loadLanguages(lng, loadedClb(i18n, cb));
165165
};
166-
const hasLoadedNamespace = function (ns, i18n) {
167-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
166+
const hasLoadedNamespace = (ns, i18n, options = {}) => {
168167
if (!i18n.languages || !i18n.languages.length) {
169168
warnOnce(i18n, 'NO_LANGUAGES', 'i18n.languages were undefined or empty', {
170169
languages: i18n.languages
@@ -218,8 +217,7 @@
218217
useSuspense: true,
219218
unescape
220219
};
221-
const setDefaults = function () {
222-
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
220+
const setDefaults = (options = {}) => {
223221
defaultOptions = {
224222
...defaultOptions,
225223
...options
@@ -471,23 +469,22 @@
471469
});
472470
return null;
473471
};
474-
function Trans$1(_ref) {
475-
let {
476-
children,
477-
count,
478-
parent,
479-
i18nKey,
480-
context,
481-
tOptions = {},
482-
values,
483-
defaults,
484-
components,
485-
ns,
486-
i18n: i18nFromProps,
487-
t: tFromProps,
488-
shouldUnescape,
489-
...additionalProps
490-
} = _ref;
472+
function Trans$1({
473+
children,
474+
count,
475+
parent,
476+
i18nKey,
477+
context,
478+
tOptions = {},
479+
values,
480+
defaults,
481+
components,
482+
ns,
483+
i18n: i18nFromProps,
484+
t: tFromProps,
485+
shouldUnescape,
486+
...additionalProps
487+
}) {
491488
const i18n = i18nFromProps || getI18n();
492489
if (!i18n) {
493490
warnOnce(i18n, 'NO_I18NEXT_INSTANCE', `Trans: You need to pass in an i18next instance using i18nextReactModule`, {
@@ -585,23 +582,22 @@
585582
return ret;
586583
};
587584

588-
function Trans(_ref) {
589-
let {
590-
children,
591-
count,
592-
parent,
593-
i18nKey,
594-
context,
595-
tOptions = {},
596-
values,
597-
defaults,
598-
components,
599-
ns,
600-
i18n: i18nFromProps,
601-
t: tFromProps,
602-
shouldUnescape,
603-
...additionalProps
604-
} = _ref;
585+
function Trans({
586+
children,
587+
count,
588+
parent,
589+
i18nKey,
590+
context,
591+
tOptions = {},
592+
values,
593+
defaults,
594+
components,
595+
ns,
596+
i18n: i18nFromProps,
597+
t: tFromProps,
598+
shouldUnescape,
599+
...additionalProps
600+
}) {
605601
const {
606602
i18n: i18nFromContext,
607603
defaultNS: defaultNSFromContext
@@ -635,8 +631,7 @@
635631
};
636632
const alwaysNewT = (i18n, language, namespace, keyPrefix) => i18n.getFixedT(language, namespace, keyPrefix);
637633
const useMemoizedT = (i18n, language, namespace, keyPrefix) => react.useCallback(alwaysNewT(i18n, language, namespace, keyPrefix), [i18n, language, namespace, keyPrefix]);
638-
const useTranslation = function (ns) {
639-
let props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
634+
const useTranslation = (ns, props = {}) => {
640635
const {
641636
i18n: i18nFromProps
642637
} = props;
@@ -732,59 +727,53 @@
732727
});
733728
};
734729

735-
const withTranslation = function (ns) {
736-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
737-
return function Extend(WrappedComponent) {
738-
function I18nextWithTranslation(_ref) {
739-
let {
740-
forwardedRef,
741-
...rest
742-
} = _ref;
743-
const [t, i18n, ready] = useTranslation(ns, {
744-
...rest,
745-
keyPrefix: options.keyPrefix
746-
});
747-
const passDownProps = {
748-
...rest,
749-
t,
750-
i18n,
751-
tReady: ready
752-
};
753-
if (options.withRef && forwardedRef) {
754-
passDownProps.ref = forwardedRef;
755-
} else if (!options.withRef && forwardedRef) {
756-
passDownProps.forwardedRef = forwardedRef;
757-
}
758-
return react.createElement(WrappedComponent, passDownProps);
730+
const withTranslation = (ns, options = {}) => function Extend(WrappedComponent) {
731+
function I18nextWithTranslation({
732+
forwardedRef,
733+
...rest
734+
}) {
735+
const [t, i18n, ready] = useTranslation(ns, {
736+
...rest,
737+
keyPrefix: options.keyPrefix
738+
});
739+
const passDownProps = {
740+
...rest,
741+
t,
742+
i18n,
743+
tReady: ready
744+
};
745+
if (options.withRef && forwardedRef) {
746+
passDownProps.ref = forwardedRef;
747+
} else if (!options.withRef && forwardedRef) {
748+
passDownProps.forwardedRef = forwardedRef;
759749
}
760-
I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
761-
I18nextWithTranslation.WrappedComponent = WrappedComponent;
762-
const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
763-
forwardedRef: ref
764-
}));
765-
return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
766-
};
750+
return react.createElement(WrappedComponent, passDownProps);
751+
}
752+
I18nextWithTranslation.displayName = `withI18nextTranslation(${getDisplayName(WrappedComponent)})`;
753+
I18nextWithTranslation.WrappedComponent = WrappedComponent;
754+
const forwardRef = (props, ref) => react.createElement(I18nextWithTranslation, Object.assign({}, props, {
755+
forwardedRef: ref
756+
}));
757+
return options.withRef ? react.forwardRef(forwardRef) : I18nextWithTranslation;
767758
};
768759

769-
const Translation = _ref => {
770-
let {
771-
ns,
772-
children,
773-
...options
774-
} = _ref;
760+
const Translation = ({
761+
ns,
762+
children,
763+
...options
764+
}) => {
775765
const [t, i18n, ready] = useTranslation(ns, options);
776766
return children(t, {
777767
i18n,
778768
lng: i18n.language
779769
}, ready);
780770
};
781771

782-
function I18nextProvider(_ref) {
783-
let {
784-
i18n,
785-
defaultNS,
786-
children
787-
} = _ref;
772+
function I18nextProvider({
773+
i18n,
774+
defaultNS,
775+
children
776+
}) {
788777
const value = react.useMemo(() => ({
789778
i18n,
790779
defaultNS
@@ -794,8 +783,7 @@
794783
}, children);
795784
}
796785

797-
const useSSR = function (initialI18nStore, initialLanguage) {
798-
let props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
786+
const useSSR = (initialI18nStore, initialLanguage, props = {}) => {
799787
const {
800788
i18n: i18nFromProps
801789
} = props;
@@ -822,12 +810,11 @@
822810
};
823811

824812
const withSSR = () => function Extend(WrappedComponent) {
825-
function I18nextWithSSR(_ref) {
826-
let {
827-
initialI18nStore,
828-
initialLanguage,
829-
...rest
830-
} = _ref;
813+
function I18nextWithSSR({
814+
initialI18nStore,
815+
initialLanguage,
816+
...rest
817+
}) {
831818
useSSR(initialI18nStore, initialLanguage);
832819
return react.createElement(WrappedComponent, {
833820
...rest

0 commit comments

Comments
 (0)