next-intl 2.13.0-beta.1 → 2.13.0-beta.2

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.
Files changed (33) hide show
  1. package/dist/react-server/useFormatter.d.ts +2 -5
  2. package/dist/react-server/useLocale.d.ts +2 -1
  3. package/dist/react-server/useNow.d.ts +2 -1
  4. package/dist/react-server/useTimeZone.d.ts +2 -1
  5. package/dist/react-server/useTranslations.d.ts +2 -5
  6. package/dist/server/getConfig.d.ts +14 -6
  7. package/dist/server/getNow.d.ts +1 -1
  8. package/dist/src/middleware/resolveLocale.js +8 -11
  9. package/dist/src/middleware/resolveLocale.js.map +1 -1
  10. package/dist/src/react-server/useFormatter.d.ts +2 -5
  11. package/dist/src/react-server/useFormatter.js +3 -1
  12. package/dist/src/react-server/useFormatter.js.map +1 -1
  13. package/dist/src/react-server/useLocale.d.ts +2 -1
  14. package/dist/src/react-server/useLocale.js +3 -1
  15. package/dist/src/react-server/useLocale.js.map +1 -1
  16. package/dist/src/react-server/useNow.d.ts +2 -1
  17. package/dist/src/react-server/useNow.js +4 -1
  18. package/dist/src/react-server/useNow.js.map +1 -1
  19. package/dist/src/react-server/useTimeZone.d.ts +2 -1
  20. package/dist/src/react-server/useTimeZone.js +3 -1
  21. package/dist/src/react-server/useTimeZone.js.map +1 -1
  22. package/dist/src/react-server/useTranslations.d.ts +2 -5
  23. package/dist/src/react-server/useTranslations.js +5 -2
  24. package/dist/src/react-server/useTranslations.js.map +1 -1
  25. package/dist/src/server/getConfig.d.ts +14 -6
  26. package/dist/src/server/getNow.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/src/middleware/resolveLocale.tsx +9 -12
  29. package/src/react-server/useFormatter.tsx +5 -1
  30. package/src/react-server/useLocale.tsx +5 -1
  31. package/src/react-server/useNow.tsx +10 -1
  32. package/src/react-server/useTimeZone.tsx +5 -1
  33. package/src/react-server/useTranslations.tsx +9 -2
