use-intl 2.20.0 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) 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 +37 -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 +210 -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.esm10.js +23 -32
  31. package/dist/core/use-intl.esm10.js.map +1 -1
  32. package/dist/core/use-intl.esm11.js +10 -0
  33. package/dist/core/use-intl.esm11.js.map +1 -0
  34. package/dist/core/use-intl.esm2.js +204 -31
  35. package/dist/core/use-intl.esm2.js.map +1 -1
  36. package/dist/core/use-intl.esm3.js +31 -132
  37. package/dist/core/use-intl.esm3.js.map +1 -1
  38. package/dist/core/use-intl.esm4.js +1 -1
  39. package/dist/core/use-intl.esm5.js +19 -43
  40. package/dist/core/use-intl.esm5.js.map +1 -1
  41. package/dist/core/use-intl.esm6.js +134 -11
  42. package/dist/core/use-intl.esm6.js.map +1 -1
  43. package/dist/core/use-intl.esm7.js +29 -192
  44. package/dist/core/use-intl.esm7.js.map +1 -1
  45. package/dist/core/use-intl.esm8.js +10 -5
  46. package/dist/core/use-intl.esm8.js.map +1 -1
  47. package/dist/core/use-intl.esm9.js +44 -22
  48. package/dist/core/use-intl.esm9.js.map +1 -1
  49. package/dist/core/validateMessages.esm.js +28 -0
  50. package/dist/core/validateMessages.esm.js.map +1 -0
  51. package/dist/core.cjs.development.js +93 -0
  52. package/dist/core.cjs.development.js.map +1 -0
  53. package/dist/core.cjs.production.min.js +2 -0
  54. package/dist/core.cjs.production.min.js.map +1 -0
  55. package/dist/core.d.ts +1 -0
  56. package/dist/core.esm.js +7 -0
  57. package/dist/core.esm.js.map +1 -0
  58. package/dist/core.js +8 -0
  59. package/dist/createIntl-34d4281e.js +592 -0
  60. package/dist/createIntl-34d4281e.js.map +1 -0
  61. package/dist/createIntl-bc325740.js +2 -0
  62. package/dist/createIntl-bc325740.js.map +1 -0
  63. package/dist/react/IntlContext.esm.js +6 -0
  64. package/dist/react/IntlContext.esm.js.map +1 -0
  65. package/dist/react/IntlProvider.d.ts +1 -1
  66. package/dist/react/IntlProvider.esm.js +22 -0
  67. package/dist/react/IntlProvider.esm.js.map +1 -0
  68. package/dist/react/getInitializedConfig.d.ts +1 -13
  69. package/dist/react/use-intl.esm.js +22 -18
  70. package/dist/react/use-intl.esm.js.map +1 -1
  71. package/dist/react/use-intl.esm10.js +8 -24
  72. package/dist/react/use-intl.esm10.js.map +1 -1
  73. package/dist/react/use-intl.esm11.js +3 -10
  74. package/dist/react/use-intl.esm11.js.map +1 -1
  75. package/dist/react/use-intl.esm2.js +4 -22
  76. package/dist/react/use-intl.esm2.js.map +1 -1
  77. package/dist/react/use-intl.esm3.js +26 -4
  78. package/dist/react/use-intl.esm3.js.map +1 -1
  79. package/dist/react/use-intl.esm4.js +18 -41
  80. package/dist/react/use-intl.esm4.js.map +1 -1
  81. package/dist/react/use-intl.esm5.js +20 -4
  82. package/dist/react/use-intl.esm5.js.map +1 -1
  83. package/dist/react/use-intl.esm6.js +41 -4
  84. package/dist/react/use-intl.esm6.js.map +1 -1
  85. package/dist/react/use-intl.esm7.js +4 -20
  86. package/dist/react/use-intl.esm7.js.map +1 -1
  87. package/dist/react/use-intl.esm8.js +4 -26
  88. package/dist/react/use-intl.esm8.js.map +1 -1
  89. package/dist/react/use-intl.esm9.js +33 -3
  90. package/dist/react/use-intl.esm9.js.map +1 -1
  91. package/dist/react/useFormatter.esm.js +24 -0
  92. package/dist/react/useFormatter.esm.js.map +1 -0
  93. package/dist/react/useIntl.esm.js +30 -0
  94. package/dist/react/useIntl.esm.js.map +1 -0
  95. package/dist/react/useIntlContext.esm.js +13 -0
  96. package/dist/react/useIntlContext.esm.js.map +1 -0
  97. package/dist/react/useLocale.esm.js +8 -0
  98. package/dist/react/useLocale.esm.js.map +1 -0
  99. package/dist/react/useMessages.esm.js +8 -0
  100. package/dist/react/useMessages.esm.js.map +1 -0
  101. package/{src/react/useNow.tsx → dist/react/useNow.esm.js} +32 -36
  102. package/dist/react/useNow.esm.js.map +1 -0
  103. package/dist/react/useTimeZone.esm.js +8 -0
  104. package/dist/react/useTimeZone.esm.js.map +1 -0
  105. package/dist/react/useTranslations.esm.js +26 -0
  106. package/dist/react/useTranslations.esm.js.map +1 -0
  107. package/dist/react/{use-intl.esm12.js → useTranslationsImpl.esm.js} +6 -13
  108. package/dist/react/useTranslationsImpl.esm.js.map +1 -0
  109. package/dist/react.cjs.development.js +190 -0
  110. package/dist/react.cjs.development.js.map +1 -0
  111. package/dist/react.cjs.production.min.js +2 -0
  112. package/dist/react.cjs.production.min.js.map +1 -0
  113. package/dist/react.d.ts +1 -0
  114. package/dist/react.esm.js +9 -0
  115. package/dist/react.esm.js.map +1 -0
  116. package/dist/react.js +8 -0
  117. package/dist/test/setup.d.ts +1 -0
  118. package/dist/use-intl.cjs.development.js +32 -30
  119. package/dist/use-intl.cjs.development.js.map +1 -1
  120. package/dist/use-intl.cjs.production.min.js +1 -1
  121. package/dist/use-intl.cjs.production.min.js.map +1 -1
  122. package/dist/use-intl.esm.js +12 -10
  123. package/dist/use-intl.esm.js.map +1 -1
  124. package/package.json +17 -15
  125. package/react.d.ts +1 -0
  126. package/dist/react/use-intl.esm12.js.map +0 -1
  127. package/dist/src/core/AbstractIntlMessages.d.ts +0 -9
  128. package/dist/src/core/AbstractIntlMessages.js +0 -2
  129. package/dist/src/core/AbstractIntlMessages.js.map +0 -1
  130. package/dist/src/core/DateTimeFormatOptions.d.ts +0 -73
  131. package/dist/src/core/DateTimeFormatOptions.js +0 -3
  132. package/dist/src/core/DateTimeFormatOptions.js.map +0 -1
  133. package/dist/src/core/Formats.d.ts +0 -8
  134. package/dist/src/core/Formats.js +0 -2
  135. package/dist/src/core/Formats.js.map +0 -1
  136. package/dist/src/core/IntlConfig.d.ts +0 -54
  137. package/dist/src/core/IntlConfig.js +0 -2
  138. package/dist/src/core/IntlConfig.js.map +0 -1
  139. package/dist/src/core/IntlError.d.ts +0 -13
  140. package/dist/src/core/IntlError.js +0 -23
  141. package/dist/src/core/IntlError.js.map +0 -1
  142. package/dist/src/core/MessageFormatCache.d.ts +0 -5
  143. package/dist/src/core/MessageFormatCache.js +0 -2
  144. package/dist/src/core/MessageFormatCache.js.map +0 -1
  145. package/dist/src/core/NumberFormatOptions.d.ts +0 -2
  146. package/dist/src/core/NumberFormatOptions.js +0 -2
  147. package/dist/src/core/NumberFormatOptions.js.map +0 -1
  148. package/dist/src/core/TimeZone.d.ts +0 -2
  149. package/dist/src/core/TimeZone.js +0 -2
  150. package/dist/src/core/TimeZone.js.map +0 -1
  151. package/dist/src/core/TranslationValues.d.ts +0 -5
  152. package/dist/src/core/TranslationValues.js +0 -2
  153. package/dist/src/core/TranslationValues.js.map +0 -1
  154. package/dist/src/core/convertFormatsToIntlMessageFormat.d.ts +0 -11
  155. package/dist/src/core/convertFormatsToIntlMessageFormat.js +0 -47
  156. package/dist/src/core/convertFormatsToIntlMessageFormat.js.map +0 -1
  157. package/dist/src/core/createBaseTranslator.d.ts +0 -26
  158. package/dist/src/core/createBaseTranslator.js +0 -218
  159. package/dist/src/core/createBaseTranslator.js.map +0 -1
  160. package/dist/src/core/createFormatter.d.ts +0 -19
  161. package/dist/src/core/createFormatter.js +0 -129
  162. package/dist/src/core/createFormatter.js.map +0 -1
  163. package/dist/src/core/createIntl.d.ts +0 -7
  164. package/dist/src/core/createIntl.js +0 -11
  165. package/dist/src/core/createIntl.js.map +0 -1
  166. package/dist/src/core/createTranslator.d.ts +0 -48
  167. package/dist/src/core/createTranslator.js +0 -24
  168. package/dist/src/core/createTranslator.js.map +0 -1
  169. package/dist/src/core/createTranslatorImpl.d.ts +0 -14
  170. package/dist/src/core/createTranslatorImpl.js +0 -43
  171. package/dist/src/core/createTranslatorImpl.js.map +0 -1
  172. package/dist/src/core/defaults.d.ts +0 -11
  173. package/dist/src/core/defaults.js +0 -11
  174. package/dist/src/core/defaults.js.map +0 -1
  175. package/dist/src/core/index.d.ts +0 -9
  176. package/dist/src/core/index.js +0 -6
  177. package/dist/src/core/index.js.map +0 -1
  178. package/dist/src/core/resolveNamespace.d.ts +0 -5
  179. package/dist/src/core/resolveNamespace.js +0 -10
  180. package/dist/src/core/resolveNamespace.js.map +0 -1
  181. package/dist/src/core/utils/MessageKeys.d.ts +0 -5
  182. package/dist/src/core/utils/MessageKeys.js +0 -2
  183. package/dist/src/core/utils/MessageKeys.js.map +0 -1
  184. package/dist/src/core/utils/NamespaceKeys.d.ts +0 -5
  185. package/dist/src/core/utils/NamespaceKeys.js +0 -2
  186. package/dist/src/core/utils/NamespaceKeys.js.map +0 -1
  187. package/dist/src/core/utils/NestedKeyOf.d.ts +0 -4
  188. package/dist/src/core/utils/NestedKeyOf.js +0 -2
  189. package/dist/src/core/utils/NestedKeyOf.js.map +0 -1
  190. package/dist/src/core/utils/NestedValueOf.d.ts +0 -2
  191. package/dist/src/core/utils/NestedValueOf.js +0 -2
  192. package/dist/src/core/utils/NestedValueOf.js.map +0 -1
  193. package/dist/src/core/validateMessages.d.ts +0 -3
  194. package/dist/src/core/validateMessages.js +0 -56
  195. package/dist/src/core/validateMessages.js.map +0 -1
  196. package/dist/src/index.d.ts +0 -2
  197. package/dist/src/index.js +0 -3
  198. package/dist/src/index.js.map +0 -1
  199. package/dist/src/react/IntlContext.d.ts +0 -13
  200. package/dist/src/react/IntlContext.js +0 -4
  201. package/dist/src/react/IntlContext.js.map +0 -1
  202. package/dist/src/react/IntlProvider.d.ts +0 -7
  203. package/dist/src/react/IntlProvider.js +0 -11
  204. package/dist/src/react/IntlProvider.js.map +0 -1
  205. package/dist/src/react/getInitializedConfig.d.ts +0 -13
  206. package/dist/src/react/getInitializedConfig.js +0 -21
  207. package/dist/src/react/getInitializedConfig.js.map +0 -1
  208. package/dist/src/react/index.d.ts +0 -8
  209. package/dist/src/react/index.js +0 -10
  210. package/dist/src/react/index.js.map +0 -1
  211. package/dist/src/react/useFormatter.d.ts +0 -6
  212. package/dist/src/react/useFormatter.js +0 -14
  213. package/dist/src/react/useFormatter.js.map +0 -1
  214. package/dist/src/react/useIntl.d.ts +0 -6
  215. package/dist/src/react/useIntl.js +0 -20
  216. package/dist/src/react/useIntl.js.map +0 -1
  217. package/dist/src/react/useIntlContext.d.ts +0 -10
  218. package/dist/src/react/useIntlContext.js +0 -12
  219. package/dist/src/react/useIntlContext.js.map +0 -1
  220. package/dist/src/react/useLocale.d.ts +0 -1
  221. package/dist/src/react/useLocale.js +0 -5
  222. package/dist/src/react/useLocale.js.map +0 -1
  223. package/dist/src/react/useMessages.d.ts +0 -1
  224. package/dist/src/react/useMessages.js +0 -5
  225. package/dist/src/react/useMessages.js.map +0 -1
  226. package/dist/src/react/useNow.d.ts +0 -23
  227. package/dist/src/react/useNow.js +0 -40
  228. package/dist/src/react/useNow.js.map +0 -1
  229. package/dist/src/react/useTimeZone.d.ts +0 -1
  230. package/dist/src/react/useTimeZone.js +0 -5
  231. package/dist/src/react/useTimeZone.js.map +0 -1
  232. package/dist/src/react/useTranslations.d.ts +0 -44
  233. package/dist/src/react/useTranslations.js +0 -21
  234. package/dist/src/react/useTranslations.js.map +0 -1
  235. package/dist/src/react/useTranslationsImpl.d.ts +0 -8
  236. package/dist/src/react/useTranslationsImpl.js +0 -35
  237. package/dist/src/react/useTranslationsImpl.js.map +0 -1
  238. package/src/core/AbstractIntlMessages.tsx +0 -10
  239. package/src/core/DateTimeFormatOptions.tsx +0 -130
  240. package/src/core/Formats.tsx +0 -10
  241. package/src/core/IntlConfig.tsx +0 -59
  242. package/src/core/IntlError.tsx +0 -26
  243. package/src/core/MessageFormatCache.tsx +0 -10
  244. package/src/core/NumberFormatOptions.tsx +0 -3
  245. package/src/core/TimeZone.tsx +0 -426
  246. package/src/core/TranslationValues.tsx +0 -22
  247. package/src/core/convertFormatsToIntlMessageFormat.tsx +0 -63
  248. package/src/core/createBaseTranslator.tsx +0 -352
  249. package/src/core/createFormatter.tsx +0 -191
  250. package/src/core/createIntl.tsx +0 -13
  251. package/src/core/createTranslator.tsx +0 -112
  252. package/src/core/createTranslatorImpl.tsx +0 -87
  253. package/src/core/defaults.tsx +0 -18
  254. package/src/core/index.tsx +0 -14
  255. package/src/core/resolveNamespace.tsx +0 -12
  256. package/src/core/utils/MessageKeys.tsx +0 -9
  257. package/src/core/utils/NamespaceKeys.tsx +0 -9
  258. package/src/core/utils/NestedKeyOf.tsx +0 -9
  259. package/src/core/utils/NestedValueOf.tsx +0 -12
  260. package/src/core/validateMessages.tsx +0 -77
  261. package/src/index.tsx +0 -2
  262. package/src/react/IntlContext.tsx +0 -12
  263. package/src/react/IntlProvider.tsx +0 -23
  264. package/src/react/getInitializedConfig.tsx +0 -29
  265. package/src/react/index.tsx +0 -10
  266. package/src/react/useFormatter.tsx +0 -19
  267. package/src/react/useIntl.tsx +0 -29
  268. package/src/react/useIntlContext.tsx +0 -16
  269. package/src/react/useLocale.tsx +0 -5
  270. package/src/react/useMessages.tsx +0 -5
  271. package/src/react/useTimeZone.tsx +0 -5
  272. package/src/react/useTranslations.tsx +0 -103
  273. package/src/react/useTranslationsImpl.tsx +0 -61
