intor 1.0.30 → 1.0.31

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.
@@ -753,6 +753,17 @@ var localizePathname = ({
753
753
  var shouldUseFullReload = (loaderOptions) => {
754
754
  return (loaderOptions == null ? void 0 : loaderOptions.type) === "import" || (loaderOptions == null ? void 0 : loaderOptions.type) === "api" && loaderOptions.fullReload === true;
755
755
  };
756
+ var usePathname = () => {
757
+ const { config } = useIntorConfig();
758
+ const { locale } = useIntorLocale();
759
+ const rawPathname = navigation.usePathname();
760
+ const { localePrefixedPathname } = localizePathname({
761
+ config,
762
+ pathname: rawPathname,
763
+ locale
764
+ });
765
+ return localePrefixedPathname;
766
+ };
756
767
 
757
768
  // src/adapters/next-client/tools/Link.tsx
758
769
  var Link = (_a) => {
@@ -768,9 +779,10 @@ var Link = (_a) => {
768
779
  const { config } = useIntorConfig();
769
780
  const { locale: currentLocale, setLocale } = useIntorLocale();
770
781
  const targetLocale = locale || currentLocale;
782
+ const pathname = usePathname();
771
783
  const { localePrefixedPathname } = localizePathname({
772
784
  config,
773
- pathname: href,
785
+ pathname: href != null ? href : pathname,
774
786
  locale: targetLocale
775
787
  });
776
788
  href = localePrefixedPathname;
@@ -782,6 +794,7 @@ var Link = (_a) => {
782
794
  return;
783
795
  }
784
796
  if (shouldUseFullReload(config.loaderOptions)) {
797
+ setLocaleCookieClient({ cookie: config.cookie, locale: targetLocale });
785
798
  window.location.href = href;
786
799
  return;
787
800
  } else {
@@ -790,17 +803,6 @@ var Link = (_a) => {
790
803
  };
791
804
  return /* @__PURE__ */ React7__namespace.createElement(NextLink__default.default, __spreadValues({ href, onClick: handleClick }, props), children);
792
805
  };
793
- var usePathname = () => {
794
- const { config } = useIntorConfig();
795
- const { locale } = useIntorLocale();
796
- const rawPathname = navigation.usePathname();
797
- const { localePrefixedPathname } = localizePathname({
798
- config,
799
- pathname: rawPathname,
800
- locale
801
- });
802
- return localePrefixedPathname;
803
- };
804
806
  var useRouter = () => {
805
807
  const { config } = useIntorConfig();
806
808
  const { locale: currentLocale, setLocale } = useIntorLocale();
@@ -178,7 +178,7 @@ declare function useIntor<M>(): TranslatorMethods<M> & Shared<M>;
178
178
  declare function useIntor<M, K extends string>(preKey: K): ScopedTranslatorMethods<M, K> & Shared<M>;
179
179
 
180
180
  type LinkProps = {
181
- href: string;
181
+ href?: string;
182
182
  locale?: string;
183
183
  children: React.ReactNode;
184
184
  } & Omit<LinkProps$1, "href" | "locale" | "children"> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
@@ -178,7 +178,7 @@ declare function useIntor<M>(): TranslatorMethods<M> & Shared<M>;
178
178
  declare function useIntor<M, K extends string>(preKey: K): ScopedTranslatorMethods<M, K> & Shared<M>;
179
179
 
180
180
  type LinkProps = {
181
- href: string;
181
+ href?: string;
182
182
  locale?: string;
183
183
  children: React.ReactNode;
184
184
  } & Omit<LinkProps$1, "href" | "locale" | "children"> & React.AnchorHTMLAttributes<HTMLAnchorElement>;
@@ -728,6 +728,17 @@ var localizePathname = ({
728
728
  var shouldUseFullReload = (loaderOptions) => {
729
729
  return (loaderOptions == null ? void 0 : loaderOptions.type) === "import" || (loaderOptions == null ? void 0 : loaderOptions.type) === "api" && loaderOptions.fullReload === true;
730
730
  };
731
+ var usePathname = () => {
732
+ const { config } = useIntorConfig();
733
+ const { locale } = useIntorLocale();
734
+ const rawPathname = usePathname$1();
735
+ const { localePrefixedPathname } = localizePathname({
736
+ config,
737
+ pathname: rawPathname,
738
+ locale
739
+ });
740
+ return localePrefixedPathname;
741
+ };
731
742
 
732
743
  // src/adapters/next-client/tools/Link.tsx
733
744
  var Link = (_a) => {
@@ -743,9 +754,10 @@ var Link = (_a) => {
743
754
  const { config } = useIntorConfig();
744
755
  const { locale: currentLocale, setLocale } = useIntorLocale();
745
756
  const targetLocale = locale || currentLocale;
757
+ const pathname = usePathname();
746
758
  const { localePrefixedPathname } = localizePathname({
747
759
  config,
748
- pathname: href,
760
+ pathname: href != null ? href : pathname,
749
761
  locale: targetLocale
750
762
  });
751
763
  href = localePrefixedPathname;
@@ -757,6 +769,7 @@ var Link = (_a) => {
757
769
  return;
758
770
  }
759
771
  if (shouldUseFullReload(config.loaderOptions)) {
772
+ setLocaleCookieClient({ cookie: config.cookie, locale: targetLocale });
760
773
  window.location.href = href;
761
774
  return;
762
775
  } else {
@@ -765,17 +778,6 @@ var Link = (_a) => {
765
778
  };
766
779
  return /* @__PURE__ */ React7.createElement(NextLink, __spreadValues({ href, onClick: handleClick }, props), children);
767
780
  };
768
- var usePathname = () => {
769
- const { config } = useIntorConfig();
770
- const { locale } = useIntorLocale();
771
- const rawPathname = usePathname$1();
772
- const { localePrefixedPathname } = localizePathname({
773
- config,
774
- pathname: rawPathname,
775
- locale
776
- });
777
- return localePrefixedPathname;
778
- };
779
781
  var useRouter = () => {
780
782
  const { config } = useIntorConfig();
781
783
  const { locale: currentLocale, setLocale } = useIntorLocale();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "intor",
3
- "version": "1.0.30",
3
+ "version": "1.0.31",
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",