@@ -1,5 +1,2 @@
1
- export default function useFormatter(): {
2
- dateTime: (value: number | Date, formatOrOptions?: string | import("use-intl/dist/src/core/DateTimeFormatOptions").default | undefined) => string;
3
- number: (value: number | bigint, formatOrOptions?: string | import("use-intl").NumberFormatOptions | undefined) => string;
4
- relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
5
- };
1
+ import type { useFormatter as useFormatterType } from 'use-intl';
2
+ export default function useFormatter(...[]: Parameters<typeof useFormatterType>): ReturnType<typeof useFormatterType>;
@@ -1 +1,2 @@
1
- export default function useLocale(): string;
1
+ import type { useLocale as useLocaleType } from 'use-intl';
2
+ export default function useLocale(...[]: Parameters<typeof useLocaleType>): ReturnType<typeof useLocaleType>;
@@ -1 +1,2 @@
1
- export default function useNow(): Date | undefined;
1
+ import type { useNow as useNowType } from 'use-intl';
2
+ export default function useNow(...[options]: Parameters<typeof useNowType>): ReturnType<typeof useNowType>;
@@ -1 +1,2 @@
1
- export default function useTimeZone(): string | undefined;
1
+ import type { useTimeZone as useTimeZoneType } from 'use-intl';
2
+ export default function useTimeZone(...[]: Parameters<typeof useTimeZoneType>): ReturnType<typeof useTimeZoneType>;
@@ -1,5 +1,2 @@
1
- export default function useTranslations(namespace?: string): {
2
- <TargetKey extends string>(key: TargetKey, values?: import("use-intl/dist/src/core/TranslationValues").default | undefined, formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined): string;
3
- rich<TargetKey_1 extends string>(key: TargetKey_1, values?: import("use-intl/dist/src/core/createTranslatorImpl").CoreRichTranslationValues | undefined, formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined): string;
4
- raw<TargetKey_2 extends string>(key: TargetKey_2): any;
5
- };
1
+ import type { useTranslations as useTranslationsType } from 'use-intl';
2
+ export default function useTranslations(...[namespace]: Parameters<typeof useTranslationsType>): ReturnType<typeof useTranslationsType>;
@@ -1,4 +1,17 @@
1
- declare const getConfig: () => Promise<{
1
+ declare const getConfig: () => Promise<Omit<{
2
+ locale: string;
3
+ now: Date;
4
+ messages?: import("use-intl/dist/core/AbstractIntlMessages").default | undefined;
5
+ defaultTranslationValues?: import("use-intl/dist/core").RichTranslationValues | undefined;
6
+ formats?: Partial<import("use-intl/dist/core/Formats").default> | undefined;
7
+ onError?: ((error: import("use-intl/dist/core").IntlError) => void) | undefined;
8
+ getMessageFallback?: ((info: {
9
+ error: import("use-intl/dist/core").IntlError;
10
+ key: string;
11
+ namespace?: string | undefined;
12
+ }) => string) | undefined;
13
+ timeZone?: string | undefined;
14
+ }, "onError" | "getMessageFallback" | "messages"> & {
2
15
  messages: import("use-intl/dist/src/core/AbstractIntlMessages").default | undefined;
3
16
  onError: (error: import("use-intl/dist/src").IntlError) => void;
4
17
  getMessageFallback: (info: {
@@ -6,10 +19,5 @@ declare const getConfig: () => Promise<{
6
19
  key: string;
7
20
  namespace?: string | undefined;
8
21
  }) => string;
9
- defaultTranslationValues?: import("use-intl/dist/src").RichTranslationValues | undefined;
10
- formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined;
11
- locale: string;
12
- timeZone?: string | undefined;
13
- now?: Date | undefined;
14
22
  }>;
15
23
  export default getConfig;
@@ -1,2 +1,2 @@
1
- declare const getNow: () => Promise<Date | undefined>;
1
+ declare const getNow: () => Promise<Date>;
2
2
  export default getNow;
@@ -37,7 +37,7 @@ function resolveLocaleFromPrefix({ defaultLocale, localeDetection, locales }, re
37
37
  }
38
38
  }
39
39
  // Prio 2: Use existing cookie
40
- if (!locale && requestCookies) {
40
+ if (!locale && localeDetection && requestCookies) {
41
41
  if (requestCookies.has(COOKIE_LOCALE_NAME)) {
42
42
  const value = (_a = requestCookies.get(COOKIE_LOCALE_NAME)) === null || _a === void 0 ? void 0 : _a.value;
43
43
  if (value && locales.includes(value)) {
@@ -63,16 +63,13 @@ function resolveLocaleFromDomain(config, requestHeaders, requestCookies, pathnam
63
63
  const domain = findDomainFromHost(requestHeaders, domains);
64
64
  const hasLocalePrefix = pathname && pathname.startsWith(`/${localeFromPrefixStrategy}`);
65
65
  if (domain) {
66
- if (localeFromPrefixStrategy) {
67
- return {
68
- locale: isLocaleSupportedOnDomain(localeFromPrefixStrategy, domain) ||
69
- hasLocalePrefix
70
- ? localeFromPrefixStrategy
71
- : domain.defaultLocale,
72
- localeFromPrefix: localeFromPrefixStrategy,
73
- domain
74
- };
75
- }
66
+ return {
67
+ locale: isLocaleSupportedOnDomain(localeFromPrefixStrategy, domain) ||
68
+ hasLocalePrefix
69
+ ? localeFromPrefixStrategy
70
+ : domain.defaultLocale,
71
+ domain
72
+ };
76
73
  }
77
74
  }
78
75
  // Prio 2: Use prefix strategy
@@ -1 +1 @@
1
- {"version":3,"file":"resolveLocale.js","sourceRoot":"","sources":["../../../src/middleware/resolveLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,8BAA8B,CAAC;AACnD,OAAO,UAAU,MAAM,YAAY,CAAC;AAEpC,OAAO,EAAC,kBAAkB,EAAC,MAAM,qBAAqB,CAAC;AAKvD,OAAO,EACL,qBAAqB,EACrB,OAAO,EACP,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,SAAS,kBAAkB,CACzB,cAAuB,EACvB,OAA4B;IAE5B,IAAI,IAAI,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAEnC,6CAA6C;IAC7C,IAAI,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAElC,IAAI,IAAI,IAAI,OAAO,EAAE;QACnB,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;KACnD;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,uBAAuB,CAC9B,cAAuB,EACvB,OAAsB,EACtB,aAAqB;IAErB,IAAI,MAAM,CAAC;IAEX,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC;QAC/B,OAAO,EAAE;YACP,iBAAiB,EAA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C1B,MAAM;aACP,CAAC;SACH;KACF;IAED,8BAA8B;IAC9B,OAAO,EAAC,MAAM,EAAE,wBAAwB,EAAC,CAAC;AAC5C,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,MAAoC,EACpC,cAAuB,EACvB,cAA8B,EAC9B,QAAgB;IAEhB,IAAI,MAAM,CAAC,OAAO,EAAE;QAClB,OAAO,uBAAuB,CAC5B,MAAM,EACN,cAAc,EACd,cAAc,EACd,QAAQ,CACT,CAAC;KACH;SAAM;QACL,OAAO;YACL,MAAM,EAAE,uBAAuB,CAC7B,MAAM,EACN,cAAc,EACd,cAAc,EACd,QAAQ,CACT;SACF,CAAC;KACH;AACH,CAAC"}
@@ -1,5 +1,2 @@
1
- export default function useFormatter(): {
2
- dateTime: (value: number | Date, formatOrOptions?: string | import("use-intl/dist/src/core/DateTimeFormatOptions").default | undefined) => string;
3
- number: (value: number | bigint, formatOrOptions?: string | import("use-intl").NumberFormatOptions | undefined) => string;
4
- relativeTime: (date: number | Date, now?: number | Date | undefined) => string;
5
- };
1
+ import type { useFormatter as useFormatterType } from 'use-intl';
2
+ export default function useFormatter(...[]: Parameters<typeof useFormatterType>): ReturnType<typeof useFormatterType>;
@@ -1,6 +1,8 @@
1
1
  import getFormatter from '../server/getFormatter';
2
2
  import useHook from './useHook';
3
- export default function useFormatter() {
3
+ export default function useFormatter(
4
+ // eslint-disable-next-line no-empty-pattern
5
+ ...[]) {
4
6
  return useHook('useFormatter', getFormatter());
5
7
  }
6
8
  //# sourceMappingURL=useFormatter.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useFormatter.js","sourceRoot":"","sources":["../../../src/react-server/useFormatter.tsx"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO,OAAO,CAAC,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;AACjD,CAAC"}
1
+ {"version":3,"file":"useFormatter.js","sourceRoot":"","sources":["../../../src/react-server/useFormatter.tsx"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,wBAAwB,CAAC;AAClD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,YAAY;AAClC,4CAA4C;AAC5C,GAAG,EAAuC;IAE1C,OAAO,OAAO,CAAC,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;AACjD,CAAC"}
@@ -1 +1,2 @@
1
- export default function useLocale(): string;
1
+ import type { useLocale as useLocaleType } from 'use-intl';
2
+ export default function useLocale(...[]: Parameters<typeof useLocaleType>): ReturnType<typeof useLocaleType>;
@@ -1,5 +1,7 @@
1
1
  import getLocale from '../server/getLocale';
2
- export default function useLocale() {
2
+ export default function useLocale(
3
+ // eslint-disable-next-line no-empty-pattern
4
+ ...[]) {
3
5
  return getLocale();
4
6
  }
5
7
  //# sourceMappingURL=useLocale.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../../src/react-server/useLocale.tsx"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,SAAS;IAC/B,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC"}
1
+ {"version":3,"file":"useLocale.js","sourceRoot":"","sources":["../../../src/react-server/useLocale.tsx"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,OAAO,UAAU,SAAS;AAC/B,4CAA4C;AAC5C,GAAG,EAAoC;IAEvC,OAAO,SAAS,EAAE,CAAC;AACrB,CAAC"}
@@ -1 +1,2 @@
1
- export default function useNow(): Date | undefined;
1
+ import type { useNow as useNowType } from 'use-intl';
2
+ export default function useNow(...[options]: Parameters<typeof useNowType>): ReturnType<typeof useNowType>;
@@ -1,6 +1,9 @@
1
1
  import getNow from '../server/getNow';
2
2
  import useHook from './useHook';
3
- export default function useNow() {
3
+ export default function useNow(...[options]) {
4
+ if ((options === null || options === void 0 ? void 0 : options.updateInterval) != null) {
5
+ console.error("`useNow` doesn't support the `updateInterval` option in Server Components, the value will be ignored. If you need the value to update, you can convert the component to a Client Component.");
6
+ }
4
7
  return useHook('useNow', getNow());
5
8
  }
6
9
  //# sourceMappingURL=useNow.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNow.js","sourceRoot":"","sources":["../../../src/react-server/useNow.tsx"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,MAAM;IAC5B,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC"}
1
+ {"version":3,"file":"useNow.js","sourceRoot":"","sources":["../../../src/react-server/useNow.tsx"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,MAAM,CAC5B,GAAG,CAAC,OAAO,CAAgC;IAE3C,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,cAAc,KAAI,IAAI,EAAE;QACnC,OAAO,CAAC,KAAK,CACX,6LAA6L,CAC9L,CAAC;KACH;IAED,OAAO,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;AACrC,CAAC"}
@@ -1 +1,2 @@
1
- export default function useTimeZone(): string | undefined;
1
+ import type { useTimeZone as useTimeZoneType } from 'use-intl';
2
+ export default function useTimeZone(...[]: Parameters<typeof useTimeZoneType>): ReturnType<typeof useTimeZoneType>;
@@ -1,6 +1,8 @@
1
1
  import getTimeZone from '../server/getTimeZone';
2
2
  import useHook from './useHook';
3
- export default function useTimeZone() {
3
+ export default function useTimeZone(
4
+ // eslint-disable-next-line no-empty-pattern
5
+ ...[]) {
4
6
  return useHook('useTimeZone', getTimeZone());
5
7
  }
6
8
  //# sourceMappingURL=useTimeZone.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTimeZone.js","sourceRoot":"","sources":["../../../src/react-server/useTimeZone.tsx"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,OAAO,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/C,CAAC"}
1
+ {"version":3,"file":"useTimeZone.js","sourceRoot":"","sources":["../../../src/react-server/useTimeZone.tsx"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAChD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,WAAW;AACjC,4CAA4C;AAC5C,GAAG,EAAsC;IAEzC,OAAO,OAAO,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,CAAC;AAC/C,CAAC"}
@@ -1,5 +1,2 @@
1
- export default function useTranslations(namespace?: string): {
2
- <TargetKey extends string>(key: TargetKey, values?: import("use-intl/dist/src/core/TranslationValues").default | undefined, formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined): string;
3
- rich<TargetKey_1 extends string>(key: TargetKey_1, values?: import("use-intl/dist/src/core/createTranslatorImpl").CoreRichTranslationValues | undefined, formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined): string;
4
- raw<TargetKey_2 extends string>(key: TargetKey_2): any;
5
- };
1
+ import type { useTranslations as useTranslationsType } from 'use-intl';
2
+ export default function useTranslations(...[namespace]: Parameters<typeof useTranslationsType>): ReturnType<typeof useTranslationsType>;
@@ -1,6 +1,9 @@
1
1
  import getTranslations from '../server/getTranslations';
2
2
  import useHook from './useHook';
3
- export default function useTranslations(namespace) {
4
- return useHook('useTranslations', getTranslations(namespace));
3
+ export default function useTranslations(...[namespace]) {
4
+ const result = useHook('useTranslations', getTranslations(namespace));
5
+ // The types are slightly off here and indicate that rich text formatting
6
+ // doesn't integrate with React - this is not the case.
7
+ return result;
5
8
  }
6
9
  //# sourceMappingURL=useTranslations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useTranslations.js","sourceRoot":"","sources":["../../../src/react-server/useTranslations.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,SAAkB;IACxD,OAAO,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;AAChE,CAAC"}
1
+ {"version":3,"file":"useTranslations.js","sourceRoot":"","sources":["../../../src/react-server/useTranslations.tsx"],"names":[],"mappings":"AACA,OAAO,eAAe,MAAM,2BAA2B,CAAC;AACxD,OAAO,OAAO,MAAM,WAAW,CAAC;AAEhC,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,GAAG,CAAC,SAAS,CAAyC;IAEtD,MAAM,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IAEtE,yEAAyE;IACzE,uDAAuD;IACvD,OAAO,MAAa,CAAC;AACvB,CAAC"}
@@ -1,4 +1,17 @@
1
- declare const getConfig: () => Promise<{
1
+ declare const getConfig: () => Promise<Omit<{
2
+ locale: string;
3
+ now: Date;
4
+ messages?: import("use-intl/dist/core/AbstractIntlMessages").default | undefined;
5
+ onError?: ((error: import("use-intl/dist/core").IntlError) => void) | undefined;
6
+ formats?: Partial<import("use-intl/dist/core/Formats").default> | undefined;
7
+ timeZone?: string | undefined;
8
+ getMessageFallback?: ((info: {
9
+ error: import("use-intl/dist/core").IntlError;
10
+ key: string;
11
+ namespace?: string | undefined;
12
+ }) => string) | undefined;
13
+ defaultTranslationValues?: import("use-intl/dist/core").RichTranslationValues | undefined;
14
+ }, "onError" | "getMessageFallback" | "messages"> & {
2
15
  messages: import("use-intl/dist/src/core/AbstractIntlMessages").default | undefined;
3
16
  onError: (error: import("use-intl/dist/src").IntlError) => void;
4
17
  getMessageFallback: (info: {
@@ -6,10 +19,5 @@ declare const getConfig: () => Promise<{
6
19
  key: string;
7
20
  namespace?: string | undefined;
8
21
  }) => string;
9
- defaultTranslationValues?: import("use-intl/dist/src").RichTranslationValues | undefined;
10
- formats?: Partial<import("use-intl/dist/src/core/Formats").default> | undefined;
11
- locale: string;
12
- timeZone?: string | undefined;
13
- now?: Date | undefined;
14
22
  }>;
15
23
  export default getConfig;
@@ -1,2 +1,2 @@
1
- declare const getNow: () => Promise<Date | undefined>;
1
+ declare const getNow: () => Promise<Date>;
2
2
  export default getNow;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-intl",
3
- "version": "2.13.0-beta.1",
3
+ "version": "2.13.0-beta.2",
4
4
  "sideEffects": false,
5
5
  "author": "Jan Amann <jan@amann.work>",
6
6
  "description": "A minimal, but complete solution for internationalization in Next.js apps.",
@@ -66,7 +66,7 @@
66
66
  "@formatjs/intl-localematcher": "0.2.32",
67
67
  "negotiator": "0.6.3",
68
68
  "server-only": "0.0.1",
69
- "use-intl": "2.13.0-beta.1"
69
+ "use-intl": "2.13.0-beta.2"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "next": "^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0",
@@ -66,7 +66,7 @@ function resolveLocaleFromPrefix(
66
66
  }
67
67
 
68
68
  // Prio 2: Use existing cookie
69
- if (!locale && requestCookies) {
69
+ if (!locale && localeDetection && requestCookies) {
70
70
  if (requestCookies.has(COOKIE_LOCALE_NAME)) {
71
71
  const value = requestCookies.get(COOKIE_LOCALE_NAME)?.value;
72
72
  if (value && locales.includes(value)) {
@@ -110,17 +110,14 @@ function resolveLocaleFromDomain(
110
110
  pathname && pathname.startsWith(`/${localeFromPrefixStrategy}`);
111
111
 
112
112
  if (domain) {
113
- if (localeFromPrefixStrategy) {
114
- return {
115
- locale:
116
- isLocaleSupportedOnDomain(localeFromPrefixStrategy, domain) ||
117
- hasLocalePrefix
118
- ? localeFromPrefixStrategy
119
- : domain.defaultLocale,
120
- localeFromPrefix: localeFromPrefixStrategy,
121
- domain
122
- };
123
- }
113
+ return {
114
+ locale:
115
+ isLocaleSupportedOnDomain(localeFromPrefixStrategy, domain) ||
116
+ hasLocalePrefix
117
+ ? localeFromPrefixStrategy
118
+ : domain.defaultLocale,
119
+ domain
120
+ };
124
121
  }
125
122
  }
126
123
 
@@ -1,6 +1,10 @@
1
+ import type {useFormatter as useFormatterType} from 'use-intl';
1
2
  import getFormatter from '../server/getFormatter';
2
3
  import useHook from './useHook';
3
4
 
4
- export default function useFormatter() {
5
+ export default function useFormatter(
6
+ // eslint-disable-next-line no-empty-pattern
7
+ ...[]: Parameters<typeof useFormatterType>
8
+ ): ReturnType<typeof useFormatterType> {
5
9
  return useHook('useFormatter', getFormatter());
6
10
  }
@@ -1,5 +1,9 @@
1
+ import type {useLocale as useLocaleType} from 'use-intl';
1
2
  import getLocale from '../server/getLocale';
2
3
 
3
- export default function useLocale() {
4
+ export default function useLocale(
5
+ // eslint-disable-next-line no-empty-pattern
6
+ ...[]: Parameters<typeof useLocaleType>
7
+ ): ReturnType<typeof useLocaleType> {
4
8
  return getLocale();
5
9
  }
@@ -1,6 +1,15 @@
1
+ import type {useNow as useNowType} from 'use-intl';
1
2
  import getNow from '../server/getNow';
2
3
  import useHook from './useHook';
3
4
 
4
- export default function useNow() {
5
+ export default function useNow(
6
+ ...[options]: Parameters<typeof useNowType>
7
+ ): ReturnType<typeof useNowType> {
8
+ if (options?.updateInterval != null) {
9
+ console.error(
10
+ "`useNow` doesn't support the `updateInterval` option in Server Components, the value will be ignored. If you need the value to update, you can convert the component to a Client Component."
11
+ );
12
+ }
13
+
5
14
  return useHook('useNow', getNow());
6
15
  }
@@ -1,6 +1,10 @@
1
+ import type {useTimeZone as useTimeZoneType} from 'use-intl';
1
2
  import getTimeZone from '../server/getTimeZone';
2
3
  import useHook from './useHook';
3
4
 
4
- export default function useTimeZone() {
5
+ export default function useTimeZone(
6
+ // eslint-disable-next-line no-empty-pattern
7
+ ...[]: Parameters<typeof useTimeZoneType>
8
+ ): ReturnType<typeof useTimeZoneType> {
5
9
  return useHook('useTimeZone', getTimeZone());
6
10
  }
@@ -1,6 +1,13 @@
1
+ import type {useTranslations as useTranslationsType} from 'use-intl';
1
2
  import getTranslations from '../server/getTranslations';
2
3
  import useHook from './useHook';
3
4
 
4
- export default function useTranslations(namespace?: string) {
5
- return useHook('useTranslations', getTranslations(namespace));
5
+ export default function useTranslations(
6
+ ...[namespace]: Parameters<typeof useTranslationsType>
7
+ ): ReturnType<typeof useTranslationsType> {
8
+ const result = useHook('useTranslations', getTranslations(namespace));
9
+
10
+ // The types are slightly off here and indicate that rich text formatting
11
+ // doesn't integrate with React - this is not the case.
12
+ return result as any;
6
13
  }