next-intl 2.22.0 → 2.22.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 (362) hide show
  1. package/README.md +1 -1
  2. package/config.d.ts +3 -0
  3. package/dist/config.js +7 -0
  4. package/dist/development/_virtual/_rollupPluginBabelHelpers.js +20 -0
  5. package/dist/development/config.js +9 -0
  6. package/dist/development/index.js +21 -0
  7. package/dist/development/index.react-server.js +28 -0
  8. package/dist/development/middleware/getAlternateLinksHeaderValue.js +81 -0
  9. package/dist/development/middleware/middleware.js +146 -0
  10. package/dist/development/middleware/resolveLocale.js +110 -0
  11. package/dist/development/middleware/utils.js +150 -0
  12. package/dist/development/middleware.js +9 -0
  13. package/dist/development/navigation/BaseLink.js +52 -0
  14. package/dist/development/navigation/baseRedirect.js +22 -0
  15. package/dist/development/navigation/createLocalizedPathnamesNavigation.js +135 -0
  16. package/dist/development/navigation/createSharedPathnamesNavigation.js +19 -0
  17. package/dist/development/navigation/react-server/BaseLink.js +25 -0
  18. package/dist/development/navigation/react-server/baseRedirect.js +16 -0
  19. package/dist/development/navigation/react-server/createLocalizedPathnamesNavigation.js +77 -0
  20. package/dist/development/navigation/react-server/createSharedPathnamesNavigation.js +22 -0
  21. package/dist/development/navigation/useBasePathname.js +37 -0
  22. package/dist/development/navigation/useBaseRouter.js +76 -0
  23. package/dist/development/navigation/utils.js +108 -0
  24. package/dist/development/navigation.js +11 -0
  25. package/dist/development/navigation.react-server.js +11 -0
  26. package/dist/development/plugin.js +48 -0
  27. package/dist/development/react-client/index.js +38 -0
  28. package/dist/development/react-client/useLocale.js +24 -0
  29. package/dist/development/react-server/NextIntlClientProvider.js +33 -0
  30. package/dist/development/react-server/getBaseTranslator.js +21 -0
  31. package/dist/development/react-server/useFormatter.js +19 -0
  32. package/dist/development/react-server/useHook.js +21 -0
  33. package/dist/development/react-server/useLocale.js +14 -0
  34. package/dist/development/react-server/useMessages.js +19 -0
  35. package/dist/development/react-server/useNow.js +23 -0
  36. package/dist/development/react-server/useTimeZone.js +19 -0
  37. package/dist/development/react-server/useTranslations.js +19 -0
  38. package/dist/development/server/RequestLocale.js +43 -0
  39. package/dist/development/server/createRequestConfig.js +17 -0
  40. package/dist/development/server/getConfig.js +43 -0
  41. package/dist/development/server/getFormatter.js +26 -0
  42. package/dist/development/server/getLocale.js +11 -0
  43. package/dist/development/server/getMessages.js +21 -0
  44. package/dist/development/server/getNow.js +18 -0
  45. package/dist/development/server/getRequestConfig.js +12 -0
  46. package/dist/development/server/getTimeZone.js +18 -0
  47. package/dist/development/server/getTranslations.js +31 -0
  48. package/dist/development/server/resolveLocaleArg.js +15 -0
  49. package/dist/development/server.js +23 -0
  50. package/dist/development/shared/BaseLinkWithLocale.js +58 -0
  51. package/dist/development/shared/NextIntlClientProvider.js +30 -0
  52. package/dist/development/shared/constants.js +17 -0
  53. package/dist/development/shared/redirectWithLocale.js +16 -0
  54. package/dist/development/shared/utils.js +87 -0
  55. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +1 -0
  56. package/dist/esm/config.js +1 -0
  57. package/dist/esm/index.js +1 -0
  58. package/dist/esm/index.react-server.js +1 -0
  59. package/dist/esm/middleware/getAlternateLinksHeaderValue.js +1 -0
  60. package/dist/esm/middleware/middleware.js +1 -0
  61. package/dist/esm/middleware/resolveLocale.js +1 -0
  62. package/dist/esm/middleware/utils.js +1 -0
  63. package/dist/esm/middleware.js +1 -0
  64. package/dist/esm/navigation/BaseLink.js +1 -0
  65. package/dist/esm/navigation/baseRedirect.js +1 -0
  66. package/dist/esm/navigation/createLocalizedPathnamesNavigation.js +1 -0
  67. package/dist/esm/navigation/createSharedPathnamesNavigation.js +1 -0
  68. package/dist/esm/navigation/react-server/BaseLink.js +1 -0
  69. package/dist/esm/navigation/react-server/baseRedirect.js +1 -0
  70. package/dist/esm/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -0
  71. package/dist/esm/navigation/react-server/createSharedPathnamesNavigation.js +1 -0
  72. package/dist/esm/navigation/useBasePathname.js +2 -0
  73. package/dist/esm/navigation/useBaseRouter.js +1 -0
  74. package/dist/esm/navigation/utils.js +1 -0
  75. package/dist/esm/navigation.js +1 -0
  76. package/dist/esm/navigation.react-server.js +1 -0
  77. package/dist/esm/plugin.js +1 -0
  78. package/dist/esm/react-client/index.js +1 -0
  79. package/dist/esm/react-client/useLocale.js +1 -0
  80. package/dist/esm/react-server/NextIntlClientProvider.js +1 -0
  81. package/dist/esm/react-server/getBaseTranslator.js +1 -0
  82. package/dist/esm/react-server/useFormatter.js +1 -0
  83. package/dist/esm/react-server/useHook.js +1 -0
  84. package/dist/esm/react-server/useLocale.js +1 -0
  85. package/dist/esm/react-server/useMessages.js +1 -0
  86. package/dist/esm/react-server/useNow.js +1 -0
  87. package/dist/esm/react-server/useTimeZone.js +1 -0
  88. package/dist/esm/react-server/useTranslations.js +1 -0
  89. package/dist/esm/server/RequestLocale.js +1 -0
  90. package/dist/esm/server/createRequestConfig.js +1 -0
  91. package/dist/esm/server/getConfig.js +1 -0
  92. package/dist/esm/server/getFormatter.js +1 -0
  93. package/dist/esm/server/getLocale.js +1 -0
  94. package/dist/esm/server/getMessages.js +1 -0
  95. package/dist/esm/server/getNow.js +1 -0
  96. package/dist/esm/server/getRequestConfig.js +1 -0
  97. package/dist/esm/server/getTimeZone.js +1 -0
  98. package/dist/esm/server/getTranslations.js +1 -0
  99. package/dist/esm/server/resolveLocaleArg.js +1 -0
  100. package/dist/esm/server.js +1 -0
  101. package/dist/esm/shared/BaseLinkWithLocale.js +2 -0
  102. package/dist/esm/shared/NextIntlClientProvider.js +2 -0
  103. package/dist/esm/shared/constants.js +1 -0
  104. package/dist/esm/shared/redirectWithLocale.js +1 -0
  105. package/dist/esm/shared/utils.js +1 -0
  106. package/dist/index.js +3 -4
  107. package/dist/index.react-server.js +7 -0
  108. package/dist/middleware.js +7 -0
  109. package/dist/navigation.js +7 -0
  110. package/dist/navigation.react-server.js +7 -0
  111. package/dist/plugin.js +7 -0
  112. package/dist/production/_virtual/_rollupPluginBabelHelpers.js +1 -0
  113. package/dist/production/config.js +1 -0
  114. package/dist/production/index.js +1 -0
  115. package/dist/production/index.react-server.js +1 -0
  116. package/dist/production/middleware/getAlternateLinksHeaderValue.js +1 -0
  117. package/dist/production/middleware/middleware.js +1 -0
  118. package/dist/production/middleware/resolveLocale.js +1 -0
  119. package/dist/production/middleware/utils.js +1 -0
  120. package/dist/production/middleware.js +1 -0
  121. package/dist/production/navigation/BaseLink.js +1 -0
  122. package/dist/production/navigation/baseRedirect.js +1 -0
  123. package/dist/production/navigation/createLocalizedPathnamesNavigation.js +1 -0
  124. package/dist/production/navigation/createSharedPathnamesNavigation.js +1 -0
  125. package/dist/production/navigation/react-server/BaseLink.js +1 -0
  126. package/dist/production/navigation/react-server/baseRedirect.js +1 -0
  127. package/dist/production/navigation/react-server/createLocalizedPathnamesNavigation.js +1 -0
  128. package/dist/production/navigation/react-server/createSharedPathnamesNavigation.js +1 -0
  129. package/dist/production/navigation/useBasePathname.js +2 -0
  130. package/dist/production/navigation/useBaseRouter.js +1 -0
  131. package/dist/production/navigation/utils.js +1 -0
  132. package/dist/production/navigation.js +1 -0
  133. package/dist/production/navigation.react-server.js +1 -0
  134. package/dist/production/plugin.js +1 -0
  135. package/dist/production/react-client/index.js +1 -0
  136. package/dist/production/react-client/useLocale.js +1 -0
  137. package/dist/production/react-server/NextIntlClientProvider.js +1 -0
  138. package/dist/production/react-server/getBaseTranslator.js +1 -0
  139. package/dist/production/react-server/useFormatter.js +1 -0
  140. package/dist/production/react-server/useHook.js +1 -0
  141. package/dist/production/react-server/useLocale.js +1 -0
  142. package/dist/production/react-server/useMessages.js +1 -0
  143. package/dist/production/react-server/useNow.js +1 -0
  144. package/dist/production/react-server/useTimeZone.js +1 -0
  145. package/dist/production/react-server/useTranslations.js +1 -0
  146. package/dist/production/server/RequestLocale.js +1 -0
  147. package/dist/production/server/createRequestConfig.js +1 -0
  148. package/dist/production/server/getConfig.js +1 -0
  149. package/dist/production/server/getFormatter.js +1 -0
  150. package/dist/production/server/getLocale.js +1 -0
  151. package/dist/production/server/getMessages.js +1 -0
  152. package/dist/production/server/getNow.js +1 -0
  153. package/dist/production/server/getRequestConfig.js +1 -0
  154. package/dist/production/server/getTimeZone.js +1 -0
  155. package/dist/production/server/getTranslations.js +1 -0
  156. package/dist/production/server/resolveLocaleArg.js +1 -0
  157. package/dist/production/server.js +1 -0
  158. package/dist/production/shared/BaseLinkWithLocale.js +2 -0
  159. package/dist/production/shared/NextIntlClientProvider.js +2 -0
  160. package/dist/production/shared/constants.js +1 -0
  161. package/dist/production/shared/redirectWithLocale.js +1 -0
  162. package/dist/production/shared/utils.js +1 -0
  163. package/dist/server.js +7 -0
  164. package/dist/types/src/config.d.ts +1 -0
  165. package/dist/types/src/index.react-server.d.ts +1 -0
  166. package/dist/{src → types/src}/middleware/NextIntlMiddlewareConfig.d.ts +14 -10
  167. package/dist/types/src/middleware/getAlternateLinksHeaderValue.d.ts +12 -0
  168. package/dist/types/src/middleware/middleware.d.ts +4 -0
  169. package/dist/types/src/middleware/resolveLocale.d.ts +7 -0
  170. package/dist/types/src/middleware/utils.d.ts +17 -0
  171. package/dist/types/src/middleware.d.ts +1 -0
  172. package/dist/types/src/navigation/BaseLink.d.ts +63 -0
  173. package/dist/types/src/navigation/StrictParams.d.ts +8 -0
  174. package/dist/types/src/navigation/baseRedirect.d.ts +3 -0
  175. package/dist/types/src/navigation/createLocalizedPathnamesNavigation.d.ts +78 -0
  176. package/dist/types/src/navigation/createSharedPathnamesNavigation.d.ts +13 -0
  177. package/dist/types/src/navigation/index.d.ts +3 -0
  178. package/dist/types/src/navigation/react-server/BaseLink.d.ts +8 -0
  179. package/dist/types/src/navigation/react-server/baseRedirect.d.ts +3 -0
  180. package/dist/types/src/navigation/react-server/createLocalizedPathnamesNavigation.d.ts +60 -0
  181. package/dist/types/src/navigation/react-server/createSharedPathnamesNavigation.d.ts +44 -0
  182. package/dist/types/src/navigation/react-server/index.d.ts +3 -0
  183. package/dist/{src/client/usePathname.d.ts → types/src/navigation/useBasePathname.d.ts} +1 -1
  184. package/dist/{client/useRouter.d.ts → types/src/navigation/useBaseRouter.d.ts} +32 -31
  185. package/dist/types/src/navigation/utils.d.ts +51 -0
  186. package/dist/types/src/navigation.d.ts +1 -0
  187. package/dist/types/src/navigation.react-server.d.ts +1 -0
  188. package/dist/types/src/plugin.d.ts +1 -0
  189. package/dist/{react-client → types/src/react-client}/index.d.ts +15 -12
  190. package/dist/types/src/react-client/useLocale.d.ts +1 -0
  191. package/dist/types/src/react-server/NextIntlClientProvider.d.ts +5 -0
  192. package/dist/types/src/react-server/getBaseTranslator.d.ts +42 -0
  193. package/dist/types/src/react-server/index.d.ts +15 -0
  194. package/dist/types/src/react-server/useFormatter.d.ts +2 -0
  195. package/dist/types/src/react-server/useHook.d.ts +1 -0
  196. package/dist/types/src/react-server/useLocale.d.ts +2 -0
  197. package/dist/types/src/react-server/useMessages.d.ts +2 -0
  198. package/dist/types/src/react-server/useNow.d.ts +2 -0
  199. package/dist/types/src/react-server/useTimeZone.d.ts +2 -0
  200. package/dist/types/src/react-server/useTranslations.d.ts +2 -0
  201. package/dist/types/src/server/RequestLocale.d.ts +2 -0
  202. package/dist/types/src/server/createRequestConfig.d.ts +4 -0
  203. package/dist/types/src/server/getConfig.d.ts +23 -0
  204. package/dist/types/src/server/getFormatter.d.ts +14 -0
  205. package/dist/types/src/server/getLocale.d.ts +1 -0
  206. package/dist/types/src/server/getMessages.d.ts +3 -0
  207. package/dist/types/src/server/getNow.d.ts +3 -0
  208. package/dist/types/src/server/getRequestConfig.d.ts +10 -0
  209. package/dist/types/src/server/getTimeZone.d.ts +3 -0
  210. package/dist/types/src/server/getTranslations.d.ts +83 -0
  211. package/dist/types/src/server/index.d.ts +11 -0
  212. package/dist/types/src/server/resolveLocaleArg.d.ts +3 -0
  213. package/dist/types/src/server.d.ts +1 -0
  214. package/dist/types/src/shared/NextIntlClientProvider.d.ts +8 -0
  215. package/dist/{shared → types/src/shared}/constants.d.ts +3 -2
  216. package/dist/types/src/shared/redirectWithLocale.d.ts +3 -0
  217. package/dist/types/src/shared/types.d.ts +6 -0
  218. package/dist/{src → types/src}/shared/utils.d.ts +6 -0
  219. package/dist/types/test/middleware/getAlternateLinksHeaderValue.test.d.ts +1 -0
  220. package/dist/types/test/middleware/middleware.test.d.ts +1 -0
  221. package/dist/types/test/middleware/utils.test.d.ts +1 -0
  222. package/dist/types/test/navigation/BaseLink.test.d.ts +1 -0
  223. package/dist/types/test/navigation/createLocalizedPathnamesNavigation.test.d.ts +1 -0
  224. package/dist/types/test/navigation/createSharedPathnamesNavigation.test.d.ts +1 -0
  225. package/dist/types/test/navigation/useBasePathname.test.d.ts +1 -0
  226. package/dist/types/test/navigation/useBaseRouter.test.d.ts +1 -0
  227. package/dist/types/test/navigation/utils.test.d.ts +1 -0
  228. package/dist/types/test/react-client/useFormatter.test.d.ts +1 -0
  229. package/dist/types/test/react-client/useLocale.test.d.ts +1 -0
  230. package/dist/types/test/react-client/useNow.test.d.ts +1 -0
  231. package/dist/types/test/react-client/useTimeZone.test.d.ts +1 -0
  232. package/dist/types/test/react-client/useTranslations.test.d.ts +1 -0
  233. package/dist/types/test/server/index.test.d.ts +1 -0
  234. package/dist/types/test/setup.d.ts +1 -0
  235. package/dist/types/test/shared/NextIntlClientProvider.test.d.ts +1 -0
  236. package/dist/types/test/shared/utils.test.d.ts +1 -0
  237. package/middleware.d.ts +1 -1
  238. package/navigation.d.ts +1 -0
  239. package/package.json +45 -34
  240. package/plugin.d.ts +6 -0
  241. package/server.d.ts +1 -1
  242. package/client.d.ts +0 -1
  243. package/dist/_virtual/next-intl.esm.js +0 -29
  244. package/dist/_virtual/next-intl.esm.js.map +0 -1
  245. package/dist/client/NextIntlClientProvider.d.ts +0 -4
  246. package/dist/client/index.d.ts +0 -6
  247. package/dist/client/useClientLocale.d.ts +0 -1
  248. package/dist/client/usePathname.d.ts +0 -14
  249. package/dist/index.d.ts +0 -8
  250. package/dist/link/Link.d.ts +0 -27
  251. package/dist/link/index.d.ts +0 -1
  252. package/dist/link/react-server/Link.d.ts +0 -1
  253. package/dist/link/react-server/index.d.ts +0 -1
  254. package/dist/middleware/NextIntlMiddlewareConfig.d.ts +0 -28
  255. package/dist/middleware/getAlternateLinksHeaderValue.d.ts +0 -6
  256. package/dist/middleware/index.d.ts +0 -4
  257. package/dist/middleware/middleware.d.ts +0 -3
  258. package/dist/middleware/resolveLocale.d.ts +0 -6
  259. package/dist/middleware/utils.d.ts +0 -5
  260. package/dist/next-intl.cjs.development.js +0 -82
  261. package/dist/next-intl.cjs.development.js.map +0 -1
  262. package/dist/next-intl.cjs.production.min.js +0 -2
  263. package/dist/next-intl.cjs.production.min.js.map +0 -1
  264. package/dist/next-intl.esm.js +0 -3
  265. package/dist/next-intl.esm.js.map +0 -1
  266. package/dist/react-server/index.d.ts +0 -17
  267. package/dist/server/index.d.ts +0 -6
  268. package/dist/shared/BaseLink.d.ts +0 -7
  269. package/dist/shared/NextIntlClientProvider.d.ts +0 -9
  270. package/dist/shared/next-intl.esm.js +0 -41
  271. package/dist/shared/next-intl.esm.js.map +0 -1
  272. package/dist/shared/utils.d.ts +0 -15
  273. package/dist/src/client/NextIntlClientProvider.d.ts +0 -4
  274. package/dist/src/client/NextIntlClientProvider.js +0 -16
  275. package/dist/src/client/NextIntlClientProvider.js.map +0 -1
  276. package/dist/src/client/index.d.ts +0 -6
  277. package/dist/src/client/index.js +0 -8
  278. package/dist/src/client/index.js.map +0 -1
  279. package/dist/src/client/useClientLocale.d.ts +0 -1
  280. package/dist/src/client/useClientLocale.js +0 -18
  281. package/dist/src/client/useClientLocale.js.map +0 -1
  282. package/dist/src/client/usePathname.js +0 -34
  283. package/dist/src/client/usePathname.js.map +0 -1
  284. package/dist/src/client/useRouter.d.ts +0 -31
  285. package/dist/src/client/useRouter.js +0 -61
  286. package/dist/src/client/useRouter.js.map +0 -1
  287. package/dist/src/index.js +0 -9
  288. package/dist/src/index.js.map +0 -1
  289. package/dist/src/link/Link.d.ts +0 -27
  290. package/dist/src/link/Link.js +0 -29
  291. package/dist/src/link/Link.js.map +0 -1
  292. package/dist/src/link/index.d.ts +0 -1
  293. package/dist/src/link/index.js +0 -2
  294. package/dist/src/link/index.js.map +0 -1
  295. package/dist/src/link/react-server/Link.d.ts +0 -1
  296. package/dist/src/link/react-server/Link.js +0 -6
  297. package/dist/src/link/react-server/Link.js.map +0 -1
  298. package/dist/src/link/react-server/index.d.ts +0 -1
  299. package/dist/src/link/react-server/index.js +0 -2
  300. package/dist/src/link/react-server/index.js.map +0 -1
  301. package/dist/src/middleware/NextIntlMiddlewareConfig.js +0 -2
  302. package/dist/src/middleware/NextIntlMiddlewareConfig.js.map +0 -1
  303. package/dist/src/middleware/getAlternateLinksHeaderValue.d.ts +0 -6
  304. package/dist/src/middleware/getAlternateLinksHeaderValue.js +0 -71
  305. package/dist/src/middleware/getAlternateLinksHeaderValue.js.map +0 -1
  306. package/dist/src/middleware/index.js +0 -5
  307. package/dist/src/middleware/index.js.map +0 -1
  308. package/dist/src/middleware/middleware.d.ts +0 -3
  309. package/dist/src/middleware/middleware.js +0 -149
  310. package/dist/src/middleware/middleware.js.map +0 -1
  311. package/dist/src/middleware/resolveLocale.d.ts +0 -6
  312. package/dist/src/middleware/resolveLocale.js +0 -88
  313. package/dist/src/middleware/resolveLocale.js.map +0 -1
  314. package/dist/src/middleware/utils.d.ts +0 -5
  315. package/dist/src/middleware/utils.js +0 -37
  316. package/dist/src/middleware/utils.js.map +0 -1
  317. package/dist/src/react-client/index.d.ts +0 -12
  318. package/dist/src/react-client/index.js +0 -14
  319. package/dist/src/react-client/index.js.map +0 -1
  320. package/dist/src/react-server/index.d.ts +0 -17
  321. package/dist/src/react-server/index.js +0 -25
  322. package/dist/src/react-server/index.js.map +0 -1
  323. package/dist/src/server/index.d.ts +0 -6
  324. package/dist/src/server/index.js +0 -30
  325. package/dist/src/server/index.js.map +0 -1
  326. package/dist/src/shared/BaseLink.js +0 -38
  327. package/dist/src/shared/BaseLink.js.map +0 -1
  328. package/dist/src/shared/NextIntlClientProvider.d.ts +0 -9
  329. package/dist/src/shared/NextIntlClientProvider.js +0 -33
  330. package/dist/src/shared/NextIntlClientProvider.js.map +0 -1
  331. package/dist/src/shared/constants.d.ts +0 -2
  332. package/dist/src/shared/constants.js +0 -6
  333. package/dist/src/shared/constants.js.map +0 -1
  334. package/dist/src/shared/utils.js +0 -53
  335. package/dist/src/shared/utils.js.map +0 -1
  336. package/link.d.ts +0 -3
  337. package/src/client/NextIntlClientProvider.tsx +0 -18
  338. package/src/client/index.tsx +0 -9
  339. package/src/client/useClientLocale.tsx +0 -20
  340. package/src/client/usePathname.tsx +0 -40
  341. package/src/client/useRouter.tsx +0 -92
  342. package/src/index.tsx +0 -9
  343. package/src/link/Link.tsx +0 -34
  344. package/src/link/index.tsx +0 -1
  345. package/src/link/react-server/Link.tsx +0 -6
  346. package/src/link/react-server/index.tsx +0 -1
  347. package/src/middleware/NextIntlMiddlewareConfig.tsx +0 -42
  348. package/src/middleware/getAlternateLinksHeaderValue.tsx +0 -97
  349. package/src/middleware/index.tsx +0 -5
  350. package/src/middleware/middleware.tsx +0 -206
  351. package/src/middleware/resolveLocale.tsx +0 -151
  352. package/src/middleware/utils.tsx +0 -61
  353. package/src/react-client/index.tsx +0 -15
  354. package/src/react-server/index.tsx +0 -29
  355. package/src/server/index.tsx +0 -34
  356. package/src/shared/BaseLink.tsx +0 -57
  357. package/src/shared/NextIntlClientProvider.tsx +0 -54
  358. package/src/shared/constants.tsx +0 -6
  359. package/src/shared/utils.tsx +0 -91
  360. /package/dist/{src → types/src}/index.d.ts +0 -0
  361. /package/dist/{src → types/src}/middleware/index.d.ts +0 -0
  362. /package/dist/{src/shared/BaseLink.d.ts → types/src/shared/BaseLinkWithLocale.d.ts} +0 -0
