intor 2.2.11 → 2.2.13

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.
@@ -1,6 +1,6 @@
1
1
  import { formatUrl } from 'next/dist/shared/lib/router/utils/format-url';
2
2
  import NextLink from 'next/link';
3
- import * as React6 from 'react';
3
+ import * as React7 from 'react';
4
4
  import { usePathname as usePathname$1, useRouter as useRouter$1, redirect as redirect$1 } from 'next/navigation';
5
5
  import merge from 'lodash.merge';
6
6
  import { jsx } from 'react/jsx-runtime';
@@ -254,20 +254,71 @@ var localizePathname = ({
254
254
  localePrefixedPathname
255
255
  };
256
256
  };
257
- var ConfigContext = React6.createContext(void 0);
257
+ var ConfigContext = React7.createContext(void 0);
258
258
  function ConfigProvider({
259
259
  value: { config, pathname },
260
260
  children
261
261
  }) {
262
- const value = React6.useMemo(() => ({ config, pathname }), [config, pathname]);
262
+ const value = React7.useMemo(() => ({ config, pathname }), [config, pathname]);
263
263
  return /* @__PURE__ */ jsx(ConfigContext.Provider, { value, children });
264
264
  }
265
265
  function useConfig() {
266
- const context = React6.useContext(ConfigContext);
266
+ const context = React7.useContext(ConfigContext);
267
267
  if (!context) throw new Error("useConfig must be used within ConfigProvider");
268
268
  return context;
269
269
  }
270
270
 
271
+ // src/shared/utils/client/build-cookie-string.ts
272
+ var buildCookieString = (cookie, locale) => {
273
+ const parts = [`${cookie.name}=${encodeURIComponent(locale)}`];
274
+ if (cookie.maxAge) {
275
+ const expires = new Date(Date.now() + cookie.maxAge * 1e3).toUTCString();
276
+ parts.push(`expires=${expires}`, `max-age=${cookie.maxAge}`);
277
+ }
278
+ parts.push(`path=${cookie.path ?? "/"}`);
279
+ if (cookie.domain) {
280
+ parts.push(`domain=${cookie.domain}`);
281
+ }
282
+ if (cookie.sameSite) {
283
+ parts.push(
284
+ `SameSite=${cookie.sameSite[0].toUpperCase()}${cookie.sameSite.slice(1).toLowerCase()}`
285
+ );
286
+ }
287
+ if (cookie.secure !== false) {
288
+ parts.push(`Secure`);
289
+ }
290
+ return parts.join("; ");
291
+ };
292
+
293
+ // src/shared/utils/client/set-locale-cookie-browser.ts
294
+ var setLocaleCookieBrowser = ({
295
+ cookie,
296
+ locale
297
+ }) => {
298
+ if (typeof document === "undefined") return;
299
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
300
+ const cookieString = buildCookieString(cookie, locale);
301
+ document.cookie = cookieString;
302
+ };
303
+
304
+ // src/client/react/contexts/locale/utils/use-init-locale-cookie.ts
305
+ var useInitLocaleCookie = ({
306
+ config,
307
+ locale
308
+ }) => {
309
+ React7.useEffect(() => {
310
+ if (typeof document === "undefined") return;
311
+ const { cookie, routing } = config;
312
+ const { firstVisit } = routing;
313
+ const cookies2 = document.cookie.split(";").map((c) => c.trim());
314
+ const isCookieExists = cookies2.some((c) => c.startsWith(`${cookie.name}=`));
315
+ if (isCookieExists) return;
316
+ if (!firstVisit.redirect) return;
317
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
318
+ setLocaleCookieBrowser({ cookie, locale });
319
+ }, []);
320
+ };
321
+
271
322
  // src/config/constants/cache.constants.ts