@@ -1 +0,0 @@
1
- {"version":3,"file":"NumberFormatOptions.js","sourceRoot":"","sources":["../../../src/core/NumberFormatOptions.tsx"],"names":[],"mappings":""}
@@ -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,47 +0,0 @@
1
- // eslint-disable-next-line import/no-named-as-default -- False positive
2
- import IntlMessageFormat from 'intl-messageformat';
3
- function setTimeZoneInFormats(formats, timeZone) {
4
- if (!formats)
5
- return formats;
6
- // The only way to set a time zone with `intl-messageformat` is to merge it into the formats
7
- // https://github.com/formatjs/formatjs/blob/8256c5271505cf2606e48e3c97ecdd16ede4f1b5/packages/intl/src/message.ts#L15
8
- return Object.keys(formats).reduce((acc, key) => {
9
- acc[key] = {
10
- timeZone,
11
- ...formats[key]
12
- };
13
- return acc;
14
- }, {});
15
- }
16
- /**
17
- * `intl-messageformat` uses separate keys for `date` and `time`, but there's
18
- * only one native API: `Intl.DateTimeFormat`. Additionally you might want to
19
- * include both a time and a date in a value, therefore the separation doesn't
20
- * seem so useful. We offer a single `dateTime` namespace instead, but we have
21
- * to convert the format before `intl-messageformat` can be used.
22
- */
23
- export default function convertFormatsToIntlMessageFormat(formats, timeZone) {
24
- const formatsWithTimeZone = timeZone
25
- ? { ...formats, dateTime: setTimeZoneInFormats(formats.dateTime, timeZone) }
26
- : formats;
27
- const mfDateDefaults = IntlMessageFormat.formats.date;
28
- const defaultDateFormats = timeZone
29
- ? setTimeZoneInFormats(mfDateDefaults, timeZone)
30
- : mfDateDefaults;
31
- const mfTimeDefaults = IntlMessageFormat.formats.time;
32
- const defaultTimeFormats = timeZone
33
- ? setTimeZoneInFormats(mfTimeDefaults, timeZone)
34
- : mfTimeDefaults;
35
- return {
36
- ...formatsWithTimeZone,
37
- date: {
38
- ...defaultDateFormats,
39
- ...formatsWithTimeZone?.dateTime
40
- },
41
- time: {
42
- ...defaultTimeFormats,
43
- ...formatsWithTimeZone?.dateTime
44
- }
45
- };
46
- }
47
- //# sourceMappingURL=convertFormatsToIntlMessageFormat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"convertFormatsToIntlMessageFormat.js","sourceRoot":"","sources":["../../../src/core/convertFormatsToIntlMessageFormat.tsx"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,OAAO,iBAA2C,MAAM,oBAAoB,CAAC;AAK7E,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,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAA2B,CAAC;IAC7E,MAAM,kBAAkB,GAAG,QAAQ;QACjC,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,QAAQ,CAAC;QAChD,CAAC,CAAC,cAAc,CAAC;IAEnB,MAAM,cAAc,GAAG,iBAAiB,CAAC,OAAO,CAAC,IAA2B,CAAC;IAC7E,MAAM,kBAAkB,GAAG,QAAQ;QACjC,CAAC,CAAC,oBAAoB,CAAC,cAAc,EAAE,QAAQ,CAAC;QAChD,CAAC,CAAC,cAAc,CAAC;IAEnB,OAAO;QACL,GAAG,mBAAmB;QACtB,IAAI,EAAE;YACJ,GAAG,kBAAkB;YACrB,GAAG,mBAAmB,EAAE,QAAQ;SACjC;QACD,IAAI,EAAE;YACJ,GAAG,kBAAkB;YACrB,GAAG,mBAAmB,EAAE,QAAQ;SACjC;KACF,CAAC;AACJ,CAAC"}
@@ -1,26 +0,0 @@
1
- import { ReactElement, ReactNodeArray } from 'react';
2
- import AbstractIntlMessages from './AbstractIntlMessages';
3
- import Formats from './Formats';
4
- import { InitializedIntlConfig } from './IntlConfig';
5
- import IntlError from './IntlError';
6
- import MessageFormatCache from './MessageFormatCache';
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
- messageFormatCache?: MessageFormatCache;
18
- defaultTranslationValues?: RichTranslationValues;
19
- namespace?: string;
20
- messagesOrError: Messages | IntlError;
21
- };
22
- export default function createBaseTranslator<Messages extends AbstractIntlMessages, NestedKey extends NestedKeyOf<Messages>>({ defaultTranslationValues, formats: globalFormats, getMessageFallback, locale, messageFormatCache, 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,218 +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
- function getPlainMessage(candidate, values) {
73
- if (values)
74
- return undefined;
75
- const unescapedMessage = candidate.replace(/'([{}])/gi, '$1');
76
- // Placeholders can be in the message if there are default values,
77
- // or if the user has forgotten to provide values. In the latter
78
- // case we need to compile the message to receive an error.
79
- const hasPlaceholders = /<|{/.test(unescapedMessage);
80
- if (!hasPlaceholders) {
81
- return unescapedMessage;
82
- }
83
- return undefined;
84
- }
85
- export default function createBaseTranslator({ defaultTranslationValues, formats: globalFormats, getMessageFallback = defaultGetMessageFallback, locale, messageFormatCache, messagesOrError, namespace, onError, timeZone }) {
86
- function getFallbackFromErrorAndNotify(key, code, message) {
87
- const error = new IntlError(code, message);
88
- onError(error);
89
- return getMessageFallback({ error, key, namespace });
90
- }
91
- function translateBaseFn(
92
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
93
- key,
94
- /** Key value pairs for values to interpolate into the message. */
95
- values,
96
- /** Provide custom formats for numbers, dates and times. */
97
- formats) {
98
- if (messagesOrError instanceof IntlError) {
99
- // We have already warned about this during render
100
- return getMessageFallback({
101
- error: messagesOrError,
102
- key,
103
- namespace
104
- });
105
- }
106
- const messages = messagesOrError;
107
- let message;
108
- try {
109
- message = resolvePath(messages, key, namespace);
110
- }
111
- catch (error) {
112
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
113
- }
114
- function joinPath(parts) {
115
- return parts.filter((part) => part != null).join('.');
116
- }
117
- const cacheKey = joinPath([locale, namespace, key, String(message)]);
118
- let messageFormat;
119
- if (messageFormatCache?.has(cacheKey)) {
120
- messageFormat = messageFormatCache.get(cacheKey);
121
- }
122
- else {
123
- if (typeof message === 'object') {
124
- let code, errorMessage;
125
- if (Array.isArray(message)) {
126
- code = IntlErrorCode.INVALID_MESSAGE;
127
- if (process.env.NODE_ENV !== 'production') {
128
- errorMessage = `Message at \`${joinPath([
129
- namespace,
130
- key
131
- ])}\` resolved to an array, but only strings are supported. See https://next-intl-docs.vercel.app/docs/usage/messages#arrays-of-messages`;
132
- }
133
- }
134
- else {
135
- code = IntlErrorCode.INSUFFICIENT_PATH;
136
- if (process.env.NODE_ENV !== 'production') {
137
- errorMessage = `Message at \`${joinPath([
138
- namespace,
139
- key
140
- ])}\` 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`;
141
- }
142
- }
143
- return getFallbackFromErrorAndNotify(key, code, errorMessage);
144
- }
145
- // Hot path that avoids creating an `IntlMessageFormat` instance
146
- const plainMessage = getPlainMessage(message, values);
147
- if (plainMessage)
148
- return plainMessage;
149
- try {
150
- messageFormat = new IntlMessageFormat(message, locale, convertFormatsToIntlMessageFormat({ ...globalFormats, ...formats }, timeZone));
151
- }
152
- catch (error) {
153
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, error.message);
154
- }
155
- messageFormatCache?.set(cacheKey, messageFormat);
156
- }
157
- try {
158
- const formattedMessage = messageFormat.format(
159
- // @ts-ignore `intl-messageformat` expects a different format
160
- // for rich text elements since a recent minor update. This
161
- // needs to be evaluated in detail, possibly also in regards
162
- // to be able to format to parts.
163
- prepareTranslationValues({ ...defaultTranslationValues, ...values }));
164
- if (formattedMessage == null) {
165
- throw new Error(process.env.NODE_ENV !== 'production'
166
- ? `Unable to format \`${key}\` in ${namespace ? `namespace \`${namespace}\`` : 'messages'}`
167
- : undefined);
168
- }
169
- // Limit the function signature to return strings or React elements
170
- return isValidElement(formattedMessage) ||
171
- // Arrays of React elements
172
- Array.isArray(formattedMessage) ||
173
- typeof formattedMessage === 'string'
174
- ? formattedMessage
175
- : String(formattedMessage);
176
- }
177
- catch (error) {
178
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.FORMATTING_ERROR, error.message);
179
- }
180
- }
181
- function translateFn(
182
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
183
- key,
184
- /** Key value pairs for values to interpolate into the message. */
185
- values,
186
- /** Provide custom formats for numbers, dates and times. */
187
- formats) {
188
- const result = translateBaseFn(key, values, formats);
189
- if (typeof result !== 'string') {
190
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.INVALID_MESSAGE, process.env.NODE_ENV !== 'production'
191
- ? `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.`
192
- : undefined);
193
- }
194
- return result;
195
- }
196
- translateFn.rich = translateBaseFn;
197
- translateFn.raw = (
198
- /** Use a dot to indicate a level of nesting (e.g. `namespace.nestedLabel`). */
199
- key) => {
200
- if (messagesOrError instanceof IntlError) {
201
- // We have already warned about this during render
202
- return getMessageFallback({
203
- error: messagesOrError,
204
- key,
205
- namespace
206
- });
207
- }
208
- const messages = messagesOrError;
209
- try {
210
- return resolvePath(messages, key, namespace);
211
- }
212
- catch (error) {
213
- return getFallbackFromErrorAndNotify(key, IntlErrorCode.MISSING_MESSAGE, error.message);
214
- }
215
- };
216
- return translateFn;
217
- }
218
- //# 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;AAGr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,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;QACr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AAE,MAAM;aAChB,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;SACxB;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CACL,IAAI,SAAS,CAAC,aAAa,CAAC,gBAAgB,EAAG,KAAe,CAAC,OAAO,CAAC,CACxE,CAAC;YACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;SACrB;IACH,CAAC;IAED,SAAS,IAAI,CACX,KAAuB,EACvB,eAAiD;QAEjD,OAAO,iBAAiB,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,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