intor 2.2.11 → 2.2.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/next/index.cjs +12 -5
- package/dist/next/index.d.cts +2 -1
- package/dist/next/index.d.ts +2 -1
- package/dist/next/index.js +12 -5
- package/dist/react/index.cjs +12 -5
- package/dist/react/index.d.cts +2 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +12 -5
- package/package.json +1 -1
package/dist/next/index.cjs
CHANGED
|
@@ -666,7 +666,7 @@ var changeLocale = ({
|
|
|
666
666
|
}
|
|
667
667
|
};
|
|
668
668
|
function LocaleProvider({
|
|
669
|
-
value: { initialLocale },
|
|
669
|
+
value: { initialLocale, onLocaleChange },
|
|
670
670
|
children
|
|
671
671
|
}) {
|
|
672
672
|
const { config } = useConfig();
|
|
@@ -676,7 +676,7 @@ function LocaleProvider({
|
|
|
676
676
|
useInitLazyLoad({ loaderOptions, currentLocale });
|
|
677
677
|
useInitLocaleCookie({ config, locale: initialLocale });
|
|
678
678
|
const setLocale = React6__namespace.useCallback(
|
|
679
|
-
(newLocale) => {
|
|
679
|
+
async (newLocale) => {
|
|
680
680
|
changeLocale({
|
|
681
681
|
currentLocale,
|
|
682
682
|
newLocale,
|
|
@@ -685,8 +685,9 @@ function LocaleProvider({
|
|
|
685
685
|
setLocale: setCurrentLocale,
|
|
686
686
|
refetchMessages
|
|
687
687
|
});
|
|
688
|
+
onLocaleChange?.(newLocale);
|
|
688
689
|
},
|
|
689
|
-
[currentLocale, loaderOptions, cookie, refetchMessages]
|
|
690
|
+
[currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
|
|
690
691
|
);
|
|
691
692
|
const value = React6__namespace.useMemo(
|
|
692
693
|
() => ({
|
|
@@ -925,10 +926,16 @@ function useTranslator() {
|
|
|
925
926
|
return context;
|
|
926
927
|
}
|
|
927
928
|
var IntorProvider = ({
|
|
928
|
-
value: {
|
|
929
|
+
value: {
|
|
930
|
+
config,
|
|
931
|
+
pathname = "",
|
|
932
|
+
initialLocale,
|
|
933
|
+
messages = config.messages,
|
|
934
|
+
onLocaleChange
|
|
935
|
+
},
|
|
929
936
|
children
|
|
930
937
|
}) => {
|
|
931
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
|
|
938
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
|
|
932
939
|
};
|
|
933
940
|
|
|
934
941
|
// src/client/react/hooks/use-translator.ts
|
package/dist/next/index.d.cts
CHANGED
|
@@ -223,11 +223,12 @@ interface IntorProviderProps {
|
|
|
223
223
|
initialLocale: Locale;
|
|
224
224
|
pathname?: string;
|
|
225
225
|
messages?: Readonly<LocaleMessages>;
|
|
226
|
+
onLocaleChange?: (newLocale: string) => Promise<void> | void;
|
|
226
227
|
};
|
|
227
228
|
children: React.ReactNode;
|
|
228
229
|
}
|
|
229
230
|
|
|
230
|
-
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
231
|
+
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
231
232
|
|
|
232
233
|
type TranslateHandlersProviderProps = {
|
|
233
234
|
children: React.ReactNode;
|
package/dist/next/index.d.ts
CHANGED
|
@@ -223,11 +223,12 @@ interface IntorProviderProps {
|
|
|
223
223
|
initialLocale: Locale;
|
|
224
224
|
pathname?: string;
|
|
225
225
|
messages?: Readonly<LocaleMessages>;
|
|
226
|
+
onLocaleChange?: (newLocale: string) => Promise<void> | void;
|
|
226
227
|
};
|
|
227
228
|
children: React.ReactNode;
|
|
228
229
|
}
|
|
229
230
|
|
|
230
|
-
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
231
|
+
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
231
232
|
|
|
232
233
|
type TranslateHandlersProviderProps = {
|
|
233
234
|
children: React.ReactNode;
|
package/dist/next/index.js
CHANGED
|
@@ -639,7 +639,7 @@ var changeLocale = ({
|
|
|
639
639
|
}
|
|
640
640
|
};
|
|
641
641
|
function LocaleProvider({
|
|
642
|
-
value: { initialLocale },
|
|
642
|
+
value: { initialLocale, onLocaleChange },
|
|
643
643
|
children
|
|
644
644
|
}) {
|
|
645
645
|
const { config } = useConfig();
|
|
@@ -649,7 +649,7 @@ function LocaleProvider({
|
|
|
649
649
|
useInitLazyLoad({ loaderOptions, currentLocale });
|
|
650
650
|
useInitLocaleCookie({ config, locale: initialLocale });
|
|
651
651
|
const setLocale = React6.useCallback(
|
|
652
|
-
(newLocale) => {
|
|
652
|
+
async (newLocale) => {
|
|
653
653
|
changeLocale({
|
|
654
654
|
currentLocale,
|
|
655
655
|
newLocale,
|
|
@@ -658,8 +658,9 @@ function LocaleProvider({
|
|
|
658
658
|
setLocale: setCurrentLocale,
|
|
659
659
|
refetchMessages
|
|
660
660
|
});
|
|
661
|
+
onLocaleChange?.(newLocale);
|
|
661
662
|
},
|
|
662
|
-
[currentLocale, loaderOptions, cookie, refetchMessages]
|
|
663
|
+
[currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
|
|
663
664
|
);
|
|
664
665
|
const value = React6.useMemo(
|
|
665
666
|
() => ({
|
|
@@ -898,10 +899,16 @@ function useTranslator() {
|
|
|
898
899
|
return context;
|
|
899
900
|
}
|
|
900
901
|
var IntorProvider = ({
|
|
901
|
-
value: {
|
|
902
|
+
value: {
|
|
903
|
+
config,
|
|
904
|
+
pathname = "",
|
|
905
|
+
initialLocale,
|
|
906
|
+
messages = config.messages,
|
|
907
|
+
onLocaleChange
|
|
908
|
+
},
|
|
902
909
|
children
|
|
903
910
|
}) => {
|
|
904
|
-
return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
|
|
911
|
+
return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
|
|
905
912
|
};
|
|
906
913
|
|
|
907
914
|
// src/client/react/hooks/use-translator.ts
|
package/dist/react/index.cjs
CHANGED
|
@@ -522,7 +522,7 @@ var changeLocale = ({
|
|
|
522
522
|
}
|
|
523
523
|
};
|
|
524
524
|
function LocaleProvider({
|
|
525
|
-
value: { initialLocale },
|
|
525
|
+
value: { initialLocale, onLocaleChange },
|
|
526
526
|
children
|
|
527
527
|
}) {
|
|
528
528
|
const { config } = useConfig();
|
|
@@ -532,7 +532,7 @@ function LocaleProvider({
|
|
|
532
532
|
useInitLazyLoad({ loaderOptions, currentLocale });
|
|
533
533
|
useInitLocaleCookie({ config, locale: initialLocale });
|
|
534
534
|
const setLocale = React6__namespace.useCallback(
|
|
535
|
-
(newLocale) => {
|
|
535
|
+
async (newLocale) => {
|
|
536
536
|
changeLocale({
|
|
537
537
|
currentLocale,
|
|
538
538
|
newLocale,
|
|
@@ -541,8 +541,9 @@ function LocaleProvider({
|
|
|
541
541
|
setLocale: setCurrentLocale,
|
|
542
542
|
refetchMessages
|
|
543
543
|
});
|
|
544
|
+
onLocaleChange?.(newLocale);
|
|
544
545
|
},
|
|
545
|
-
[currentLocale, loaderOptions, cookie, refetchMessages]
|
|
546
|
+
[currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
|
|
546
547
|
);
|
|
547
548
|
const value = React6__namespace.useMemo(
|
|
548
549
|
() => ({
|
|
@@ -621,10 +622,16 @@ function useTranslator() {
|
|
|
621
622
|
return context;
|
|
622
623
|
}
|
|
623
624
|
var IntorProvider = ({
|
|
624
|
-
value: {
|
|
625
|
+
value: {
|
|
626
|
+
config,
|
|
627
|
+
pathname = "",
|
|
628
|
+
initialLocale,
|
|
629
|
+
messages = config.messages,
|
|
630
|
+
onLocaleChange
|
|
631
|
+
},
|
|
625
632
|
children
|
|
626
633
|
}) => {
|
|
627
|
-
return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
|
|
634
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsxRuntime.jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsxRuntime.jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsxRuntime.jsx(TranslatorProvider, { children }) }) }) });
|
|
628
635
|
};
|
|
629
636
|
|
|
630
637
|
// src/client/react/hooks/use-translator.ts
|
package/dist/react/index.d.cts
CHANGED
|
@@ -125,11 +125,12 @@ interface IntorProviderProps {
|
|
|
125
125
|
initialLocale: Locale;
|
|
126
126
|
pathname?: string;
|
|
127
127
|
messages?: Readonly<LocaleMessages>;
|
|
128
|
+
onLocaleChange?: (newLocale: string) => Promise<void> | void;
|
|
128
129
|
};
|
|
129
130
|
children: React.ReactNode;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
133
|
+
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
133
134
|
|
|
134
135
|
type TranslateHandlersProviderProps = {
|
|
135
136
|
children: React.ReactNode;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -125,11 +125,12 @@ interface IntorProviderProps {
|
|
|
125
125
|
initialLocale: Locale;
|
|
126
126
|
pathname?: string;
|
|
127
127
|
messages?: Readonly<LocaleMessages>;
|
|
128
|
+
onLocaleChange?: (newLocale: string) => Promise<void> | void;
|
|
128
129
|
};
|
|
129
130
|
children: React.ReactNode;
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
133
|
+
declare const IntorProvider: ({ value: { config, pathname, initialLocale, messages, onLocaleChange, }, children, }: IntorProviderProps) => react_jsx_runtime.JSX.Element;
|
|
133
134
|
|
|
134
135
|
type TranslateHandlersProviderProps = {
|
|
135
136
|
children: React.ReactNode;
|
package/dist/react/index.js
CHANGED
|
@@ -496,7 +496,7 @@ var changeLocale = ({
|
|
|
496
496
|
}
|
|
497
497
|
};
|
|
498
498
|
function LocaleProvider({
|
|
499
|
-
value: { initialLocale },
|
|
499
|
+
value: { initialLocale, onLocaleChange },
|
|
500
500
|
children
|
|
501
501
|
}) {
|
|
502
502
|
const { config } = useConfig();
|
|
@@ -506,7 +506,7 @@ function LocaleProvider({
|
|
|
506
506
|
useInitLazyLoad({ loaderOptions, currentLocale });
|
|
507
507
|
useInitLocaleCookie({ config, locale: initialLocale });
|
|
508
508
|
const setLocale = React6.useCallback(
|
|
509
|
-
(newLocale) => {
|
|
509
|
+
async (newLocale) => {
|
|
510
510
|
changeLocale({
|
|
511
511
|
currentLocale,
|
|
512
512
|
newLocale,
|
|
@@ -515,8 +515,9 @@ function LocaleProvider({
|
|
|
515
515
|
setLocale: setCurrentLocale,
|
|
516
516
|
refetchMessages
|
|
517
517
|
});
|
|
518
|
+
onLocaleChange?.(newLocale);
|
|
518
519
|
},
|
|
519
|
-
[currentLocale, loaderOptions, cookie, refetchMessages]
|
|
520
|
+
[currentLocale, loaderOptions, cookie, refetchMessages, onLocaleChange]
|
|
520
521
|
);
|
|
521
522
|
const value = React6.useMemo(
|
|
522
523
|
() => ({
|
|
@@ -595,10 +596,16 @@ function useTranslator() {
|
|
|
595
596
|
return context;
|
|
596
597
|
}
|
|
597
598
|
var IntorProvider = ({
|
|
598
|
-
value: {
|
|
599
|
+
value: {
|
|
600
|
+
config,
|
|
601
|
+
pathname = "",
|
|
602
|
+
initialLocale,
|
|
603
|
+
messages = config.messages,
|
|
604
|
+
onLocaleChange
|
|
605
|
+
},
|
|
599
606
|
children
|
|
600
607
|
}) => {
|
|
601
|
-
return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
|
|
608
|
+
return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsx(TranslatorProvider, { children }) }) }) });
|
|
602
609
|
};
|
|
603
610
|
|
|
604
611
|
// src/client/react/hooks/use-translator.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intor",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.12",
|
|
4
4
|
"description": "A modular and extensible i18n core designed for TypeScript and JavaScript projects. Intor enables custom translation logic with support for both frontend and backend environments, featuring runtime configuration, caching, adapters, and message loaders.",
|
|
5
5
|
"author": "Yiming Liao",
|
|
6
6
|
"license": "MIT",
|