use-intl 2.19.0 → 3.0.0-beta.1

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 (270) hide show
  1. package/core.d.ts +1 -0
  2. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js +102 -0
  3. package/dist/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
  4. package/dist/core/IntlError.esm.js +33 -0
  5. package/dist/core/IntlError.esm.js.map +1 -0
  6. package/dist/core/TranslationValues.d.ts +1 -0
  7. package/dist/core/convertFormatsToIntlMessageFormat.esm.js +32 -0
  8. package/dist/core/convertFormatsToIntlMessageFormat.esm.js.map +1 -0
  9. package/dist/core/createBaseTranslator.d.ts +3 -8
  10. package/dist/core/createBaseTranslator.esm.js +201 -0
  11. package/dist/core/createBaseTranslator.esm.js.map +1 -0
  12. package/dist/core/createFormatter.esm.js +138 -0
  13. package/dist/core/createFormatter.esm.js.map +1 -0
  14. package/dist/core/createIntl.esm.js +14 -0
  15. package/dist/core/createIntl.esm.js.map +1 -0
  16. package/dist/core/createTranslator.d.ts +2 -3
  17. package/dist/core/createTranslator.esm.js +37 -0
  18. package/dist/core/createTranslator.esm.js.map +1 -0
  19. package/dist/core/createTranslatorImpl.d.ts +2 -3
  20. package/dist/core/createTranslatorImpl.esm.js +50 -0
  21. package/dist/core/createTranslatorImpl.esm.js.map +1 -0
  22. package/dist/core/defaults.esm.js +15 -0
  23. package/dist/core/defaults.esm.js.map +1 -0
  24. package/dist/core/index.d.ts +8 -1
  25. package/dist/core/initializeConfig.d.ts +13 -0
  26. package/dist/core/initializeConfig.esm.js +29 -0
  27. package/dist/core/initializeConfig.esm.js.map +1 -0
  28. package/dist/core/resolveNamespace.esm.js +10 -0
  29. package/dist/core/resolveNamespace.esm.js.map +1 -0
  30. package/dist/core/use-intl.esm.js +34 -30
  31. package/dist/core/use-intl.esm.js.map +1 -1
  32. package/dist/core/use-intl.esm10.js +23 -27
  33. package/dist/core/use-intl.esm10.js.map +1 -1
  34. package/dist/core/use-intl.esm11.js +10 -0
  35. package/dist/core/use-intl.esm11.js.map +1 -0
  36. package/dist/core/use-intl.esm2.js +30 -34
  37. package/dist/core/use-intl.esm2.js.map +1 -1
  38. package/dist/core/use-intl.esm3.js +8 -132
  39. package/dist/core/use-intl.esm3.js.map +1 -1
  40. package/dist/core/use-intl.esm4.js +196 -9
  41. package/dist/core/use-intl.esm4.js.map +1 -1
  42. package/dist/core/use-intl.esm5.js +19 -43
  43. package/dist/core/use-intl.esm5.js.map +1 -1
  44. package/dist/core/use-intl.esm6.js +134 -11
  45. package/dist/core/use-intl.esm6.js.map +1 -1
  46. package/dist/core/use-intl.esm7.js +12 -188
  47. package/dist/core/use-intl.esm7.js.map +1 -1
  48. package/dist/core/use-intl.esm8.js +47 -7
  49. package/dist/core/use-intl.esm8.js.map +1 -1
  50. package/dist/core/use-intl.esm9.js +27 -23
  51. package/dist/core/use-intl.esm9.js.map +1 -1
  52. package/dist/core/validateMessages.esm.js +28 -0
  53. package/dist/core/validateMessages.esm.js.map +1 -0
  54. package/dist/core.cjs.development.js +93 -0
  55. package/dist/core.cjs.development.js.map +1 -0
  56. package/dist/core.cjs.production.min.js +2 -0
  57. package/dist/core.cjs.production.min.js.map +1 -0
  58. package/dist/core.d.ts +1 -0
  59. package/dist/core.esm.js +7 -0
  60. package/dist/core.esm.js.map +1 -0
  61. package/dist/core.js +8 -0
  62. package/dist/createIntl-8a2b87eb.js +579 -0
  63. package/dist/createIntl-8a2b87eb.js.map +1 -0
  64. package/dist/createIntl-f7979de1.js +2 -0
  65. package/dist/createIntl-f7979de1.js.map +1 -0
  66. package/dist/react/IntlContext.esm.js +6 -0
  67. package/dist/react/IntlContext.esm.js.map +1 -0
  68. package/dist/react/IntlProvider.d.ts +1 -1
  69. package/dist/react/IntlProvider.esm.js +16 -0
  70. package/dist/react/IntlProvider.esm.js.map +1 -0
  71. package/dist/react/getInitializedConfig.d.ts +1 -13
  72. package/dist/react/use-intl.esm.js +22 -12
  73. package/dist/react/use-intl.esm.js.map +1 -1
  74. package/dist/react/use-intl.esm10.js +8 -24
  75. package/dist/react/use-intl.esm10.js.map +1 -1
  76. package/dist/react/use-intl.esm11.js +3 -10
  77. package/dist/react/use-intl.esm11.js.map +1 -1
  78. package/dist/react/use-intl.esm2.js +20 -22
  79. package/dist/react/use-intl.esm2.js.map +1 -1
  80. package/dist/react/use-intl.esm3.js +41 -4
  81. package/dist/react/use-intl.esm3.js.map +1 -1
  82. package/dist/react/use-intl.esm4.js +12 -41
  83. package/dist/react/use-intl.esm4.js.map +1 -1
  84. package/dist/react/use-intl.esm5.js +1 -1
  85. package/dist/react/use-intl.esm6.js +1 -1
  86. package/dist/react/use-intl.esm7.js +11 -5
  87. package/dist/react/use-intl.esm7.js.map +1 -1
  88. package/dist/react/use-intl.esm8.js +4 -26
  89. package/dist/react/use-intl.esm8.js.map +1 -1
  90. package/dist/react/use-intl.esm9.js +33 -3
  91. package/dist/react/use-intl.esm9.js.map +1 -1
  92. package/dist/react/useFormatter.esm.js +24 -0
  93. package/dist/react/useFormatter.esm.js.map +1 -0
  94. package/dist/react/useIntl.esm.js +30 -0
  95. package/dist/react/useIntl.esm.js.map +1 -0
  96. package/dist/react/useIntlContext.esm.js +13 -0
  97. package/dist/react/useIntlContext.esm.js.map +1 -0
  98. package/dist/react/useLocale.esm.js +8 -0
  99. package/dist/react/useLocale.esm.js.map +1 -0
  100. package/dist/react/useMessages.esm.js +8 -0
  101. package/dist/react/useMessages.esm.js.map +1 -0
  102. package/{src/react/useNow.tsx → dist/react/useNow.esm.js} +32 -36
  103. package/dist/react/useNow.esm.js.map +1 -0
  104. package/dist/react/useTimeZone.esm.js +8 -0
  105. package/dist/react/useTimeZone.esm.js.map +1 -0
  106. package/dist/react/useTranslations.esm.js +26 -0
  107. package/dist/react/useTranslations.esm.js.map +1 -0
  108. package/dist/react/{use-intl.esm12.js → useTranslationsImpl.esm.js} +6 -13
  109. package/dist/react/useTranslationsImpl.esm.js.map +1 -0
  110. package/dist/react.cjs.development.js +184 -0
  111. package/dist/react.cjs.development.js.map +1 -0
  112. package/dist/react.cjs.production.min.js +2 -0
  113. package/dist/react.cjs.production.min.js.map +1 -0
  114. package/dist/react.d.ts +1 -0
  115. package/dist/react.esm.js +9 -0
  116. package/dist/react.esm.js.map +1 -0
  117. package/dist/react.js +8 -0
  118. package/dist/test/setup.d.ts +1 -0
  119. package/dist/use-intl.cjs.development.js +32 -30
  120. package/dist/use-intl.cjs.development.js.map +1 -1
  121. package/dist/use-intl.cjs.production.min.js +1 -1
  122. package/dist/use-intl.cjs.production.min.js.map +1 -1
  123. package/dist/use-intl.esm.js +12 -10
  124. package/dist/use-intl.esm.js.map +1 -1
  125. package/package.json +17 -15
  126. package/react.d.ts +1 -0
  127. package/dist/react/use-intl.esm12.js.map +0 -1
  128. package/dist/src/core/AbstractIntlMessages.d.ts +0 -9
  129. package/dist/src/core/AbstractIntlMessages.js +0 -2
  130. package/dist/src/core/AbstractIntlMessages.js.map +0 -1
  131. package/dist/src/core/DateTimeFormatOptions.d.ts +0 -73
  132. package/dist/src/core/DateTimeFormatOptions.js +0 -3
  133. package/dist/src/core/DateTimeFormatOptions.js.map +0 -1
  134. package/dist/src/core/Formats.d.ts +0 -8
  135. package/dist/src/core/Formats.js +0 -2
  136. package/dist/src/core/Formats.js.map +0 -1
  137. package/dist/src/core/IntlConfig.d.ts +0 -54
  138. package/dist/src/core/IntlConfig.js +0 -2
  139. package/dist/src/core/IntlConfig.js.map +0 -1
  140. package/dist/src/core/IntlError.d.ts +0 -13
  141. package/dist/src/core/IntlError.js +0 -23
  142. package/dist/src/core/IntlError.js.map +0 -1
  143. package/dist/src/core/NumberFormatOptions.d.ts +0 -2
  144. package/dist/src/core/NumberFormatOptions.js +0 -2
  145. package/dist/src/core/NumberFormatOptions.js.map +0 -1
  146. package/dist/src/core/TimeZone.d.ts +0 -2
  147. package/dist/src/core/TimeZone.js +0 -2
  148. package/dist/src/core/TimeZone.js.map +0 -1
  149. package/dist/src/core/TranslationValues.d.ts +0 -5
  150. package/dist/src/core/TranslationValues.js +0 -2
  151. package/dist/src/core/TranslationValues.js.map +0 -1
  152. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +0 -11
  153. package/dist/src/core/convertFormatsToIntlMessageFormat.js +0 -31
  154. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  155. package/dist/src/core/createBaseTranslator.d.ts +0 -26
  156. package/dist/src/core/createBaseTranslator.js +0 -206
  157. package/dist/src/core/createBaseTranslator.js.map +0 -1
  158. package/dist/src/core/createFormatter.d.ts +0 -19
  159. package/dist/src/core/createFormatter.js +0 -129
  160. package/dist/src/core/createFormatter.js.map +0 -1
  161. package/dist/src/core/createIntl.d.ts +0 -7
  162. package/dist/src/core/createIntl.js +0 -11
  163. package/dist/src/core/createIntl.js.map +0 -1
  164. package/dist/src/core/createTranslator.d.ts +0 -48
  165. package/dist/src/core/createTranslator.js +0 -24
  166. package/dist/src/core/createTranslator.js.map +0 -1
  167. package/dist/src/core/createTranslatorImpl.d.ts +0 -14
  168. package/dist/src/core/createTranslatorImpl.js +0 -43
  169. package/dist/src/core/createTranslatorImpl.js.map +0 -1
  170. package/dist/src/core/defaults.d.ts +0 -11
  171. package/dist/src/core/defaults.js +0 -11
  172. package/dist/src/core/defaults.js.map +0 -1
  173. package/dist/src/core/index.d.ts +0 -9
  174. package/dist/src/core/index.js +0 -6
  175. package/dist/src/core/index.js.map +0 -1
  176. package/dist/src/core/resolveNamespace.d.ts +0 -5
  177. package/dist/src/core/resolveNamespace.js +0 -10
  178. package/dist/src/core/resolveNamespace.js.map +0 -1
  179. package/dist/src/core/utils/MessageKeys.d.ts +0 -5
  180. package/dist/src/core/utils/MessageKeys.js +0 -2
  181. package/dist/src/core/utils/MessageKeys.js.map +0 -1
  182. package/dist/src/core/utils/NamespaceKeys.d.ts +0 -5
  183. package/dist/src/core/utils/NamespaceKeys.js +0 -2
  184. package/dist/src/core/utils/NamespaceKeys.js.map +0 -1
  185. package/dist/src/core/utils/NestedKeyOf.d.ts +0 -4
  186. package/dist/src/core/utils/NestedKeyOf.js +0 -2
  187. package/dist/src/core/utils/NestedKeyOf.js.map +0 -1
  188. package/dist/src/core/utils/NestedValueOf.d.ts +0 -2
  189. package/dist/src/core/utils/NestedValueOf.js +0 -2
  190. package/dist/src/core/utils/NestedValueOf.js.map +0 -1
  191. package/dist/src/core/validateMessages.d.ts +0 -3
  192. package/dist/src/core/validateMessages.js +0 -56
  193. package/dist/src/core/validateMessages.js.map +0 -1
  194. package/dist/src/index.d.ts +0 -2
  195. package/dist/src/index.js +0 -3
  196. package/dist/src/index.js.map +0 -1
  197. package/dist/src/react/IntlContext.d.ts +0 -4
  198. package/dist/src/react/IntlContext.js +0 -4
  199. package/dist/src/react/IntlContext.js.map +0 -1
  200. package/dist/src/react/IntlProvider.d.ts +0 -7
  201. package/dist/src/react/IntlProvider.js +0 -7
  202. package/dist/src/react/IntlProvider.js.map +0 -1
  203. package/dist/src/react/getInitializedConfig.d.ts +0 -13
  204. package/dist/src/react/getInitializedConfig.js +0 -21
  205. package/dist/src/react/getInitializedConfig.js.map +0 -1
  206. package/dist/src/react/index.d.ts +0 -8
  207. package/dist/src/react/index.js +0 -10
  208. package/dist/src/react/index.js.map +0 -1
  209. package/dist/src/react/useFormatter.d.ts +0 -6
  210. package/dist/src/react/useFormatter.js +0 -14
  211. package/dist/src/react/useFormatter.js.map +0 -1
  212. package/dist/src/react/useIntl.d.ts +0 -6
  213. package/dist/src/react/useIntl.js +0 -20
  214. package/dist/src/react/useIntl.js.map +0 -1
  215. package/dist/src/react/useIntlContext.d.ts +0 -1
  216. package/dist/src/react/useIntlContext.js +0 -12
  217. package/dist/src/react/useIntlContext.js.map +0 -1
  218. package/dist/src/react/useLocale.d.ts +0 -1
  219. package/dist/src/react/useLocale.js +0 -5
  220. package/dist/src/react/useLocale.js.map +0 -1
  221. package/dist/src/react/useMessages.d.ts +0 -1
  222. package/dist/src/react/useMessages.js +0 -5
  223. package/dist/src/react/useMessages.js.map +0 -1
  224. package/dist/src/react/useNow.d.ts +0 -23
  225. package/dist/src/react/useNow.js +0 -40
  226. package/dist/src/react/useNow.js.map +0 -1
  227. package/dist/src/react/useTimeZone.d.ts +0 -1
  228. package/dist/src/react/useTimeZone.js +0 -5
  229. package/dist/src/react/useTimeZone.js.map +0 -1
  230. package/dist/src/react/useTranslations.d.ts +0 -44
  231. package/dist/src/react/useTranslations.js +0 -21
  232. package/dist/src/react/useTranslations.js.map +0 -1
  233. package/dist/src/react/useTranslationsImpl.d.ts +0 -8
  234. package/dist/src/react/useTranslationsImpl.js +0 -35
  235. package/dist/src/react/useTranslationsImpl.js.map +0 -1
  236. package/src/core/AbstractIntlMessages.tsx +0 -10
  237. package/src/core/DateTimeFormatOptions.tsx +0 -130
  238. package/src/core/Formats.tsx +0 -10
  239. package/src/core/IntlConfig.tsx +0 -59
  240. package/src/core/IntlError.tsx +0 -26
  241. package/src/core/NumberFormatOptions.tsx +0 -3
  242. package/src/core/TimeZone.tsx +0 -426
  243. package/src/core/TranslationValues.tsx +0 -22
  244. package/src/core/convertFormatsToIntlMessageFormat.tsx +0 -46
  245. package/src/core/createBaseTranslator.tsx +0 -335
  246. package/src/core/createFormatter.tsx +0 -191
  247. package/src/core/createIntl.tsx +0 -13
  248. package/src/core/createTranslator.tsx +0 -112
  249. package/src/core/createTranslatorImpl.tsx +0 -87
  250. package/src/core/defaults.tsx +0 -18
  251. package/src/core/index.tsx +0 -14
  252. package/src/core/resolveNamespace.tsx +0 -12
  253. package/src/core/utils/MessageKeys.tsx +0 -9
  254. package/src/core/utils/NamespaceKeys.tsx +0 -9
  255. package/src/core/utils/NestedKeyOf.tsx +0 -9
  256. package/src/core/utils/NestedValueOf.tsx +0 -12
  257. package/src/core/validateMessages.tsx +0 -77
  258. package/src/index.tsx +0 -2
  259. package/src/react/IntlContext.tsx +0 -6
  260. package/src/react/IntlProvider.tsx +0 -16
  261. package/src/react/getInitializedConfig.tsx +0 -29
  262. package/src/react/index.tsx +0 -10
  263. package/src/react/useFormatter.tsx +0 -19
  264. package/src/react/useIntl.tsx +0 -29
  265. package/src/react/useIntlContext.tsx +0 -16
  266. package/src/react/useLocale.tsx +0 -5
  267. package/src/react/useMessages.tsx +0 -5
  268. package/src/react/useTimeZone.tsx +0 -5
  269. package/src/react/useTranslations.tsx +0 -103
  270. package/src/react/useTranslationsImpl.tsx +0 -65