@@ -0,0 +1,135 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var useLocale = require('../react-client/useLocale.js');
8
+ var BaseLink = require('./BaseLink.js');
9
+ var baseRedirect = require('./baseRedirect.js');
10
+ var useBasePathname = require('./useBasePathname.js');
11
+ var useBaseRouter = require('./useBaseRouter.js');
12
+ var utils = require('./utils.js');
13
+
14
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
15
+
16
+ var React__default = /*#__PURE__*/_interopDefault(React);
17
+
18
+ function createLocalizedPathnamesNavigation(_ref) {
19
+ let {
20
+ locales,
21
+ pathnames
22
+ } = _ref;
23
+ function useTypedLocale() {
24
+ const locale = useLocale.default();
25
+ const isValid = locales.includes(locale);
26
+ if (!isValid) {
27
+ throw new Error("Unknown locale encountered: \"".concat(locale, "\". Make sure to validate the locale in `app/[locale]/layout.tsx`.") );
28
+ }
29
+ return locale;
30
+ }
31
+ function Link(_ref2, ref) {
32
+ let {
33
+ href,
34
+ locale,
35
+ ...rest
36
+ } = _ref2;
37
+ const defaultLocale = useTypedLocale();
38
+ const finalLocale = locale || defaultLocale;
39
+ return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
40
+ ref: ref,
41
+ href: utils.compileLocalizedPathname({
42
+ locale: finalLocale,
43
+ // @ts-expect-error -- This is ok
44
+ pathname: href,
45
+ // @ts-expect-error -- This is ok
46
+ params: typeof href === 'object' ? href.params : undefined,
47
+ pathnames
48
+ }),
49
+ locale: locale
50
+ }, rest));
51
+ }
52
+ const LinkWithRef = /*#__PURE__*/React.forwardRef(Link);
53
+ LinkWithRef.displayName = 'Link';
54
+ function redirect(href) {
55
+ // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context here is fine, since `redirect` should be called during render
56
+ const locale = useTypedLocale();
57
+ const resolvedHref = getPathname({
58
+ href,
59
+ locale
60
+ });
61
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
62
+ args[_key - 1] = arguments[_key];
63
+ }
64
+ return baseRedirect.default(resolvedHref, ...args);
65
+ }
66
+ function useRouter() {
67
+ const baseRouter = useBaseRouter.default();
68
+ const defaultLocale = useTypedLocale();
69
+ return {
70
+ ...baseRouter,
71
+ push(href) {
72
+ var _args$;
73
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
74
+ args[_key2 - 1] = arguments[_key2];
75
+ }
76
+ const resolvedHref = getPathname({
77
+ href,
78
+ locale: ((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.locale) || defaultLocale
79
+ });
80
+ return baseRouter.push(resolvedHref, ...args);
81
+ },
82
+ replace(href) {
83
+ var _args$2;
84
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
85
+ args[_key3 - 1] = arguments[_key3];
86
+ }
87
+ const resolvedHref = getPathname({
88
+ href,
89
+ locale: ((_args$2 = args[0]) === null || _args$2 === void 0 ? void 0 : _args$2.locale) || defaultLocale
90
+ });
91
+ return baseRouter.replace(resolvedHref, ...args);
92
+ },
93
+ prefetch(href) {
94
+ var _args$3;
95
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
96
+ args[_key4 - 1] = arguments[_key4];
97
+ }
98
+ const resolvedHref = getPathname({
99
+ href,
100
+ locale: ((_args$3 = args[0]) === null || _args$3 === void 0 ? void 0 : _args$3.locale) || defaultLocale
101
+ });
102
+ return baseRouter.prefetch(resolvedHref, ...args);
103
+ }
104
+ };
105
+ }
106
+ function usePathname() {
107
+ const pathname = useBasePathname.default();
108
+ const locale = useTypedLocale();
109
+ return utils.getRoute({
110
+ pathname,
111
+ locale,
112
+ pathnames
113
+ });
114
+ }
115
+ function getPathname(_ref3) {
116
+ let {
117
+ href,
118
+ locale
119
+ } = _ref3;
120
+ return utils.compileLocalizedPathname({
121
+ ...utils.normalizeNameOrNameWithParams(href),
122
+ locale,
123
+ pathnames
124
+ });
125
+ }
126
+ return {
127
+ Link: LinkWithRef,
128
+ redirect,
129
+ usePathname,
130
+ useRouter,
131
+ getPathname
132
+ };
133
+ }
134
+
135
+ exports.default = createLocalizedPathnamesNavigation;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var BaseLink = require('./BaseLink.js');
6
+ var baseRedirect = require('./baseRedirect.js');
7
+ var useBasePathname = require('./useBasePathname.js');
8
+ var useBaseRouter = require('./useBaseRouter.js');
9
+
10
+ function createSharedPathnamesNavigation(opts) {
11
+ return {
12
+ Link: BaseLink.default,
13
+ redirect: baseRedirect.default,
14
+ usePathname: useBasePathname.default,
15
+ useRouter: useBaseRouter.default
16
+ };
17
+ }
18
+
19
+ exports.default = createSharedPathnamesNavigation;
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var useLocale = require('../../react-server/useLocale.js');
8
+ var BaseLinkWithLocale = require('../../shared/BaseLinkWithLocale.js');
9
+
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var React__default = /*#__PURE__*/_interopDefault(React);
13
+
14
+ function BaseLink(_ref) {
15
+ let {
16
+ locale,
17
+ ...rest
18
+ } = _ref;
19
+ const defaultLocale = useLocale.default();
20
+ return /*#__PURE__*/React__default.default.createElement(BaseLinkWithLocale.default, _rollupPluginBabelHelpers.extends({
21
+ locale: locale || defaultLocale
22
+ }, rest));
23
+ }
24
+
25
+ exports.default = BaseLink;
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var RequestLocale = require('../../server/RequestLocale.js');
6
+ var redirectWithLocale = require('../../shared/redirectWithLocale.js');
7
+
8
+ function baseRedirect(pathname) {
9
+ const locale = RequestLocale.getRequestLocale();
10
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
11
+ args[_key - 1] = arguments[_key];
12
+ }
13
+ return redirectWithLocale.default(pathname, locale, ...args);
14
+ }
15
+
16
+ exports.default = baseRedirect;
@@ -0,0 +1,77 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var RequestLocale = require('../../server/RequestLocale.js');
8
+ var utils = require('../utils.js');
9
+ var BaseLink = require('./BaseLink.js');
10
+ var baseRedirect = require('./baseRedirect.js');
11
+
12
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
+
14
+ var React__default = /*#__PURE__*/_interopDefault(React);
15
+
16
+ function createLocalizedPathnamesNavigation(_ref) {
17
+ let {
18
+ locales,
19
+ pathnames
20
+ } = _ref;
21
+ function Link(_ref2) {
22
+ let {
23
+ href,
24
+ locale,
25
+ ...rest
26
+ } = _ref2;
27
+ const defaultLocale = RequestLocale.getRequestLocale();
28
+ const finalLocale = locale || defaultLocale;
29
+ return /*#__PURE__*/React__default.default.createElement(BaseLink.default, _rollupPluginBabelHelpers.extends({
30
+ href: utils.compileLocalizedPathname({
31
+ locale: finalLocale,
32
+ // @ts-expect-error -- This is ok
33
+ pathname: href,
34
+ // @ts-expect-error -- This is ok
35
+ params: typeof href === 'object' ? href.params : undefined,
36
+ pathnames
37
+ }),
38
+ locale: locale
39
+ }, rest));
40
+ }
41
+ function redirect(href) {
42
+ const locale = RequestLocale.getRequestLocale();
43
+ const resolvedHref = getPathname({
44
+ href,
45
+ locale
46
+ });
47
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
48
+ args[_key - 1] = arguments[_key];
49
+ }
50
+ return baseRedirect.default(resolvedHref, ...args);
51
+ }
52
+ function getPathname(_ref3) {
53
+ let {
54
+ href,
55
+ locale
56
+ } = _ref3;
57
+ return utils.compileLocalizedPathname({
58
+ ...utils.normalizeNameOrNameWithParams(href),
59
+ locale,
60
+ pathnames
61
+ });
62
+ }
63
+ function notSupported(message) {
64
+ return () => {
65
+ throw new Error("`".concat(message, "` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."));
66
+ };
67
+ }
68
+ return {
69
+ Link,
70
+ redirect,
71
+ getPathname,
72
+ usePathname: notSupported('usePathname'),
73
+ useRouter: notSupported('useRouter')
74
+ };
75
+ }
76
+
77
+ exports.default = createLocalizedPathnamesNavigation;
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var BaseLink = require('./BaseLink.js');
6
+ var baseRedirect = require('./baseRedirect.js');
7
+
8
+ function createSharedPathnamesNavigation(opts) {
9
+ function notSupported(message) {
10
+ return () => {
11
+ throw new Error("`".concat(message, "` is not supported in Server Components. You can use this hook if you convert the component to a Client Component."));
12
+ };
13
+ }
14
+ return {
15
+ Link: BaseLink.default,
16
+ redirect: baseRedirect.default,
17
+ usePathname: notSupported('usePathname'),
18
+ useRouter: notSupported('useRouter')
19
+ };
20
+ }
21
+
22
+ exports.default = createSharedPathnamesNavigation;
@@ -0,0 +1,37 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var navigation = require('next/navigation');
7
+ var React = require('react');
8
+ var useLocale = require('../react-client/useLocale.js');
9
+ var utils = require('../shared/utils.js');
10
+
11
+ /**
12
+ * Returns the pathname without a potential locale prefix.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * 'use client';
17
+ *
18
+ * import {usePathname} from 'next-intl/client';
19
+ *
20
+ * // When the user is on `/en`, this will be `/`
21
+ * const pathname = usePathname();
22
+ * ```
23
+ */
24
+ function useBasePathname() {
25
+ // The types aren't entirely correct here. Outside of Next.js
26
+ // `useParams` can be called, but the return type is `null`.
27
+ const pathname = navigation.usePathname();
28
+ const locale = useLocale.default();
29
+ return React.useMemo(() => {
30
+ if (!pathname) return pathname;
31
+ const isPathnamePrefixed = utils.hasPathnamePrefixed(locale, pathname);
32
+ const unlocalizedPathname = isPathnamePrefixed ? utils.unlocalizePathname(pathname, locale) : pathname;
33
+ return unlocalizedPathname;
34
+ }, [locale, pathname]);
35
+ }
36
+
37
+ exports.default = useBasePathname;
@@ -0,0 +1,76 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var navigation = require('next/navigation');
6
+ var React = require('react');
7
+ var useLocale = require('../react-client/useLocale.js');
8
+ var utils = require('../shared/utils.js');
9
+
10
+ /**
11
+ * Returns a wrapped instance of `useRouter` from `next/navigation` that
12
+ * will automatically localize the `href` parameters it receives.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * 'use client';
17
+ *
18
+ * import {useRouter} from 'next-intl/client';
19
+ *
20
+ * const router = useRouter();
21
+ *
22
+ * // When the user is on `/en`, the router will navigate to `/en/about`
23
+ * router.push('/about');
24
+ *
25
+ * // Optionally, you can switch the locale by passing the second argument
26
+ * router.push('/about', {locale: 'de'});
27
+ * ```
28
+ */
29
+ function useBaseRouter() {
30
+ const router = navigation.useRouter();
31
+ const locale = useLocale.default();
32
+ return React.useMemo(() => {
33
+ function localize(href, nextLocale) {
34
+ return utils.localizeHref(href, nextLocale || locale, locale, window.location.pathname);
35
+ }
36
+ return {
37
+ ...router,
38
+ push(href, options) {
39
+ const {
40
+ locale: nextLocale,
41
+ ...rest
42
+ } = options || {};
43
+ const args = [localize(href, nextLocale)];
44
+ if (Object.keys(rest).length > 0) {
45
+ args.push(rest);
46
+ }
47
+ return router.push(...args);
48
+ },
49
+ replace(href, options) {
50
+ const {
51
+ locale: nextLocale,
52
+ ...rest
53
+ } = options || {};
54
+ const args = [localize(href, nextLocale)];
55
+ if (Object.keys(rest).length > 0) {
56
+ args.push(rest);
57
+ }
58
+ return router.replace(...args);
59
+ },
60
+ prefetch(href, options) {
61
+ const {
62
+ locale: nextLocale,
63
+ ...rest
64
+ } = options || {};
65
+ const args = [localize(href, nextLocale)];
66
+ if (Object.keys(rest).length > 0) {
67
+ // @ts-expect-error TypeScript thinks `rest` can be an empty object
68
+ args.push(rest);
69
+ }
70
+ return router.prefetch(...args);
71
+ }
72
+ };
73
+ }, [locale, router]);
74
+ }
75
+
76
+ exports.default = useBaseRouter;
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var utils = require('../shared/utils.js');
6
+
7
+ // Minor false positive: A route that has both optional and
8
+ // required params will allow optional params.
9
+ function normalizeNameOrNameWithParams(href) {
10
+ // @ts-expect-error -- `extends string` in the generic unfortunately weakens the type
11
+ return typeof href === 'string' ? {
12
+ pathname: href
13
+ } : href;
14
+ }
15
+ function serializeSearchParams(searchParams) {
16
+ function serializeValue(value) {
17
+ return String(value);
18
+ }
19
+ const urlSearchParams = new URLSearchParams();
20
+ for (const [key, value] of Object.entries(searchParams)) {
21
+ if (Array.isArray(value)) {
22
+ value.forEach(cur => {
23
+ urlSearchParams.append(key, serializeValue(cur));
24
+ });
25
+ } else {
26
+ urlSearchParams.set(key, serializeValue(value));
27
+ }
28
+ }
29
+ return '?' + urlSearchParams.toString();
30
+ }
31
+ function compileLocalizedPathname(_ref) {
32
+ let {
33
+ pathname,
34
+ locale,
35
+ params,
36
+ pathnames,
37
+ query
38
+ } = _ref;
39
+ function getNamedPath(value) {
40
+ let namedPath = pathnames[value];
41
+ if (!namedPath) {
42
+ namedPath = value;
43
+ }
44
+ return namedPath;
45
+ }
46
+ function compilePath(namedPath) {
47
+ const template = typeof namedPath === 'string' ? namedPath : namedPath[locale];
48
+ let compiled = template;
49
+ if (params) {
50
+ Object.entries(params).forEach(_ref2 => {
51
+ let [key, value] = _ref2;
52
+ if (Array.isArray(value)) {
53
+ compiled = compiled.replace(new RegExp("(\\[)?\\[...".concat(key, "\\](\\])?"), 'g'), value.map(v => String(v)).join('/'));
54
+ } else {
55
+ compiled = compiled.replace("[".concat(key, "]"), String(value));
56
+ }
57
+ });
58
+ }
59
+ if (compiled.includes('[')) {
60
+ // Next.js throws anyway, therefore better provide a more helpful error message
61
+ throw new Error("Insufficient params provided for localized pathname.\nTemplate: ".concat(template, "\nParams: ").concat(JSON.stringify(params)));
62
+ }
63
+ if (query) {
64
+ compiled += serializeSearchParams(query);
65
+ }
66
+ return compiled;
67
+ }
68
+ if (typeof pathname === 'string') {
69
+ const namedPath = getNamedPath(pathname);
70
+ const compiled = compilePath(namedPath);
71
+ return compiled;
72
+ } else {
73
+ const {
74
+ pathname: href,
75
+ ...rest
76
+ } = pathname;
77
+ const namedPath = getNamedPath(href);
78
+ const compiled = compilePath(namedPath);
79
+ const result = {
80
+ ...rest,
81
+ pathname: compiled
82
+ };
83
+ return result;
84
+ }
85
+ }
86
+ function getRoute(_ref3) {
87
+ var _Object$entries$find;
88
+ let {
89
+ locale,
90
+ pathname,
91
+ pathnames
92
+ } = _ref3;
93
+ const unlocalizedPathname = utils.unlocalizePathname(pathname, locale);
94
+ let template = (_Object$entries$find = Object.entries(pathnames).find(_ref4 => {
95
+ let [, routePath] = _ref4;
96
+ const routePathname = typeof routePath !== 'string' ? routePath[locale] : routePath;
97
+ return utils.matchesPathname(routePathname, unlocalizedPathname);
98
+ })) === null || _Object$entries$find === void 0 ? void 0 : _Object$entries$find[0];
99
+ if (!template) {
100
+ template = pathname;
101
+ }
102
+ return template;
103
+ }
104
+
105
+ exports.compileLocalizedPathname = compileLocalizedPathname;
106
+ exports.getRoute = getRoute;
107
+ exports.normalizeNameOrNameWithParams = normalizeNameOrNameWithParams;
108
+ exports.serializeSearchParams = serializeSearchParams;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createSharedPathnamesNavigation = require('./navigation/createSharedPathnamesNavigation.js');
6
+ var createLocalizedPathnamesNavigation = require('./navigation/createLocalizedPathnamesNavigation.js');
7
+
8
+
9
+
10
+ exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
11
+ exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createSharedPathnamesNavigation = require('./navigation/react-server/createSharedPathnamesNavigation.js');
6
+ var createLocalizedPathnamesNavigation = require('./navigation/react-server/createLocalizedPathnamesNavigation.js');
7
+
8
+
9
+
10
+ exports.createSharedPathnamesNavigation = createSharedPathnamesNavigation.default;
11
+ exports.createLocalizedPathnamesNavigation = createLocalizedPathnamesNavigation.default;
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs');
4
+ var path = require('path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
9
+ var path__default = /*#__PURE__*/_interopDefault(path);
10
+
11
+ /* eslint-env node */
12
+
13
+ function resolveI18nPath(cwd, providedPath) {
14
+ let i18nPath = providedPath;
15
+ if (i18nPath) {
16
+ i18nPath = path__default.default.resolve(i18nPath);
17
+ if (!fs__default.default.existsSync(i18nPath)) {
18
+ throw new Error("Could not find i18n config at ".concat(i18nPath, ", please provide a valid path."));
19
+ }
20
+ } else {
21
+ i18nPath = ['./i18n.tsx', './i18n.ts', './i18n.js', './i18n.jsx', './src/i18n.tsx', './src/i18n.ts', './src/i18n.js', './src/i18n.jsx'].map(cur => path__default.default.resolve(cwd, cur)).find(cur => fs__default.default.existsSync(cur));
22
+ if (!i18nPath) {
23
+ throw new Error("\n\nCould not locate i18n config. Create one at `./(src/)i18n.{js,jsx,ts,tsx}` or specify a custom location:\n\nconst withNextIntl = require('next-intl/plugin')(\n './path/to/i18n.tsx'\n);\n\nmodule.exports = withNextIntl({\n // Other Next.js configuration ...\n});\n");
24
+ }
25
+ }
26
+ return i18nPath;
27
+ }
28
+ function initPlugin(i18nPath, nextConfig) {
29
+ if ((nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.i18n) != null) {
30
+ console.warn("\nnext-intl has found an `i18n` config in your next.config.js. This likely causes conflicts and should therefore be removed if you use the App Router.\n\nIf you're in progress of migrating from the `pages` folder, you can refer to this example: https://github.com/amannn/next-intl/tree/feat/next-13-rsc/packages/example-next-13-with-pages\n");
31
+ }
32
+ return Object.assign({}, nextConfig, {
33
+ webpack() {
34
+ for (var _len = arguments.length, _ref = new Array(_len), _key = 0; _key < _len; _key++) {
35
+ _ref[_key] = arguments[_key];
36
+ }
37
+ let [config, options] = _ref;
38
+ config.resolve.alias['next-intl/config'] = require.resolve(resolveI18nPath(config.context, i18nPath));
39
+ if (typeof (nextConfig === null || nextConfig === void 0 ? void 0 : nextConfig.webpack) === 'function') {
40
+ return nextConfig.webpack(config, options);
41
+ }
42
+ return config;
43
+ }
44
+ });
45
+ }
46
+ module.exports = function withNextIntl(i18nPath) {
47
+ return nextConfig => initPlugin(i18nPath, nextConfig);
48
+ };
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var useIntl = require('use-intl');
6
+
7
+ /**
8
+ * This is the main entry file when non-'react-server'
9
+ * environments import from 'next-intl'.
10
+ *
11
+ * Maintainer notes:
12
+ * - Make sure this mirrors the API from 'react-server'.
13
+ * - Make sure everything exported from this module is
14
+ * supported in all Next.js versions that are supported.
15
+ */
16
+
17
+
18
+ // eslint-disable-next-line @typescript-eslint/ban-types
19
+ function callHook(name, hook) {
20
+ return function () {
21
+ try {
22
+ return hook(...arguments);
23
+ } catch (e) {
24
+ throw new Error("Failed to call `".concat(name, "` because the context from `NextIntlClientProvider` was not found.\n\nThis can happen because:\n1) You intended to render this component as a Server Component, the render\n failed, and therefore React attempted to render the component on the client\n instead. If this is the case, check the console for server errors.\n2) You intended to render this component on the client side, but no context was found.\n Learn more about this error here: https://next-intl-docs.vercel.app/docs/environments/server-client-components#missing-context") );
25
+ }
26
+ };
27
+ }
28
+ const useTranslations = callHook('useTranslations', useIntl.useTranslations);
29
+ const useFormatter = callHook('useFormatter', useIntl.useFormatter);
30
+
31
+ exports.useFormatter = useFormatter;
32
+ exports.useTranslations = useTranslations;
33
+ Object.keys(useIntl).forEach(function (k) {
34
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
35
+ enumerable: true,
36
+ get: function () { return useIntl[k]; }
37
+ });
38
+ });
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var navigation = require('next/navigation');
6
+ var _useLocale = require('use-intl/_useLocale');
7
+ var constants = require('../shared/constants.js');
8
+
9
+ function useLocale() {
10
+ let locale;
11
+
12
+ // The types aren't entirely correct here. Outside of Next.js
13
+ // `useParams` can be called, but the return type is `null`.
14
+ const params = navigation.useParams();
15
+ if (typeof (params === null || params === void 0 ? void 0 : params[constants.LOCALE_SEGMENT_NAME]) === 'string') {
16
+ locale = params[constants.LOCALE_SEGMENT_NAME];
17
+ } else {
18
+ // eslint-disable-next-line react-hooks/rules-of-hooks -- Reading from context conditionally is fine as long as we're in the render phase
19
+ locale = _useLocale.useLocale();
20
+ }
21
+ return locale;
22
+ }
23
+
24
+ exports.default = useLocale;