272
323
  var DEFAULT_CACHE_OPTIONS = {
273
324
  enabled: process.env.NODE_ENV === "production",
@@ -475,19 +526,19 @@ var useRefetchMessages = ({
475
526
  setLoadedMessages,
476
527
  setIsLoadingMessages
477
528
  }) => {
478
- const { messages: staticMessages } = config;
479
- const namespaces = React6.useMemo(() => {
480
- if (!config.loader) return [];
529
+ const { messages: staticMessages, loader } = config;
530
+ const namespaces = React7.useMemo(() => {
531
+ if (!loader) return [];
481
532
  return resolveNamespaces({ config, pathname });
482
533
  }, [config, pathname]);
483
- const refetchMessages = React6.useCallback(
534
+ const refetchMessages = React7.useCallback(
484
535
  async (newLocale) => {
485
- if (config.loader?.type === "remote") {
536
+ if (loader?.type === "remote") {
486
537
  setIsLoadingMessages(true);
487
538
  const loadedMessages = await loadRemoteMessages({
488
- rootDir: config.loader.rootDir,
489
- remoteUrl: config.loader.remoteUrl,
490
- remoteHeaders: config.loader.remoteHeaders,
539
+ rootDir: loader.rootDir,
540
+ remoteUrl: loader.remoteUrl,
541
+ remoteHeaders: loader.remoteHeaders,
491
542
  locale: newLocale,
492
543
  fallbackLocales: config.fallbackLocales[newLocale] || [],
493
544
  namespaces,
@@ -502,8 +553,9 @@ var useRefetchMessages = ({
502
553
  }
503
554
  },
504
555
  [
505
- config.loader,
556
+ loader,
506
557
  config.fallbackLocales,
558
+ config.cache,
507
559
  config.id,
508
560
  setIsLoadingMessages,
509
561
  namespaces,
@@ -513,21 +565,21 @@ var useRefetchMessages = ({
513
565
  );
514
566
  return { refetchMessages };
515
567
  };
516
- var MessagesContext = React6.createContext(void 0);
568
+ var MessagesContext = React7.createContext(void 0);
517
569
  function MessagesProvider({
518
570
  value: { messages = {} },
519
571
  children
520
572
  }) {
521
573
  const { config, pathname } = useConfig();
522
- const [loadedMessages, setLoadedMessages] = React6.useState(null);
523
- const [isLoadingMessages, setIsLoadingMessages] = React6.useState(false);
574
+ const [loadedMessages, setLoadedMessages] = React7.useState(null);
575
+ const [isLoadingMessages, setIsLoadingMessages] = React7.useState(false);
524
576
  const { refetchMessages } = useRefetchMessages({
525
577
  config,
526
578
  pathname,
527
579
  setLoadedMessages,
528
580
  setIsLoadingMessages
529
581
  });
530
- const value = React6.useMemo(
582
+ const value = React7.useMemo(
531
583
  () => ({
532
584
  messages: loadedMessages || messages,
533
585
  isLoading: isLoadingMessages,
@@ -540,128 +592,61 @@ function MessagesProvider({
540
592
  return /* @__PURE__ */ jsx(MessagesContext.Provider, { value, children });
541
593
  }
542
594
  function useMessages() {
543
- const context = React6.useContext(MessagesContext);
595
+ const context = React7.useContext(MessagesContext);
544
596
  if (!context)
545
597
  throw new Error("useMessages must be used within a MessagesProvider");
546
598
  return context;
547
599
  }
548
-
549
- // src/client/react/contexts/locale/utils/use-init-lazy-load.ts
550
- var useInitLazyLoad = ({
551
- loaderOptions,
552
- currentLocale
553
- }) => {
554
- const { refetchMessages } = useMessages();
555
- const lazyLoad = !!loaderOptions?.lazyLoad;
556
- const isFirstLoadedRef = React6.useRef(false);
557
- React6.useEffect(() => {
558
- if (lazyLoad && !isFirstLoadedRef.current) {
559
- void refetchMessages(currentLocale);
560
- isFirstLoadedRef.current = true;
561
- }
562
- }, [lazyLoad, currentLocale, refetchMessages, isFirstLoadedRef]);
563
- };
564
-
565
- // src/shared/utils/client/build-cookie-string.ts
566
- var buildCookieString = (cookie, locale) => {
567
- const parts = [`${cookie.name}=${encodeURIComponent(locale)}`];
568
- if (cookie.maxAge) {
569
- const expires = new Date(Date.now() + cookie.maxAge * 1e3).toUTCString();
570
- parts.push(`expires=${expires}`, `max-age=${cookie.maxAge}`);
571
- }
572
- parts.push(`path=${cookie.path ?? "/"}`);
573
- if (cookie.domain) {
574
- parts.push(`domain=${cookie.domain}`);
575
- }
576
- if (cookie.sameSite) {
577
- parts.push(
578
- `SameSite=${cookie.sameSite[0].toUpperCase()}${cookie.sameSite.slice(1).toLowerCase()}`
579
- );
580
- }
581
- if (cookie.secure !== false) {
582
- parts.push(`Secure`);
583
- }
584
- return parts.join("; ");
585
- };
586
-
587
- // src/shared/utils/client/set-locale-cookie-browser.ts
588
- var setLocaleCookieBrowser = ({
589
- cookie,
590
- locale
591
- }) => {
592
- if (globalThis.window === void 0) return;
593
- if (cookie.disabled || !cookie.autoSetCookie) return;
594
- const cookieString = buildCookieString(cookie, locale);
595
- document.cookie = cookieString;
596
- };
597
-
598
- // src/client/react/contexts/locale/utils/use-init-locale-cookie.ts
599
- var useInitLocaleCookie = ({
600
- config,
601
- locale
602
- }) => {
603
- React6.useEffect(() => {
604
- if (typeof document === "undefined") return;
605
- const { cookie, routing } = config;
606
- const { firstVisit } = routing;
607
- const cookies2 = document.cookie.split(";").map((c) => c.trim());
608
- const isCookieExists = cookies2.some((c) => c.startsWith(`${cookie.name}=`));
609
- if (isCookieExists) return;
610
- if (!firstVisit.redirect) return;
611
- if (cookie.disabled || !cookie.autoSetCookie) return;
612
- setLocaleCookieBrowser({ cookie, locale });
613
- }, []);
614
- };
615
- var LocaleContext = React6.createContext(void 0);
600
+ var LocaleContext = React7.createContext(void 0);
616
601
 
617
602
  // src/client/react/contexts/locale/utils/change-locale.ts
618
603
  var changeLocale = ({
619
604
  currentLocale,
620
605
  newLocale,
621
- loaderOptions,
606
+ loader,
622
607
  cookie,
623
608
  setLocale,
624
609
  refetchMessages
625
610
  }) => {
626
611
  if (typeof document === "undefined") return;
627
- const loaderType = loaderOptions?.type;
612
+ const { type } = loader || {};
628
613
  if (newLocale === currentLocale) return;
629
- if (loaderType === "local") {
614
+ if (type === "local") {
630
615
  console.warn(
631
- `[Intor] You are using dynamic local to switch languages. Please make sure to use the wrapped <Link> component to trigger a page reload, ensuring that the translation data is dynamically updated.`
616
+ `[Intor] You are using "loader type: local" to switch languages. Please make sure to use the wrapped <Link> component to trigger a page reload, ensuring that the translation data is dynamically updated.`
632
617
  );
633
618
  }
634
619
  setLocale(newLocale);
635
620
  setLocaleCookieBrowser({ cookie, locale: newLocale });
636
621
  document.documentElement.lang = newLocale;
637
- if (loaderType === "remote" && refetchMessages) {
622
+ if (type === "remote" && refetchMessages) {
638
623
  void refetchMessages(newLocale);
639
624
  }
640
625
  };
641
626
  function LocaleProvider({
642
- value: { initialLocale },
627
+ value: { initialLocale, onLocaleChange },
643
628
  children
644
629
  }) {
645
630
  const { config } = useConfig();
646
631
  const { refetchMessages } = useMessages();
647
- const { loader: loaderOptions, cookie } = config;
648
- const [currentLocale, setCurrentLocale] = React6.useState(initialLocale);
649
- useInitLazyLoad({ loaderOptions, currentLocale });
632
+ const { loader, cookie } = config;
633
+ const [currentLocale, setCurrentLocale] = React7.useState(initialLocale);
650
634
  useInitLocaleCookie({ config, locale: initialLocale });
651
- const setLocale = React6.useCallback(
652
- (newLocale) => {
635
+ const setLocale = React7.useCallback(
636
+ async (newLocale) => {
653
637
  changeLocale({
654
638
  currentLocale,
655
639
  newLocale,
656
- loaderOptions,
640
+ loader,
657
641
  cookie,
658
642
  setLocale: setCurrentLocale,
659
643
  refetchMessages
660
644
  });
645
+ onLocaleChange?.(newLocale);
661
646
  },
662
- [currentLocale, loaderOptions, cookie, refetchMessages]
647
+ [currentLocale, loader, cookie, refetchMessages, onLocaleChange]
663
648
  );
664
- const value = React6.useMemo(
649
+ const value = React7.useMemo(
665
650
  () => ({
666
651
  locale: currentLocale,
667
652
  setLocale
@@ -671,7 +656,7 @@ function LocaleProvider({
671
656
  return /* @__PURE__ */ jsx(LocaleContext.Provider, { value, children });
672
657
  }
673
658
  function useLocale() {
674
- const context = React6.useContext(LocaleContext);
659
+ const context = React7.useContext(LocaleContext);
675
660
  if (!context)
676
661
  throw new Error("useLocale must be used within a LocaleProvider");
677
662
  return context;
@@ -794,7 +779,7 @@ var getI18nContext = async (config) => {
794
779
  const headersStore = await headers();
795
780
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
796
781
  let locale;
797
- if (!cookie.disabled) {
782
+ if (cookie.enabled) {
798
783
  const localeFromCookie = cookiesStore.get(cookie.name)?.value;
799
784
  locale = normalizeLocale(localeFromCookie, supportedLocales);
800
785
  if (locale) {
@@ -836,61 +821,51 @@ var redirect = async ({
836
821
  });
837
822
  redirect$1(localePrefixedPathname, type);
838
823
  };
839
- var TranslateHandlersContext = React6.createContext(void 0);
824
+ var TranslateHandlersContext = React7.createContext(void 0);
840
825
  var TranslateHandlersProvider = ({
841
- children,
842
- handlers
826
+ handlers,
827
+ children
843
828
  }) => {
844
- const value = handlers;
845
- return /* @__PURE__ */ jsx(TranslateHandlersContext.Provider, { value, children });
829
+ return /* @__PURE__ */ jsx(TranslateHandlersContext.Provider, { value: { handlers }, children });
846
830
  };
847
831
  function useTranslateHandlers() {
848
- const context = React6.useContext(TranslateHandlersContext);
832
+ const context = React7.useContext(TranslateHandlersContext);
849
833
  return context;
850
834
  }
851
- var useInitLoadingState = (config) => {
852
- const lazyLoad = !!config.loader?.lazyLoad;
853
- const [isCsr, setIsCsr] = React6.useState(false);
854
- React6.useEffect(() => {
855
- setIsCsr(true);
856
- }, []);
857
- const isBeforeCSRLoading = lazyLoad && !isCsr;
858
- return isBeforeCSRLoading;
859
- };
860
- var TranslatorContext = React6.createContext(void 0);
861
- var EMPTY_OBJECT = Object.freeze({});
862
- function TranslatorProvider({ children }) {
835
+ var TranslatorContext = React7.createContext(void 0);
836
+ function TranslatorProvider({
837
+ value: { isLoading: externalIsLoading },
838
+ children
839
+ }) {
863
840
  const { config } = useConfig();
864
- const { messages, isLoading } = useMessages();
841
+ const { messages, isLoading: internalIsLoading } = useMessages();
865
842
  const { locale } = useLocale();
866
- const translatorHandlers = useTranslateHandlers();
843
+ const { handlers } = useTranslateHandlers();
867
844
  const { fallbackLocales, translator: translatorOptions } = config;
868
- const isBeforeCSRLoading = useInitLoadingState(config);
869
- const value = React6.useMemo(() => {
870
- const translator = new Translator({
871
- messages: messages || EMPTY_OBJECT,
845
+ const isLoading = Boolean(externalIsLoading ?? internalIsLoading);
846
+ const translator = React7.useMemo(() => {
847
+ return new Translator({
848
+ messages,
872
849
  locale,
850
+ isLoading,
873
851
  fallbackLocales,
874
852
  loadingMessage: translatorOptions?.loadingMessage,
875
853
  placeholder: translatorOptions?.placeholder,
876
- handlers: translatorHandlers
854
+ handlers
877
855
  });
878
- translator.setLoading(isBeforeCSRLoading || isLoading);
879
- return { translator };
880
856
  }, [
881
- fallbackLocales,
882
- isBeforeCSRLoading,
883
- isLoading,
884
- locale,
885
857
  messages,
886
- translatorHandlers,
858
+ locale,
859
+ isLoading,
860
+ fallbackLocales,
861
+ handlers,
887
862
  translatorOptions?.loadingMessage,
888
863
  translatorOptions?.placeholder
889
864
  ]);
890
- return /* @__PURE__ */ jsx(TranslatorContext.Provider, { value, children });
865
+ return /* @__PURE__ */ jsx(TranslatorContext.Provider, { value: { translator }, children });
891
866
  }
892
867
  function useTranslator() {
893
- const context = React6.useContext(TranslatorContext);
868
+ const context = React7.useContext(TranslatorContext);
894
869
  if (!context)
895
870
  throw new Error(
896
871
  "useTranslator must be used within IntorTranslatorProvider"
@@ -898,10 +873,17 @@ function useTranslator() {
898
873
  return context;
899
874
  }
900
875
  var IntorProvider = ({
901
- value: { config, pathname = "", initialLocale, messages = config.messages },
876
+ value: {
877
+ config,
878
+ pathname = "",
879
+ initialLocale,
880
+ messages = config.messages,
881
+ onLocaleChange,
882
+ isLoading
883
+ },
902
884
  children
903
885
  }) => {
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 }) }) }) });
886
+ return /* @__PURE__ */ jsx(ConfigProvider, { value: { config, pathname }, children: /* @__PURE__ */ jsx(MessagesProvider, { value: { messages }, children: /* @__PURE__ */ jsx(LocaleProvider, { value: { initialLocale, onLocaleChange }, children: /* @__PURE__ */ jsx(TranslatorProvider, { value: { isLoading }, children }) }) }) });
905
887
  };
906
888
 
907
889
  // src/client/react/hooks/use-translator.ts
@@ -14,7 +14,7 @@ function setLocaleCookieEdge({
14
14
  override = false
15
15
  // Default to not override existed cookie
16
16
  }) {
17
- if (cookie.disabled || !cookie.autoSetCookie) return;
17
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
18
18
  const isCookieExists = request.cookies.has(cookie.name);
19
19
  if (isCookieExists && !override) return;
20
20
  response.cookies.set(cookie.name, locale, {
@@ -3,8 +3,8 @@ import { Locale, LocaleMessages, FallbackLocalesMap } from 'intor-translator';
3
3
  import { NextRequest } from 'next/server';
4
4
 
5
5
  type CookieRawOptions = {
6
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
7
- disabled?: boolean;
6
+ /** Enable cookie usage (read/write) - default: true */
7
+ enabled?: boolean;
8
8
  /** Allow the system to automatically set cookies - default: true */
9
9
  autoSetCookie?: boolean;
10
10
  /** default: "intor.i18n.locale" */
@@ -52,7 +52,6 @@ type BaseLoaderOptions = {
52
52
  namespaces?: string[];
53
53
  routeNamespaces?: RouteNamespaces;
54
54
  concurrency?: number;
55
- lazyLoad?: boolean;
56
55
  };
57
56
  type LocalLoader = BaseLoaderOptions & {
58
57
  type: "local";
@@ -89,6 +88,7 @@ type RoutingRawOptions = {
89
88
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
90
89
 
91
90
  type CacheRawOptions = {
91
+ /** default: process.env.NODE_ENV === "production" */
92
92
  enabled?: boolean;
93
93
  /** default: 60\*60\*1000 (1 hour) */
94
94
  ttl?: number;
@@ -3,8 +3,8 @@ import { Locale, LocaleMessages, FallbackLocalesMap } from 'intor-translator';
3
3
  import { NextRequest } from 'next/server';
4
4
 
5
5
  type CookieRawOptions = {
6
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
7
- disabled?: boolean;
6
+ /** Enable cookie usage (read/write) - default: true */
7
+ enabled?: boolean;
8
8
  /** Allow the system to automatically set cookies - default: true */
9
9
  autoSetCookie?: boolean;
10
10
  /** default: "intor.i18n.locale" */
@@ -52,7 +52,6 @@ type BaseLoaderOptions = {
52
52
  namespaces?: string[];
53
53
  routeNamespaces?: RouteNamespaces;
54
54
  concurrency?: number;
55
- lazyLoad?: boolean;
56
55
  };
57
56
  type LocalLoader = BaseLoaderOptions & {
58
57
  type: "local";
@@ -89,6 +88,7 @@ type RoutingRawOptions = {
89
88
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
90
89
 
91
90
  type CacheRawOptions = {
91
+ /** default: process.env.NODE_ENV === "production" */
92
92
  enabled?: boolean;
93
93
  /** default: 60\*60\*1000 (1 hour) */
94
94
  ttl?: number;
@@ -12,7 +12,7 @@ function setLocaleCookieEdge({
12
12
  override = false
13
13
  // Default to not override existed cookie
14
14
  }) {
15
- if (cookie.disabled || !cookie.autoSetCookie) return;
15
+ if (!cookie.enabled || !cookie.autoSetCookie) return;
16
16
  const isCookieExists = request.cookies.has(cookie.name);
17
17
  if (isCookieExists && !override) return;
18
18
  response.cookies.set(cookie.name, locale, {
@@ -218,7 +218,7 @@ var getI18nContext = async (config) => {
218
218
  const headersStore = await headers.headers();
219
219
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
220
220
  let locale;
221
- if (!cookie.disabled) {
221
+ if (cookie.enabled) {
222
222
  const localeFromCookie = cookiesStore.get(cookie.name)?.value;
223
223
  locale = normalizeLocale(localeFromCookie, supportedLocales);
224
224
  if (locale) {
@@ -4,8 +4,8 @@ import Keyv from 'keyv';
4
4
  import { Logger } from 'logry';
5
5
 
6
6
  type CookieRawOptions = {
7
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
8
- disabled?: boolean;
7
+ /** Enable cookie usage (read/write) - default: true */
8
+ enabled?: boolean;
9
9
  /** Allow the system to automatically set cookies - default: true */
10
10
  autoSetCookie?: boolean;
11
11
  /** default: "intor.i18n.locale" */
@@ -53,7 +53,6 @@ type BaseLoaderOptions = {
53
53
  namespaces?: string[];
54
54
  routeNamespaces?: RouteNamespaces;
55
55
  concurrency?: number;
56
- lazyLoad?: boolean;
57
56
  };
58
57
  type LocalLoader = BaseLoaderOptions & {
59
58
  type: "local";
@@ -90,6 +89,7 @@ type RoutingRawOptions = {
90
89
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
91
90
 
92
91
  type CacheRawOptions = {
92
+ /** default: process.env.NODE_ENV === "production" */
93
93
  enabled?: boolean;
94
94
  /** default: 60\*60\*1000 (1 hour) */
95
95
  ttl?: number;
@@ -4,8 +4,8 @@ import Keyv from 'keyv';
4
4
  import { Logger } from 'logry';
5
5
 
6
6
  type CookieRawOptions = {
7
- /** Completely disable cookie usage (no read, no write, no lookup by name) - default: false */
8
- disabled?: boolean;
7
+ /** Enable cookie usage (read/write) - default: true */
8
+ enabled?: boolean;
9
9
  /** Allow the system to automatically set cookies - default: true */
10
10
  autoSetCookie?: boolean;
11
11
  /** default: "intor.i18n.locale" */
@@ -53,7 +53,6 @@ type BaseLoaderOptions = {
53
53
  namespaces?: string[];
54
54
  routeNamespaces?: RouteNamespaces;
55
55
  concurrency?: number;
56
- lazyLoad?: boolean;
57
56
  };
58
57
  type LocalLoader = BaseLoaderOptions & {
59
58
  type: "local";
@@ -90,6 +89,7 @@ type RoutingRawOptions = {
90
89
  type RoutingResolvedOptions = Required<RoutingRawOptions>;
91
90
 
92
91
  type CacheRawOptions = {
92
+ /** default: process.env.NODE_ENV === "production" */
93
93
  enabled?: boolean;
94
94
  /** default: 60\*60\*1000 (1 hour) */
95
95
  ttl?: number;
@@ -208,7 +208,7 @@ var getI18nContext = async (config) => {
208
208
  const headersStore = await headers();
209
209
  const { defaultLocale, supportedLocales = [], cookie, routing } = config;
210
210
  let locale;
211
- if (!cookie.disabled) {
211
+ if (cookie.enabled) {
212
212
  const localeFromCookie = cookiesStore.get(cookie.name)?.value;
213
213
  locale = normalizeLocale(localeFromCookie, supportedLocales);
214
214
  if (locale) {