@@ -1,2 +0,0 @@
1
- type TimeZone = 'Africa/Abidjan' | 'Africa/Accra' | 'Africa/Addis_Ababa' | 'Africa/Algiers' | 'Africa/Asmara' | 'Africa/Bamako' | 'Africa/Bangui' | 'Africa/Banjul' | 'Africa/Bissau' | 'Africa/Blantyre' | 'Africa/Brazzaville' | 'Africa/Bujumbura' | 'Africa/Cairo' | 'Africa/Casablanca' | 'Africa/Ceuta' | 'Africa/Conakry' | 'Africa/Dakar' | 'Africa/Dar_es_Salaam' | 'Africa/Djibouti' | 'Africa/Douala' | 'Africa/El_Aaiun' | 'Africa/Freetown' | 'Africa/Gaborone' | 'Africa/Harare' | 'Africa/Johannesburg' | 'Africa/Juba' | 'Africa/Kampala' | 'Africa/Khartoum' | 'Africa/Kigali' | 'Africa/Kinshasa' | 'Africa/Lagos' | 'Africa/Libreville' | 'Africa/Lome' | 'Africa/Luanda' | 'Africa/Lubumbashi' | 'Africa/Lusaka' | 'Africa/Malabo' | 'Africa/Maputo' | 'Africa/Maseru' | 'Africa/Mbabane' | 'Africa/Mogadishu' | 'Africa/Monrovia' | 'Africa/Nairobi' | 'Africa/Ndjamena' | 'Africa/Niamey' | 'Africa/Nouakchott' | 'Africa/Ouagadougou' | 'Africa/Porto-Novo' | 'Africa/Sao_Tome' | 'Africa/Tripoli' | 'Africa/Tunis' | 'Africa/Windhoek' | 'America/Adak' | 'America/Anchorage' | 'America/Anguilla' | 'America/Antigua' | 'America/Araguaina' | 'America/Argentina/Buenos_Aires' | 'America/Argentina/Catamarca' | 'America/Argentina/Cordoba' | 'America/Argentina/Jujuy' | 'America/Argentina/La_Rioja' | 'America/Argentina/Mendoza' | 'America/Argentina/Rio_Gallegos' | 'America/Argentina/Salta' | 'America/Argentina/San_Juan' | 'America/Argentina/San_Luis' | 'America/Argentina/Tucuman' | 'America/Argentina/Ushuaia' | 'America/Aruba' | 'America/Asuncion' | 'America/Atikokan' | 'America/Bahia' | 'America/Bahia_Banderas' | 'America/Barbados' | 'America/Belem' | 'America/Belize' | 'America/Blanc-Sablon' | 'America/Boa_Vista' | 'America/Bogota' | 'America/Boise' | 'America/Cambridge_Bay' | 'America/Campo_Grande' | 'America/Cancun' | 'America/Caracas' | 'America/Cayenne' | 'America/Cayman' | 'America/Chicago' | 'America/Chihuahua' | 'America/Costa_Rica' | 'America/Creston' | 'America/Cuiaba' | 'America/Curacao' | 'America/Danmarkshavn' | 'America/Dawson' | 'America/Dawson_Creek' | 'America/Denver' | 'America/Detroit' | 'America/Dominica' | 'America/Edmonton' | 'America/Eirunepe' | 'America/El_Salvador' | 'America/Fort_Nelson' | 'America/Fortaleza' | 'America/Glace_Bay' | 'America/Godthab' | 'America/Goose_Bay' | 'America/Grand_Turk' | 'America/Grenada' | 'America/Guadeloupe' | 'America/Guatemala' | 'America/Guayaquil' | 'America/Guyana' | 'America/Halifax' | 'America/Havana' | 'America/Hermosillo' | 'America/Indiana/Indianapolis' | 'America/Indiana/Knox' | 'America/Indiana/Marengo' | 'America/Indiana/Petersburg' | 'America/Indiana/Tell_City' | 'America/Indiana/Vevay' | 'America/Indiana/Vincennes' | 'America/Indiana/Winamac' | 'America/Inuvik' | 'America/Iqaluit' | 'America/Jamaica' | 'America/Juneau' | 'America/Kentucky/Louisville' | 'America/Kentucky/Monticello' | 'America/Kralendijk' | 'America/La_Paz' | 'America/Lima' | 'America/Los_Angeles' | 'America/Lower_Princes' | 'America/Maceio' | 'America/Managua' | 'America/Manaus' | 'America/Marigot' | 'America/Martinique' | 'America/Matamoros' | 'America/Mazatlan' | 'America/Menominee' | 'America/Merida' | 'America/Metlakatla' | 'America/Mexico_City' | 'America/Miquelon' | 'America/Moncton' | 'America/Monterrey' | 'America/Montevideo' | 'America/Montserrat' | 'America/Nassau' | 'America/New_York' | 'America/Nipigon' | 'America/Nome' | 'America/Noronha' | 'America/North_Dakota/Beulah' | 'America/North_Dakota/Center' | 'America/North_Dakota/New_Salem' | 'America/Ojinaga' | 'America/Panama' | 'America/Pangnirtung' | 'America/Paramaribo' | 'America/Phoenix' | 'America/Port-au-Prince' | 'America/Port_of_Spain' | 'America/Porto_Velho' | 'America/Puerto_Rico' | 'America/Punta_Arenas' | 'America/Rainy_River' | 'America/Rankin_Inlet' | 'America/Recife' | 'America/Regina' | 'America/Resolute' | 'America/Rio_Branco' | 'America/Santarem' | 'America/Santiago' | 'America/Santo_Domingo' | 'America/Sao_Paulo' | 'America/Scoresbysund' | 'America/Sitka' | 'America/St_Barthelemy' | 'America/St_Johns' | 'America/St_Kitts' | 'America/St_Lucia' | 'America/St_Thomas' | 'America/St_Vincent' | 'America/Swift_Current' | 'America/Tegucigalpa' | 'America/Thule' | 'America/Thunder_Bay' | 'America/Tijuana' | 'America/Toronto' | 'America/Tortola' | 'America/Vancouver' | 'America/Whitehorse' | 'America/Winnipeg' | 'America/Yakutat' | 'America/Yellowknife' | 'Antarctica/Casey' | 'Antarctica/Davis' | 'Antarctica/DumontDUrville' | 'Antarctica/Macquarie' | 'Antarctica/Mawson' | 'Antarctica/Palmer' | 'Antarctica/Rothera' | 'Antarctica/Syowa' | 'Antarctica/Troll' | 'Antarctica/Vostok' | 'Arctic/Longyearbyen' | 'Asia/Almaty' | 'Asia/Amman' | 'Asia/Anadyr' | 'Asia/Aqtau' | 'Asia/Aqtobe' | 'Asia/Ashgabat' | 'Asia/Atyrau' | 'Asia/Baghdad' | 'Asia/Baku' | 'Asia/Bangkok' | 'Asia/Barnaul' | 'Asia/Beirut' | 'Asia/Bishkek' | 'Asia/Brunei' | 'Asia/Chita' | 'Asia/Choibalsan' | 'Asia/Colombo' | 'Asia/Damascus' | 'Asia/Dhaka' | 'Asia/Dili' | 'Asia/Dubai' | 'Asia/Dushanbe' | 'Asia/Famagusta' | 'Asia/Gaza' | 'Asia/Hebron' | 'Asia/Ho_Chi_Minh' | 'Asia/Hong_Kong' | 'Asia/Hovd' | 'Asia/Irkutsk' | 'Asia/Jakarta' | 'Asia/Jayapura' | 'Asia/Jerusalem' | 'Asia/Kabul' | 'Asia/Kamchatka' | 'Asia/Karachi' | 'Asia/Kathmandu' | 'Asia/Khandyga' | 'Asia/Kolkata' | 'Asia/Krasnoyarsk' | 'Asia/Kuala_Lumpur' | 'Asia/Kuching' | 'Asia/Macau' | 'Asia/Magadan' | 'Asia/Makassar' | 'Asia/Manila' | 'Asia/Nicosia' | 'Asia/Novokuznetsk' | 'Asia/Novosibirsk' | 'Asia/Omsk' | 'Asia/Oral' | 'Asia/Phnom_Penh' | 'Asia/Pontianak' | 'Asia/Pyongyang' | 'Asia/Qatar' | 'Asia/Qostanay' | 'Asia/Qyzylorda' | 'Asia/Riyadh' | 'Asia/Sakhalin' | 'Asia/Samarkand' | 'Asia/Seoul' | 'Asia/Shanghai' | 'Asia/Singapore' | 'Asia/Srednekolymsk' | 'Asia/Taipei' | 'Asia/Tashkent' | 'Asia/Tbilisi' | 'Asia/Tehran' | 'Asia/Thimphu' | 'Asia/Tokyo' | 'Asia/Tomsk' | 'Asia/Ulaanbaatar' | 'Asia/Urumqi' | 'Asia/Ust-Nera' | 'Asia/Vladivostok' | 'Asia/Yakutsk' | 'Asia/Yangon' | 'Asia/Yekaterinburg' | 'Asia/Yerevan' | 'Atlantic/Azores' | 'Atlantic/Bermuda' | 'Atlantic/Canary' | 'Atlantic/Cape_Verde' | 'Atlantic/Faroe' | 'Atlantic/Madeira' | 'Atlantic/Reykjavik' | 'Atlantic/South_Georgia' | 'Atlantic/St_Helena' | 'Atlantic/Stanley' | 'Australia/Adelaide' | 'Australia/Brisbane' | 'Australia/Broken_Hill' | 'Australia/Currie' | 'Australia/Darwin' | 'Australia/Eucla' | 'Australia/Hobart' | 'Australia/Lindeman' | 'Australia/Lord_Howe' | 'Australia/Melbourne' | 'Australia/Perth' | 'Australia/Sydney' | 'Europe/Amsterdam' | 'Europe/Andorra' | 'Europe/Astrakhan' | 'Europe/Athens' | 'Europe/Belgrade' | 'Europe/Berlin' | 'Europe/Bratislava' | 'Europe/Brussels' | 'Europe/Bucharest' | 'Europe/Budapest' | 'Europe/Busingen' | 'Europe/Chisinau' | 'Europe/Copenhagen' | 'Europe/Dublin' | 'Europe/Gibraltar' | 'Europe/Guernsey' | 'Europe/Helsinki' | 'Europe/Isle_of_Man' | 'Europe/Istanbul' | 'Europe/Jersey' | 'Europe/Kaliningrad' | 'Europe/Kiev' | 'Europe/Kirov' | 'Europe/Lisbon' | 'Europe/Ljubljana' | 'Europe/London' | 'Europe/Luxembourg' | 'Europe/Madrid' | 'Europe/Malta' | 'Europe/Mariehamn' | 'Europe/Minsk' | 'Europe/Monaco' | 'Europe/Moscow' | 'Europe/Oslo' | 'Europe/Paris' | 'Europe/Podgorica' | 'Europe/Prague' | 'Europe/Riga' | 'Europe/Rome' | 'Europe/Samara' | 'Europe/San_Marino' | 'Europe/Sarajevo' | 'Europe/Saratov' | 'Europe/Simferopol' | 'Europe/Skopje' | 'Europe/Sofia' | 'Europe/Stockholm' | 'Europe/Tallinn' | 'Europe/Tirane' | 'Europe/Ulyanovsk' | 'Europe/Uzhgorod' | 'Europe/Vaduz' | 'Europe/Vatican' | 'Europe/Vienna' | 'Europe/Vilnius' | 'Europe/Volgograd' | 'Europe/Warsaw' | 'Europe/Zagreb' | 'Europe/Zaporozhye' | 'Europe/Zurich' | 'Indian/Antananarivo' | 'Indian/Chagos' | 'Indian/Christmas' | 'Indian/Cocos' | 'Indian/Comoro' | 'Indian/Kerguelen' | 'Indian/Mahe' | 'Indian/Maldives' | 'Indian/Mauritius' | 'Indian/Mayotte' | 'Indian/Reunion' | 'Pacific/Apia' | 'Pacific/Auckland' | 'Pacific/Bougainville' | 'Pacific/Chatham' | 'Pacific/Chuuk' | 'Pacific/Easter' | 'Pacific/Efate' | 'Pacific/Enderbury' | 'Pacific/Fakaofo' | 'Pacific/Fiji' | 'Pacific/Funafuti' | 'Pacific/Galapagos' | 'Pacific/Gambier' | 'Pacific/Guadalcanal' | 'Pacific/Guam' | 'Pacific/Honolulu' | 'Pacific/Kiritimati' | 'Pacific/Kosrae' | 'Pacific/Kwajalein' | 'Pacific/Majuro' | 'Pacific/Marquesas' | 'Pacific/Nauru' | 'Pacific/Niue' | 'Pacific/Norfolk' | 'Pacific/Noumea' | 'Pacific/Pago_Pago' | 'Pacific/Palau' | 'Pacific/Pitcairn' | 'Pacific/Pohnpei' | 'Pacific/Port_Moresby' | 'Pacific/Rarotonga' | 'Pacific/Tahiti' | 'Pacific/Tarawa' | 'Pacific/Tongatapu' | 'Pacific/Wake' | 'Pacific/Wallis' | 'UTC' | 'W-SU' | 'WET' | 'Zulu' | (string & {});
2
- export default TimeZone;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TimeZone.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TimeZone.js","sourceRoot":"","sources":["../../../src/core/TimeZone.tsx"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { ReactNode } from 'react';
2
- export type TranslationValue = string | number | boolean | Date | null | undefined;
3
- type TranslationValues = Record<string, TranslationValue>;
4
- export type RichTranslationValues = Record<string, TranslationValue | ((chunks: ReactNode) => ReactNode)>;
5
- export default TranslationValues;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TranslationValues.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TranslationValues.js","sourceRoot":"","sources":["../../../src/core/TranslationValues.tsx"],"names":[],"mappings":""}
@@ -1,11 +0,0 @@
1
- import { Formats as IntlFormats } from 'intl-messageformat';
2
- import Formats from './Formats';
3
- import TimeZone from './TimeZone';
4
- /**
5
- * `intl-messageformat` uses separate keys for `date` and `time`, but there's
6
- * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
7
- * include both a time and a date in a value, therefore the separation doesn't
8
- * seem so useful. We offer a single `dateTime` namespace instead, but we have
9
- * to convert the format before `intl-messageformat` can be used.
10
- */
11
- export default function convertFormatsToIntlMessageFormat(formats: Partial<Formats>, timeZone?: TimeZone): Partial<IntlFormats>;
@@ -1,31 +0,0 @@
1
- function setTimeZoneInFormats(formats, timeZone) {
2
- if (!formats)
3
- return formats;
4
- // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
5
- // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
6
- return Object.keys(formats).reduce((acc, key) => {
7
- acc[key] = {
8
- timeZone,
9
- ...formats[key]
10
- };
11
- return acc;
12
- }, {});
13
- }
14
- /**
15
- * `intl-messageformat` uses separate keys for `date` and `time`, but there's
16
- * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
17
- * include both a time and a date in a value, therefore the separation doesn't
18
- * seem so useful. We offer a single `dateTime` namespace instead, but we have
19
- * to convert the format before `intl-messageformat` can be used.
20
- */
21
- export default function convertFormatsToIntlMessageFormat(formats, timeZone) {
22
- const formatsWithTimeZone = timeZone
23
- ? { ...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone) }
24
- : formats;
25
- return {
26
- ...formatsWithTimeZone,
27
- date: formatsWithTimeZone?.dateTime,
28
- time: formatsWithTimeZone?.dateTime
29
- };
30
- }
31
- //# sourceMappingURL=convertFormatsToIntlMessageFormat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertFormatsToIntlMessageFormat.js","sourceRoot":"","sources":["../../../src/core/convertFormatsToIntlMessageFormat.tsx"],"names":[],"mappings":"AAKA,SAAS,oBAAoB,CAC3B,OAA0D,EAC1D,QAAkB;IAElB,IAAI,CAAC,OAAO;QAAE,OAAO,OAAO,CAAC;IAE7B,4FAA4F;IAC5F,sHAAsH;IACtH,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,CAChC,CAAC,GAA0C,EAAE,GAAG,EAAE,EAAE;QAClD,GAAG,CAAC,GAAG,CAAC,GAAG;YACT,QAAQ;YACR,GAAG,OAAO,CAAC,GAAG,CAAC;SAChB,CAAC;QACF,OAAO,GAAG,CAAC;IACb,CAAC,EACD,EAAE,CACH,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,iCAAiC,CACvD,OAAyB,EACzB,QAAmB;IAEnB,MAAM,mBAAmB,GAAG,QAAQ;QAClC,CAAC,CAAC,EAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,oBAAoB,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAC;QAC1E,CAAC,CAAC,OAAO,CAAC;IAEZ,OAAO;QACL,GAAG,mBAAmB;QACtB,IAAI,EAAE,mBAAmB,EAAE,QAAQ;QACnC,IAAI,EAAE,mBAAmB,EAAE,QAAQ;KACpC,CAAC;AACJ,CAAC"}
@@ -1,26 +0,0 @@
1
- import IntlMessageFormat from 'intl-messageformat';
2
- import { ReactElement, ReactNodeArray } from 'react';
3
- import AbstractIntlMessages from './AbstractIntlMessages';
4
- import Formats from './Formats';
5
- import { InitializedIntlConfig } from './IntlConfig';
6
- import IntlError from './IntlError';
7
- import TranslationValues, { RichTranslationValues } from './TranslationValues';
8
- import MessageKeys from './utils/MessageKeys';
9
- import NestedKeyOf from './utils/NestedKeyOf';
10
- import NestedValueOf from './utils/NestedValueOf';
11
- export declare function getMessagesOrError<Messages extends AbstractIntlMessages>({ messages, namespace, onError }: {
12
- messages: Messages;
13
- namespace?: string;
14
- onError?(error: IntlError): void;
15
- }): AbstractIntlMessages | IntlError;
16
- export type CreateBaseTranslatorProps<Messages> = InitializedIntlConfig & {
17
- cachedFormatsByLocale?: Record<string, Record<string, IntlMessageFormat>>;
18
- defaultTranslationValues?: RichTranslationValues;
19
- namespace?: string;
20
- messagesOrError: Messages | IntlError;
21
- };
22
- export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messagesOrError, namespace, onError, timeZone }: CreateBaseTranslatorProps<Messages>): {
23
- <TargetKey extends MessageKeys<NestedValueOf<Messages, NestedKey>, NestedKeyOf<NestedValueOf<Messages, NestedKey>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
24
- rich: (key: string, values?: RichTranslationValues, formats?: Partial<Formats>) => string | ReactElement | ReactNodeArray;
25
- raw(key: string): any;
26
- };
@@ -1,206 +0,0 @@
1
- // eslint-disable-next-line import/no-named-as-default -- False positive
2
- import IntlMessageFormat from 'intl-messageformat';
3
- import { cloneElement, isValidElement } from 'react';
4
- import IntlError, { IntlErrorCode } from './IntlError';
5
- import convertFormatsToIntlMessageFormat from './convertFormatsToIntlMessageFormat';
6
- import { defaultGetMessageFallback, defaultOnError } from './defaults';
7
- function resolvePath(messages, key, namespace) {
8
- if (!messages) {
9
- throw new Error(process.env.NODE_ENV !== 'production'
10
- ? `No messages available at \`${namespace}\`.`
11
- : undefined);
12
- }
13
- let message = messages;
14
- key.split('.').forEach((part) => {
15
- const next = message[part];
16
- if (part == null || next == null) {
17
- throw new Error(process.env.NODE_ENV !== 'production'
18
- ? `Could not resolve \`${key}\` in ${namespace ? `\`${namespace}\`` : 'messages'}.`
19
- : undefined);
20
- }
21
- message = next;
22
- });
23
- return message;
24
- }
25
- function prepareTranslationValues(values) {
26
- if (Object.keys(values).length === 0)
27
- return undefined;
28
- // Workaround for https://github.com/formatjs/formatjs/issues/1467
29
- const transformedValues = {};
30
- Object.keys(values).forEach((key) => {
31
- let index = 0;
32
- const value = values[key];
33
- let transformed;
34
- if (typeof value === 'function') {
35
- transformed = (chunks) => {
36
- const result = value(chunks);
37
- return isValidElement(result)
38
- ? cloneElement(result, { key: key + index++ })
39
- : result;
40
- };
41
- }
42
- else {
43
- transformed = value;
44
- }
45
- transformedValues[key] = transformed;
46
- });
47
- return transformedValues;
48
- }
49
- export function getMessagesOrError({ messages, namespace, onError = defaultOnError }) {
50
- try {
51
- if (!messages) {
52
- throw new Error(process.env.NODE_ENV !== 'production'
53
- ? `No messages were configured on the provider.`
54
- : undefined);
55
- }
56
- const retrievedMessages = namespace
57
- ? resolvePath(messages, namespace)
58
- : messages;
59
- if (!retrievedMessages) {
60
- throw new Error(process.env.NODE_ENV !== 'production'
61
- ? `No messages for namespace \`${namespace}\` found.`
62
- : undefined);
63
- }
64
- return retrievedMessages;
65
- }
66
- catch (error) {
67
- const intlError = new IntlError(IntlErrorCode.MISSING_MESSAGE, error.message);
68
- onError(intlError);
69
- return intlError;
70
- }
71
- }
72
- export default function createBaseTranslator({ cachedFormatsByLocale, defaultTranslationValues, formats: globalFormats, getMessageFallback = defaultGetMessageFallback, locale, messagesOrError, namespace, onError, timeZone }) {
73
- function getFallbackFromErrorAndNotify(key, code, message) {
74
- const error = new IntlError(code, message);
75
- onError(error);
76
- return getMessageFallback({ error, key, namespace });
77
- }
78
- function translateBaseFn(
79
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
80
- key,
81
- /** Key value pairs for values to interpolate into the message. */
82
- values,
83
- /** Provide custom formats for numbers, dates and times. */
84
- formats) {
85
- if (messagesOrError instanceof IntlError) {
86
- // We have already warned about this during render
87
- return getMessageFallback({
88
- error: messagesOrError,
89
- key,
90
- namespace
91
- });
92
- }
93
- const messages = messagesOrError;
94
- let message;
95
- try {
96
- message = resolvePath(messages, key, namespace);
97
- }
98
- catch (error) {
99
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
100
- }
101
- function joinPath(parts) {
102
- return parts.filter((part) => part != null).join('.');
103
- }
104
- const cacheKey = joinPath([namespace, key, String(message)]);
105
- let messageFormat;
106
- if (cachedFormatsByLocale?.[locale]?.[cacheKey]) {
107
- messageFormat = cachedFormatsByLocale?.[locale][cacheKey];
108
- }
109
- else {
110
- if (typeof message === 'object') {
111
- let code, errorMessage;
112
- if (Array.isArray(message)) {
113
- code = IntlErrorCode.INVALID_MESSAGE;
114
- if (process.env.NODE_ENV !== 'production') {
115
- errorMessage = `Message at \`${joinPath([
116
- namespace,
117
- key
118
- ])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;
119
- }
120
- }
121
- else {
122
- code = IntlErrorCode.INSUFFICIENT_PATH;
123
- if (process.env.NODE_ENV !== 'production') {
124
- errorMessage = `Message at \`${joinPath([
125
- namespace,
126
- key
127
- ])}\` resolved to an object, but only strings are supported. Use a \`.\` to retrieve nested messages. See https://next-intl-docs.vercel.app/docs/usage/messages#structuring-messages`;
128
- }
129
- }
130
- return getFallbackFromErrorAndNotify(key, code, errorMessage);
131
- }
132
- try {
133
- messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat({ ...globalFormats, ...formats }, timeZone));
134
- }
135
- catch (error) {
136
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
137
- }
138
- if (cachedFormatsByLocale) {
139
- if (!cachedFormatsByLocale[locale]) {
140
- cachedFormatsByLocale[locale] = {};
141
- }
142
- cachedFormatsByLocale[locale][cacheKey] = messageFormat;
143
- }
144
- }
145
- try {
146
- const formattedMessage = messageFormat.format(
147
- // @ts-ignore `intl-messageformat` expects a different format
148
- // for rich text elements since a recent minor update. This
149
- // needs to be evaluated in detail, possibly also in regards
150
- // to be able to format to parts.
151
- prepareTranslationValues({ ...defaultTranslationValues, ...values }));
152
- if (formattedMessage == null) {
153
- throw new Error(process.env.NODE_ENV !== 'production'
154
- ? `Unable to format \`${key}\` in ${namespace ? `namespace \`${namespace}\`` : 'messages'}`
155
- : undefined);
156
- }
157
- // Limit the function signature to return strings or React elements
158
- return isValidElement(formattedMessage) ||
159
- // Arrays of React elements
160
- Array.isArray(formattedMessage) ||
161
- typeof formattedMessage === 'string'
162
- ? formattedMessage
163
- : String(formattedMessage);
164
- }
165
- catch (error) {
166
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.FORMATTING_ERROR, error.message);
167
- }
168
- }
169
- function translateFn(
170
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
171
- key,
172
- /** Key value pairs for values to interpolate into the message. */
173
- values,
174
- /** Provide custom formats for numbers, dates and times. */
175
- formats) {
176
- const result = translateBaseFn(key, values, formats);
177
- if (typeof result !== 'string') {
178
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, process.env.NODE_ENV !== 'production'
179
- ? `The message \`${key}\` in ${namespace ? `namespace \`${namespace}\`` : 'messages'} didn't resolve to a string. If you want to format rich text, use \`t.rich\` instead.`
180
- : undefined);
181
- }
182
- return result;
183
- }
184
- translateFn.rich = translateBaseFn;
185
- translateFn.raw = (
186
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
187
- key) => {
188
- if (messagesOrError instanceof IntlError) {
189
- // We have already warned about this during render
190
- return getMessageFallback({
191
- error: messagesOrError,
192
- key,
193
- namespace
194
- });
195
- }
196
- const messages = messagesOrError;
197
- try {
198
- return resolvePath(messages, key, namespace);
199
- }
200
- catch (error) {
201
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
202
- }
203
- };
204
- return translateFn;
205
- }
206
- //# sourceMappingURL=createBaseTranslator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createBaseTranslator.js","sourceRoot":"","sources":["../../../src/core/createBaseTranslator.tsx"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,iBAAiB,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACL,YAAY,EACZ,cAAc,EAIf,MAAM,OAAO,CAAC;AAIf,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAErD,OAAO,iCAAiC,MAAM,qCAAqC,CAAC;AACpF,OA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QAAQ,EAAE;YAC9B,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC7B,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,iBAAiB,GAAG,SAClB,SAAS,CAAC,CAAC,CAAC,eAAe,SAAS,IAAI,CAAC,CAAC,CAAC,UAC7C,uFAAuF;gBACzF,CAAC,CAAC,SAAS,CACd,CAAC;SACH;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;IAEnC,WAAW,CAAC,GAAG,GAAG;IAChB,+EAA+E;IAC/E,GAAW,EACN,EAAE;QACP,IAAI,eAAe,YAAY,SAAS,EAAE;YACxC,kDAAkD;YAClD,OAAO,kBAAkB,CAAC;gBACxB,KAAK,EAAE,eAAe;gBACtB,GAAG;gBACH,SAAS;aACV,CAAC,CAAC;SACJ;QACD,MAAM,QAAQ,GAAG,eAAe,CAAC;QAEjC,IAAI;YACF,OAAO,WAAW,CAAC,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;SAC9C;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,6BAA6B,CAClC,GAAG,EACH,aAAa,CAAC,eAAe,EAC5B,KAAe,CAAC,OAAO,CACzB,CAAC;SACH;IACH,CAAC,CAAC;IAEF,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,19 +0,0 @@
1
- import DateTimeFormatOptions from './DateTimeFormatOptions';
2
- import Formats from './Formats';
3
- import IntlError from './IntlError';
4
- import NumberFormatOptions from './NumberFormatOptions';
5
- import TimeZone from './TimeZone';
6
- type Props = {
7
- locale: string;
8
- timeZone?: TimeZone;
9
- onError?(error: IntlError): void;
10
- formats?: Partial<Formats>;
11
- now?: Date;
12
- };
13
- export default function createFormatter({ formats, locale, now: globalNow, onError, timeZone }: Props): {
14
- dateTime: (value: Date | number, formatOrOptions?: string | DateTimeFormatOptions) => string;
15
- number: (value: number | bigint, formatOrOptions?: string | NumberFormatOptions) => string;
16
- relativeTime: (date: number | Date, now?: number | Date) => string;
17
- list: (value: Iterable<string>, formatOrOptions?: string | Intl.ListFormatOptions) => string;
18
- };
19
- export {};
@@ -1,129 +0,0 @@
1
- import IntlError, { IntlErrorCode } from './IntlError';
2
- import { defaultOnError } from './defaults';
3
- const MINUTE = 60;
4
- const HOUR = MINUTE * 60;
5
- const DAY = HOUR * 24;
6
- const WEEK = DAY * 7;
7
- const MONTH = DAY * (365 / 12); // Approximation
8
- const YEAR = DAY * 365;
9
- function getRelativeTimeFormatConfig(seconds) {
10
- const absValue = Math.abs(seconds);
11
- let value, unit;
12
- // We have to round the resulting values, as `Intl.RelativeTimeFormat`
13
- // will include fractions like '2.1 hours ago'.
14
- if (absValue < MINUTE) {
15
- unit = 'second';
16
- value = Math.round(seconds);
17
- }
18
- else if (absValue < HOUR) {
19
- unit = 'minute';
20
- value = Math.round(seconds / MINUTE);
21
- }
22
- else if (absValue < DAY) {
23
- unit = 'hour';
24
- value = Math.round(seconds / HOUR);
25
- }
26
- else if (absValue < WEEK) {
27
- unit = 'day';
28
- value = Math.round(seconds / DAY);
29
- }
30
- else if (absValue < MONTH) {
31
- unit = 'week';
32
- value = Math.round(seconds / WEEK);
33
- }
34
- else if (absValue < YEAR) {
35
- unit = 'month';
36
- value = Math.round(seconds / MONTH);
37
- }
38
- else {
39
- unit = 'year';
40
- value = Math.round(seconds / YEAR);
41
- }
42
- return { value, unit };
43
- }
44
- export default function createFormatter({ formats, locale, now: globalNow, onError = defaultOnError, timeZone }) {
45
- function resolveFormatOrOptions(typeFormats, formatOrOptions) {
46
- let options;
47
- if (typeof formatOrOptions === 'string') {
48
- const formatName = formatOrOptions;
49
- options = typeFormats?.[formatName];
50
- if (!options) {
51
- const error = new IntlError(IntlErrorCode.MISSING_FORMAT, process.env.NODE_ENV !== 'production'
52
- ? `Format \`${formatName}\` is not available. You can configure it on the provider or provide custom options.`
53
- : undefined);
54
- onError(error);
55
- throw error;
56
- }
57
- }
58
- else {
59
- options = formatOrOptions;
60
- }
61
- return options;
62
- }
63
- function getFormattedValue(value, formatOrOptions, typeFormats, formatter) {
64
- let options;
65
- try {
66
- options = resolveFormatOrOptions(typeFormats, formatOrOptions);
67
- }
68
- catch (error) {
69
- return String(value);
70
- }
71
- try {
72
- return formatter(options);
73
- }
74
- catch (error) {
75
- onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
76
- return String(value);
77
- }
78
- }
79
- function dateTime(
80
- /** If a number is supplied, this is interpreted as a UTC timestamp. */
81
- value,
82
- /** If a time zone is supplied, the `value` is converted to that time zone.
83
- * Otherwise the user time zone will be used. */
84
- formatOrOptions) {
85
- return getFormattedValue(value, formatOrOptions, formats?.dateTime, (options) => {
86
- if (timeZone && !options?.timeZone) {
87
- options = { ...options, timeZone };
88
- }
89
- return new Intl.DateTimeFormat(locale, options).format(value);
90
- });
91
- }
92
- function number(value, formatOrOptions) {
93
- return getFormattedValue(value, formatOrOptions, formats?.number, (options) => new Intl.NumberFormat(locale, options).format(value));
94
- }
95
- function relativeTime(
96
- /** The date time that needs to be formatted. */
97
- date,
98
- /** The reference point in time to which `date` will be formatted in relation to. */
99
- now) {
100
- try {
101
- if (!now) {
102
- if (globalNow) {
103
- now = globalNow;
104
- }
105
- else {
106
- throw new Error(process.env.NODE_ENV !== 'production'
107
- ? `The \`now\` parameter wasn't provided and there was no global fallback configured on the provider.`
108
- : undefined);
109
- }
110
- }
111
- const dateDate = date instanceof Date ? date : new Date(date);
112
- const nowDate = now instanceof Date ? now : new Date(now);
113
- const seconds = (dateDate.getTime() - nowDate.getTime()) / 1000;
114
- const { unit, value } = getRelativeTimeFormatConfig(seconds);
115
- return new Intl.RelativeTimeFormat(locale, {
116
- numeric: 'auto'
117
- }).format(value, unit);
118
- }
119
- catch (error) {
120
- onError(new IntlError(IntlErrorCode.FORMATTING_ERROR, error.message));
121
- return String(date);
122
- }
123
- }
124
- function list(value, formatOrOptions) {
125
- return getFormattedValue(value, formatOrOptions, formats?.list, (options) => new Intl.ListFormat(locale, options).format(value));
126
- }
127
- return { dateTime, number, relativeTime, list };
128
- }
129
- //# sourceMappingURL=createFormatter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createFormatter.js","sourceRoot":"","sources":["../../../src/core/createFormatter.tsx"],"names":[],"mappings":"AAEA,OAAO,SAAS,EAAE,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAE1C,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,IAAI,GAAG,MAAM,GAAG,EAAE,CAAC;AACzB,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;AACtB,MAAM,IAAI,GAAG,GAAG,GAAG,CAAC,CAAC;AACrB,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,gBAAgB;AAChD,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,CAAC;AAEvB,SAAS,2BAA2B,CAAC,OAAe;IAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACnC,IAAI,KAAK,EAAE,IAAiC,CAAC;IAE7C,sEAAsE;IACtE,+CAA+C;IAE/C,IAAI,QAAQ,GAAG,MAAM,EAAE;QACrB,IAAI,GAAG,QAAQ,CAAC;QAChB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC7B;SAAM,IAAI,QAAQ,GAAG,IAAI,EAAE;QAC1B,IAAI,GAAG,QAAQ,CAAC;QAChB,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAC;KACtC;SAAM,IAAI,QAAQ,GAAG,GAAG,EAAE;QACzB,IAAI,GAAG,MAAM,CAAC;QACd,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;KAC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,EAAE,EAAE,CAC1E,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACnD,CAAC;IACJ,CAAC;IAED,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAC,CAAC;AAChD,CAAC"}
@@ -1,7 +0,0 @@
1
- import createFormatter from './createFormatter';
2
- /** @deprecated Switch to `createFormatter` */
3
- export default function createIntl(...args: Parameters<typeof createFormatter>): {
4
- formatDateTime: (value: number | Date, formatOrOptions?: string | import("./DateTimeFormatOptions").default | undefined) => string;
5
- formatNumber: (value: number | bigint, formatOrOptions?: string | import("@formatjs/ecma402-abstract/types/number").NumberFormatOptions | undefined) => string;
6
- formatRelativeTime: (date: number | Date, now?: number | Date | undefined) => string;
7
- };
@@ -1,11 +0,0 @@
1
- import createFormatter from './createFormatter';
2
- /** @deprecated Switch to `createFormatter` */
3
- export default function createIntl(...args) {
4
- const formatter = createFormatter(...args);
5
- return {
6
- formatDateTime: formatter.dateTime,
7
- formatNumber: formatter.number,
8
- formatRelativeTime: formatter.relativeTime
9
- };
10
- }
11
- //# sourceMappingURL=createIntl.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createIntl.js","sourceRoot":"","sources":["../../../src/core/createIntl.tsx"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,8CAA8C;AAC9C,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,GAAG,IAAwC;IAE3C,MAAM,SAAS,GAAG,eAAe,CAAC,GAAG,IAAI,CAAC,CAAC;IAC3C,OAAO;QACL,cAAc,EAAE,SAAS,CAAC,QAAQ;QAClC,YAAY,EAAE,SAAS,CAAC,MAAM;QAC9B,kBAAkB,EAAE,SAAS,CAAC,YAAY;KAC3C,CAAC;AACJ,CAAC"}
@@ -1,48 +0,0 @@
1
- import Formats from './Formats';
2
- import IntlConfig from './IntlConfig';
3
- import TranslationValues from './TranslationValues';
4
- import { CoreRichTranslationValues } from './createTranslatorImpl';
5
- import MessageKeys from './utils/MessageKeys';
6
- import NamespaceKeys from './utils/NamespaceKeys';
7
- import NestedKeyOf from './utils/NestedKeyOf';
8
- import NestedValueOf from './utils/NestedValueOf';
9
- /**
10
- * Translates messages from the given namespace by using the ICU syntax.
11
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
12
- *
13
- * If no namespace is provided, all available messages are returned.
14
- * The namespace can also indicate nesting by using a dot
15
- * (e.g. `namespace.Component`).
16
- */
17
- export default function createTranslator<NestedKey extends NamespaceKeys<IntlMessages, NestedKeyOf<IntlMessages>> = never>({ getMessageFallback, messages, namespace, onError, ...rest }: Omit<IntlConfig<IntlMessages>, 'defaultTranslationValues' | 'messages'> & {
18
- messages: NonNullable<IntlConfig<IntlMessages>['messages']>;
19
- namespace?: NestedKey;
20
- }): {
21
- <TargetKey extends MessageKeys<NestedValueOf<{
22
- '!': IntlMessages;
23
- }, [
24
- NestedKey
25
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
26
- '!': IntlMessages;
27
- }, [
28
- NestedKey
29
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: TranslationValues, formats?: Partial<Formats>): string;
30
- rich<TargetKey extends MessageKeys<NestedValueOf<{
31
- '!': IntlMessages;
32
- }, [
33
- NestedKey
34
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
35
- '!': IntlMessages;
36
- }, [
37
- NestedKey
38
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey, values?: CoreRichTranslationValues, formats?: Partial<Formats>): string;
39
- raw<TargetKey extends MessageKeys<NestedValueOf<{
40
- '!': IntlMessages;
41
- }, [
42
- NestedKey
43
- ] extends [never] ? '!' : `!.${NestedKey}`>, NestedKeyOf<NestedValueOf<{
44
- '!': IntlMessages;
45
- }, [
46
- NestedKey
47
- ] extends [never] ? '!' : `!.${NestedKey}`>>>>(key: TargetKey): any;
48
- };
@@ -1,24 +0,0 @@
1
- import createTranslatorImpl from './createTranslatorImpl';
2
- import { defaultGetMessageFallback, defaultOnError } from './defaults';
3
- /**
4
- * Translates messages from the given namespace by using the ICU syntax.
5
- * See https://formatjs.io/docs/core-concepts/icu-syntax.
6
- *
7
- * If no namespace is provided, all available messages are returned.
8
- * The namespace can also indicate nesting by using a dot
9
- * (e.g. `namespace.Component`).
10
- */
11
- export default function createTranslator({ getMessageFallback = defaultGetMessageFallback, messages, namespace, onError = defaultOnError, ...rest }) {
12
- // We have to wrap the actual function so the type inference for the optional
13
- // namespace works correctly. See https://stackoverflow.com/a/71529575/343045
14
- // The prefix ("!") is arbitrary.
15
- return createTranslatorImpl({
16
- ...rest,
17
- onError,
18
- getMessageFallback,
19
- messages: { '!': messages },
20
- // @ts-ignore
21
- namespace: namespace ? `!.${namespace}` : '!'
22
- }, '!');
23
- }
24
- //# sourceMappingURL=createTranslator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createTranslator.js","sourceRoot":"","sources":["../../../src/core/createTranslator.tsx"],"names":[],"mappings":"AAGA,OAAO,oBAEN,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAC,yBAAyB,EAAE,cAAc,EAAC,MAAM,YAAY,CAAC;AAMrE;;;;;;;GAOG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAKtC,EACA,kBAAkB,GAAG,yBAAyB,EAC9C,QAAQ,EACR,SAAS,EACT,OAAO,GAAG,cAAc,EACxB,GAAG,IAAI,EAIR;IA4DC,6EAA6E;IAC7E,6EAA6E;IAC7E,iCAAiC;IACjC,OAAO,oBAAoB,CAIzB;QACE,GAAG,IAAI;QACP,OAAO;QACP,kBAAkB;QAClB,QAAQ,EAAE,EAAC,GAAG,EAAE,QAAQ,EAAC;QACzB,aAAa;QACb,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE,CAAC,CAAC,CAAC,GAAG;KAC9C,EACD,GAAG,CACJ,CAAC;AACJ,CAAC"}
@@ -1,14 +0,0 @@
1
- import AbstractIntlMessages from './AbstractIntlMessages';
2
- import { InitializedIntlConfig } from './IntlConfig';
3
- import { TranslationValue } from './TranslationValues';
4
- import NestedKeyOf from './utils/NestedKeyOf';
5
- export type CoreRichTranslationValues = Record<string, TranslationValue | ((chunks: string) => string)>;
6
- export type CreateTranslatorImplProps<Messages> = Omit<InitializedIntlConfig, 'messages'> & {
7
- namespace: string;
8
- messages: Messages;
9
- };
10
- export default function createTranslatorImpl<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ getMessageFallback, messages, namespace, onError, ...rest }: CreateTranslatorImplProps<Messages>, namespacePrefix: string): {
11
- (key: import("./utils/MessageKeys").default<import("./utils/NestedValueOf").default<Messages, NestedKey>, NestedKeyOf<import("./utils/NestedValueOf").default<Messages, NestedKey>>>, values?: import("./TranslationValues").default | undefined, formats?: Partial<import("./Formats").default> | undefined): string;
12
- rich(key: string, values: CoreRichTranslationValues, formats?: Partial<import("./Formats").default> | undefined): string;
13
- raw: (key: string) => any;
14
- };