@coveo/atomic 3.31.2-pre.cd43f025b9 → 3.31.2-pre.da74c43571

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 (240) hide show
  1. package/dist/atomic/_atomic.esm.js +1 -1
  2. package/dist/atomic/atomic.esm.js.map +1 -1
  3. package/dist/atomic/components/_index.d.ts +0 -2
  4. package/dist/atomic/components/_index.js +0 -1
  5. package/dist/atomic/components/analytics-config.js +235 -299
  6. package/dist/atomic/components/analytics-config.js.map +1 -1
  7. package/dist/atomic/components/atomic-category-facet.js +1 -1
  8. package/dist/atomic/components/atomic-facet.js +1 -1
  9. package/dist/atomic/components/atomic-format-currency.js +1 -1
  10. package/dist/atomic/components/atomic-format-number.js +1 -1
  11. package/dist/atomic/components/atomic-format-unit.js +1 -1
  12. package/dist/atomic/components/atomic-numeric-facet.js +1 -1
  13. package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
  14. package/dist/atomic/components/atomic-quickview.js +1 -1
  15. package/dist/atomic/components/atomic-result-children.js +1 -1
  16. package/dist/atomic/components/atomic-result-fields-list.js +1 -1
  17. package/dist/atomic/components/atomic-result-link.js +1 -1
  18. package/dist/atomic/components/atomic-result-list.js +1 -1
  19. package/dist/atomic/components/atomic-search-box-query-suggestions2.js +1 -1
  20. package/dist/atomic/components/atomic-search-box-recent-queries2.js +1 -1
  21. package/dist/atomic/components/atomic-search-interface.js +1 -7
  22. package/dist/atomic/components/atomic-search-interface.js.map +1 -1
  23. package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
  24. package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
  25. package/dist/atomic/components/atomic-sort-expression.js +1 -1
  26. package/dist/atomic/components/atomic-tab-manager.js +1 -1
  27. package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.tw.css.js +1 -1
  28. package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +15 -26
  29. package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tw.css.js +1 -1
  30. package/dist/atomic/components/components/commerce/atomic-commerce-layout/atomic-commerce-layout.tw.css.js +1 -1
  31. package/dist/atomic/components/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.tw.css.js +1 -1
  32. package/dist/atomic/components/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tw.css.js +1 -1
  33. package/dist/atomic/components/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.tw.css.js +1 -1
  34. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +16 -35
  35. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.tw.css.js +1 -1
  36. package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-list/atomic-commerce-recommendation-list.tw.css.js +1 -1
  37. package/dist/atomic/components/components/commerce/atomic-commerce-refine-modal/atomic-commerce-refine-modal.tw.css.js +1 -1
  38. package/dist/atomic/components/components/commerce/atomic-commerce-refine-toggle/atomic-commerce-refine-toggle.tw.css.js +1 -1
  39. package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +3 -0
  40. package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tw.css.js +1 -1
  41. package/dist/atomic/components/components/commerce/atomic-commerce-sort-dropdown/atomic-commerce-sort-dropdown.tw.css.js +1 -1
  42. package/dist/atomic/components/components/commerce/atomic-product/atomic-product.tw.css.js +1 -1
  43. package/dist/atomic/components/components/commerce/atomic-product-children/atomic-product-children.tw.css.js +1 -1
  44. package/dist/atomic/components/components/commerce/atomic-product-description/atomic-product-description.tw.css.js +1 -1
  45. package/dist/atomic/components/components/commerce/atomic-product-excerpt/atomic-product-excerpt.tw.css.js +1 -1
  46. package/dist/atomic/components/components/commerce/atomic-product-link/atomic-product-link.tw.css.js +1 -1
  47. package/dist/atomic/components/components/commerce/atomic-product-multi-value-text/atomic-product-multi-value-text.tw.css.js +1 -1
  48. package/dist/atomic/components/components/commerce/atomic-product-price/atomic-product-price.tw.css.js +1 -1
  49. package/dist/atomic/components/components/common/atomic-aria-live/atomic-aria-live.js +102 -0
  50. package/dist/atomic/components/components/common/atomic-icon/atomic-icon.tw.css.js +1 -1
  51. package/dist/atomic/components/components/common/facets/facet-common.tw.css.js +1 -1
  52. package/dist/atomic/components/components/common/facets/facet-search/facet-search.tw.css.js +1 -1
  53. package/dist/atomic/components/components/common/facets/facet-value-box/facet-value-box.tw.css.js +1 -1
  54. package/dist/atomic/components/components/common/facets/facet-value-checkbox/facet-value-checkbox.tw.css.js +1 -1
  55. package/dist/atomic/components/components/common/facets/facet-value-exclude/facet-value-exclude.tw.css.js +1 -1
  56. package/dist/atomic/components/components/common/index.js +1 -0
  57. package/dist/atomic/components/components/common/interface/interface-controller.js +89 -0
  58. package/dist/atomic/components/components/common/lazy-index.js +1 -0
  59. package/dist/atomic/components/components/common/refine-modal/refine-modal-common.tw.css.js +1 -1
  60. package/dist/atomic/components/debounce-utils.js +1 -34
  61. package/dist/atomic/components/debounce-utils.js.map +1 -1
  62. package/dist/atomic/components/global/environment.js +1 -1
  63. package/dist/atomic/components/global/tailwind.default.css.js +1 -1
  64. package/dist/atomic/components/index.js.map +1 -1
  65. package/dist/atomic/components/stencil-accessibility-utils.js.map +1 -1
  66. package/dist/atomic/components/themes/accessible.css.js +1 -1
  67. package/dist/atomic/components/themes/coveo.css.js +1 -1
  68. package/dist/atomic/components/utils/coveo.tw.css.js +1 -1
  69. package/dist/atomic/components/utils/tailwind-utilities/aspect-square.tw.css.js +1 -1
  70. package/dist/atomic/components/utils/tailwind-utilities/components.tw.css.js +1 -1
  71. package/dist/atomic/components/utils/tailwind-utilities/hide-scrollbar.tw.css.js +1 -1
  72. package/dist/atomic/components/utils/tailwind-utilities/link-style.tw.css.js +1 -1
  73. package/dist/atomic/components/utils/tailwind-utilities/set-font-size.tw.css.js +1 -1
  74. package/dist/atomic/components/utils/tailwind-utilities/utilities.tw.css.js +1 -1
  75. package/dist/atomic/components/utils/tailwind.global.tw.css.js +1 -1
  76. package/dist/atomic/p-01c91b69.js +2 -0
  77. package/dist/atomic/p-01c91b69.js.map +1 -0
  78. package/dist/atomic/{p-1b491649.entry.js → p-0af927f0.entry.js} +2 -2
  79. package/dist/atomic/{p-b043958c.entry.js → p-0b9cd281.entry.js} +2 -2
  80. package/dist/atomic/{p-e44ba87e.entry.js → p-0f5ae66e.entry.js} +2 -2
  81. package/dist/atomic/{p-0674783d.entry.js → p-1b329f85.entry.js} +2 -2
  82. package/dist/atomic/p-271cf67e.entry.js +2 -0
  83. package/dist/atomic/p-271cf67e.entry.js.map +1 -0
  84. package/dist/atomic/p-306161d1.entry.js +2 -0
  85. package/dist/atomic/{p-a0445771.entry.js → p-4c5702ba.entry.js} +2 -2
  86. package/dist/atomic/{p-acc4d5de.js → p-53bcc515.js} +2 -2
  87. package/dist/atomic/{p-e2560da8.entry.js → p-5f64bbe0.entry.js} +2 -2
  88. package/dist/atomic/{p-fc73190d.entry.js → p-6638ca39.entry.js} +2 -2
  89. package/dist/atomic/{p-b6cdee3e.entry.js → p-6c412aa0.entry.js} +2 -2
  90. package/dist/atomic/{p-1176959c.entry.js → p-6f8ae3d2.entry.js} +2 -2
  91. package/dist/atomic/{p-0ed0e8b8.entry.js → p-731f82ed.entry.js} +2 -2
  92. package/dist/atomic/{p-25f8b8d8.entry.js → p-7a07530d.entry.js} +2 -2
  93. package/dist/atomic/{p-c8d47706.entry.js → p-7a5d346b.entry.js} +2 -2
  94. package/dist/atomic/{p-f8ff0f44.entry.js → p-7db6d666.entry.js} +2 -2
  95. package/dist/atomic/{p-1e0f2e91.entry.js → p-8434625a.entry.js} +2 -2
  96. package/dist/atomic/{p-5b888121.entry.js → p-89721f11.entry.js} +2 -2
  97. package/dist/atomic/{p-29c272bb.entry.js → p-91d52cad.entry.js} +2 -2
  98. package/dist/atomic/p-96a6f84f.js.map +1 -1
  99. package/dist/atomic/{p-11dd759c.entry.js → p-b1f7ac63.entry.js} +2 -2
  100. package/dist/atomic/{p-5fc9f751.entry.js → p-bf5d5c79.entry.js} +2 -2
  101. package/dist/atomic/{p-716e9e1d.entry.js → p-c0025d4c.entry.js} +2 -2
  102. package/dist/atomic/p-d99e359b.js +2 -0
  103. package/dist/atomic/p-d99e359b.js.map +1 -0
  104. package/dist/atomic/{p-494c57a0.entry.js → p-e406cacd.entry.js} +2 -2
  105. package/dist/atomic/{p-dbf09b26.entry.js → p-ef45ff5c.entry.js} +2 -2
  106. package/dist/atomic/p-f0e861c5.entry.js +2 -0
  107. package/dist/atomic/{p-391c26ba.entry.js → p-f9bfd18b.entry.js} +2 -2
  108. package/dist/cjs/_loader.cjs.js +1 -1
  109. package/dist/cjs/{analytics-config-0a4776c9.js → analytics-config-e18c57f7.js} +236 -300
  110. package/dist/cjs/analytics-config-e18c57f7.js.map +1 -0
  111. package/dist/cjs/atomic-category-facet.cjs.entry.js +1 -1
  112. package/dist/cjs/atomic-facet.cjs.entry.js +1 -1
  113. package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
  114. package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
  115. package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
  116. package/dist/cjs/atomic-generated-answer.cjs.entry.js +1 -1
  117. package/dist/cjs/atomic-insight-generated-answer.cjs.entry.js +1 -1
  118. package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
  119. package/dist/cjs/atomic-insight-search-box.cjs.entry.js +2 -2
  120. package/dist/cjs/atomic-numeric-facet.cjs.entry.js +1 -1
  121. package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
  122. package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
  123. package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
  124. package/dist/cjs/{atomic-aria-live_2.cjs.entry.js → atomic-relevance-inspector.cjs.entry.js} +1 -68
  125. package/dist/cjs/atomic-relevance-inspector.cjs.entry.js.map +1 -0
  126. package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
  127. package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
  128. package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
  129. package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
  130. package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +2 -2
  131. package/dist/cjs/atomic-search-box.cjs.entry.js +2 -2
  132. package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
  133. package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
  134. package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
  135. package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
  136. package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
  137. package/dist/cjs/atomic.cjs.js +1 -1
  138. package/dist/cjs/debounce-utils-d26bcad4.js +15 -0
  139. package/dist/cjs/debounce-utils-d26bcad4.js.map +1 -0
  140. package/dist/cjs/index-757bc886.js +4 -4
  141. package/dist/cjs/stencil-accessibility-utils-aa4c9f6c.js.map +1 -1
  142. package/dist/cjs/{stencil-suggestion-manager-6f778cf0.js → stencil-suggestion-manager-5fa3ac70.js} +2 -2
  143. package/dist/cjs/{stencil-suggestion-manager-6f778cf0.js.map → stencil-suggestion-manager-5fa3ac70.js.map} +1 -1
  144. package/dist/cjs/version.cjs.js +2 -2
  145. package/dist/esm/_loader.js +1 -1
  146. package/dist/esm/{analytics-config-58dd2a0d.js → analytics-config-b8b6bdbb.js} +236 -300
  147. package/dist/esm/analytics-config-b8b6bdbb.js.map +1 -0
  148. package/dist/esm/atomic-category-facet.entry.js +1 -1
  149. package/dist/esm/atomic-facet.entry.js +1 -1
  150. package/dist/esm/atomic-format-currency.entry.js +1 -1
  151. package/dist/esm/atomic-format-number.entry.js +1 -1
  152. package/dist/esm/atomic-format-unit.entry.js +1 -1
  153. package/dist/esm/atomic-generated-answer.entry.js +1 -1
  154. package/dist/esm/atomic-insight-generated-answer.entry.js +1 -1
  155. package/dist/esm/atomic-insight-interface.entry.js +1 -1
  156. package/dist/esm/atomic-insight-search-box.entry.js +2 -2
  157. package/dist/esm/atomic-numeric-facet.entry.js +1 -1
  158. package/dist/esm/atomic-quickview-modal.entry.js +1 -1
  159. package/dist/esm/atomic-quickview.entry.js +1 -1
  160. package/dist/esm/atomic-recs-interface.entry.js +1 -1
  161. package/dist/esm/{atomic-aria-live_2.entry.js → atomic-relevance-inspector.entry.js} +3 -69
  162. package/dist/esm/atomic-relevance-inspector.entry.js.map +1 -0
  163. package/dist/esm/atomic-result-children.entry.js +1 -1
  164. package/dist/esm/atomic-result-fields-list.entry.js +1 -1
  165. package/dist/esm/atomic-result-link.entry.js +1 -1
  166. package/dist/esm/atomic-result-list.entry.js +1 -1
  167. package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +2 -2
  168. package/dist/esm/atomic-search-box.entry.js +2 -2
  169. package/dist/esm/atomic-search-interface.entry.js +1 -1
  170. package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
  171. package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
  172. package/dist/esm/atomic-sort-expression.entry.js +1 -1
  173. package/dist/esm/atomic-tab-manager.entry.js +1 -1
  174. package/dist/esm/atomic.js +1 -1
  175. package/dist/esm/debounce-utils-8619dece.js +13 -0
  176. package/dist/esm/{debounce-utils-efa015c0.js.map → debounce-utils-8619dece.js.map} +1 -1
  177. package/dist/esm/index-3f35faca.js +4 -4
  178. package/dist/esm/stencil-accessibility-utils-bc273be5.js.map +1 -1
  179. package/dist/esm/{stencil-suggestion-manager-91706623.js → stencil-suggestion-manager-f52c6e39.js} +2 -2
  180. package/dist/esm/{stencil-suggestion-manager-91706623.js.map → stencil-suggestion-manager-f52c6e39.js.map} +1 -1
  181. package/dist/esm/version.js +2 -2
  182. package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +3 -4
  183. package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +5 -6
  184. package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +3 -0
  185. package/dist/types/components/common/atomic-aria-live/atomic-aria-live.d.ts +38 -0
  186. package/dist/types/components/common/index.d.ts +1 -0
  187. package/dist/types/components/common/interface/i18n.d.ts +1 -1
  188. package/dist/types/components/common/interface/{interface-common.d.ts → interface-controller.d.ts} +14 -11
  189. package/dist/types/components.d.ts +0 -27
  190. package/dist/types/utils/accessibility-utils.d.ts +2 -1
  191. package/dist/types/utils/stencil-accessibility-utils.d.ts +2 -1
  192. package/docs/atomic-docs.json +33 -71
  193. package/package.json +5 -5
  194. package/dist/atomic/components/atomic-aria-live.d.ts +0 -11
  195. package/dist/atomic/components/atomic-aria-live.js +0 -8
  196. package/dist/atomic/components/atomic-aria-live.js.map +0 -1
  197. package/dist/atomic/components/atomic-aria-live2.js +0 -87
  198. package/dist/atomic/components/atomic-aria-live2.js.map +0 -1
  199. package/dist/atomic/components/components/common/interface/interface-common.js +0 -95
  200. package/dist/atomic/p-37b7705c.js +0 -2
  201. package/dist/atomic/p-37b7705c.js.map +0 -1
  202. package/dist/atomic/p-3f2442d3.entry.js +0 -2
  203. package/dist/atomic/p-3f2442d3.entry.js.map +0 -1
  204. package/dist/atomic/p-bf4d9634.js +0 -2
  205. package/dist/atomic/p-bf4d9634.js.map +0 -1
  206. package/dist/atomic/p-e790d557.entry.js +0 -2
  207. package/dist/atomic/p-efd2bb5f.entry.js +0 -2
  208. package/dist/cjs/analytics-config-0a4776c9.js.map +0 -1
  209. package/dist/cjs/atomic-aria-live_2.cjs.entry.js.map +0 -1
  210. package/dist/cjs/debounce-utils-e014935f.js +0 -49
  211. package/dist/cjs/debounce-utils-e014935f.js.map +0 -1
  212. package/dist/esm/analytics-config-58dd2a0d.js.map +0 -1
  213. package/dist/esm/atomic-aria-live_2.entry.js.map +0 -1
  214. package/dist/esm/debounce-utils-efa015c0.js +0 -46
  215. package/dist/types/components/search/atomic-search-interface/atomic-aria-live.d.ts +0 -23
  216. /package/dist/atomic/{p-1b491649.entry.js.map → p-0af927f0.entry.js.map} +0 -0
  217. /package/dist/atomic/{p-b043958c.entry.js.map → p-0b9cd281.entry.js.map} +0 -0
  218. /package/dist/atomic/{p-e44ba87e.entry.js.map → p-0f5ae66e.entry.js.map} +0 -0
  219. /package/dist/atomic/{p-0674783d.entry.js.map → p-1b329f85.entry.js.map} +0 -0
  220. /package/dist/atomic/{p-efd2bb5f.entry.js.map → p-306161d1.entry.js.map} +0 -0
  221. /package/dist/atomic/{p-a0445771.entry.js.map → p-4c5702ba.entry.js.map} +0 -0
  222. /package/dist/atomic/{p-acc4d5de.js.map → p-53bcc515.js.map} +0 -0
  223. /package/dist/atomic/{p-e2560da8.entry.js.map → p-5f64bbe0.entry.js.map} +0 -0
  224. /package/dist/atomic/{p-fc73190d.entry.js.map → p-6638ca39.entry.js.map} +0 -0
  225. /package/dist/atomic/{p-b6cdee3e.entry.js.map → p-6c412aa0.entry.js.map} +0 -0
  226. /package/dist/atomic/{p-1176959c.entry.js.map → p-6f8ae3d2.entry.js.map} +0 -0
  227. /package/dist/atomic/{p-0ed0e8b8.entry.js.map → p-731f82ed.entry.js.map} +0 -0
  228. /package/dist/atomic/{p-25f8b8d8.entry.js.map → p-7a07530d.entry.js.map} +0 -0
  229. /package/dist/atomic/{p-c8d47706.entry.js.map → p-7a5d346b.entry.js.map} +0 -0
  230. /package/dist/atomic/{p-f8ff0f44.entry.js.map → p-7db6d666.entry.js.map} +0 -0
  231. /package/dist/atomic/{p-1e0f2e91.entry.js.map → p-8434625a.entry.js.map} +0 -0
  232. /package/dist/atomic/{p-5b888121.entry.js.map → p-89721f11.entry.js.map} +0 -0
  233. /package/dist/atomic/{p-29c272bb.entry.js.map → p-91d52cad.entry.js.map} +0 -0
  234. /package/dist/atomic/{p-11dd759c.entry.js.map → p-b1f7ac63.entry.js.map} +0 -0
  235. /package/dist/atomic/{p-5fc9f751.entry.js.map → p-bf5d5c79.entry.js.map} +0 -0
  236. /package/dist/atomic/{p-716e9e1d.entry.js.map → p-c0025d4c.entry.js.map} +0 -0
  237. /package/dist/atomic/{p-494c57a0.entry.js.map → p-e406cacd.entry.js.map} +0 -0
  238. /package/dist/atomic/{p-dbf09b26.entry.js.map → p-ef45ff5c.entry.js.map} +0 -0
  239. /package/dist/atomic/{p-e790d557.entry.js.map → p-f0e861c5.entry.js.map} +0 -0
  240. /package/dist/atomic/{p-391c26ba.entry.js.map → p-f9bfd18b.entry.js.map} +0 -0
@@ -163,8 +163,7 @@ const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
163
163
  }
164
164
  return matched;
165
165
  };
166
- const deepFind = function (obj, path) {
167
- let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
166
+ const deepFind = (obj, path, keySeparator = '.') => {
168
167
  if (!obj) return undefined;
169
168
  if (obj[path]) {
170
169
  if (!Object.prototype.hasOwnProperty.call(obj, path)) return undefined;
@@ -214,39 +213,25 @@ const consoleLogger = {
214
213
  }
215
214
  };
216
215
  class Logger {
217
- constructor(concreteLogger) {
218
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
216
+ constructor(concreteLogger, options = {}) {
219
217
  this.init(concreteLogger, options);
220
218
  }
221
- init(concreteLogger) {
222
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
219
+ init(concreteLogger, options = {}) {
223
220
  this.prefix = options.prefix || 'i18next:';
224
221
  this.logger = concreteLogger || consoleLogger;
225
222
  this.options = options;
226
223
  this.debug = options.debug;
227
224
  }
228
- log() {
229
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
230
- args[_key] = arguments[_key];
231
- }
225
+ log(...args) {
232
226
  return this.forward(args, 'log', '', true);
233
227
  }
234
- warn() {
235
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
236
- args[_key2] = arguments[_key2];
237
- }
228
+ warn(...args) {
238
229
  return this.forward(args, 'warn', '', true);
239
230
  }
240
- error() {
241
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
242
- args[_key3] = arguments[_key3];
243
- }
231
+ error(...args) {
244
232
  return this.forward(args, 'error', '');
245
233
  }
246
- deprecate() {
247
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
248
- args[_key4] = arguments[_key4];
249
- }
234
+ deprecate(...args) {
250
235
  return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
251
236
  }
252
237
  forward(args, lvl, prefix, debugOnly) {
@@ -290,14 +275,10 @@ class EventEmitter {
290
275
  }
291
276
  this.observers[event].delete(listener);
292
277
  }
293
- emit(event) {
294
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
295
- args[_key - 1] = arguments[_key];
296
- }
278
+ emit(event, ...args) {
297
279
  if (this.observers[event]) {
298
280
  const cloned = Array.from(this.observers[event].entries());
299
- cloned.forEach(_ref => {
300
- let [observer, numTimesAdded] = _ref;
281
+ cloned.forEach(([observer, numTimesAdded]) => {
301
282
  for (let i = 0; i < numTimesAdded; i++) {
302
283
  observer(...args);
303
284
  }
@@ -305,8 +286,7 @@ class EventEmitter {
305
286
  }
306
287
  if (this.observers['*']) {
307
288
  const cloned = Array.from(this.observers['*'].entries());
308
- cloned.forEach(_ref2 => {
309
- let [observer, numTimesAdded] = _ref2;
289
+ cloned.forEach(([observer, numTimesAdded]) => {
310
290
  for (let i = 0; i < numTimesAdded; i++) {
311
291
  observer.apply(observer, [event, ...args]);
312
292
  }
@@ -316,11 +296,10 @@ class EventEmitter {
316
296
  }
317
297
 
318
298
  class ResourceStore extends EventEmitter {
319
- constructor(data) {
320
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
321
- ns: ['translation'],
322
- defaultNS: 'translation'
323
- };
299
+ constructor(data, options = {
300
+ ns: ['translation'],
301
+ defaultNS: 'translation'
302
+ }) {
324
303
  super();
325
304
  this.data = data || {};
326
305
  this.options = options;
@@ -342,8 +321,7 @@ class ResourceStore extends EventEmitter {
342
321
  this.options.ns.splice(index, 1);
343
322
  }
344
323
  }
345
- getResource(lng, ns, key) {
346
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
324
+ getResource(lng, ns, key, options = {}) {
347
325
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
348
326
  const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
349
327
  let path;
@@ -370,10 +348,9 @@ class ResourceStore extends EventEmitter {
370
348
  if (result || !ignoreJSONStructure || !isString(key)) return result;
371
349
  return deepFind(this.data?.[lng]?.[ns], key, keySeparator);
372
350
  }
373
- addResource(lng, ns, key, value) {
374
- let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
375
- silent: false
376
- };
351
+ addResource(lng, ns, key, value, options = {
352
+ silent: false
353
+ }) {
377
354
  const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
378
355
  let path = [lng, ns];
379
356
  if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
@@ -386,10 +363,9 @@ class ResourceStore extends EventEmitter {
386
363
  setPath(this.data, path, value);
387
364
  if (!options.silent) this.emit('added', lng, ns, key, value);
388
365
  }
389
- addResources(lng, ns, resources) {
390
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
391
- silent: false
392
- };
366
+ addResources(lng, ns, resources, options = {
367
+ silent: false
368
+ }) {
393
369
  for (const m in resources) {
394
370
  if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
395
371
  silent: true
@@ -397,11 +373,10 @@ class ResourceStore extends EventEmitter {
397
373
  }
398
374
  if (!options.silent) this.emit('added', lng, ns, resources);
399
375
  }
400
- addResourceBundle(lng, ns, resources, deep, overwrite) {
401
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
402
- silent: false,
403
- skipCopy: false
404
- };
376
+ addResourceBundle(lng, ns, resources, deep, overwrite, options = {
377
+ silent: false,
378
+ skipCopy: false
379
+ }) {
405
380
  let path = [lng, ns];
406
381
  if (lng.indexOf('.') > -1) {
407
382
  path = lng.split('.');
@@ -466,8 +441,7 @@ var postProcessor = {
466
441
  const checkedLoadedFor = {};
467
442
  const shouldHandleAsObject = res => !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
468
443
  class Translator extends EventEmitter {
469
- constructor(services) {
470
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
444
+ constructor(services, options = {}) {
471
445
  super();
472
446
  copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
473
447
  this.options = options;
@@ -479,23 +453,23 @@ class Translator extends EventEmitter {
479
453
  changeLanguage(lng) {
480
454
  if (lng) this.language = lng;
481
455
  }
482
- exists(key) {
483
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
484
- interpolation: {}
456
+ exists(key, o = {
457
+ interpolation: {}
458
+ }) {
459
+ const opt = {
460
+ ...o
485
461
  };
486
- if (key == null) {
487
- return false;
488
- }
489
- const resolved = this.resolve(key, options);
462
+ if (key == null) return false;
463
+ const resolved = this.resolve(key, opt);
490
464
  return resolved?.res !== undefined;
491
465
  }
492
- extractFromKey(key, options) {
493
- let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
466
+ extractFromKey(key, opt) {
467
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
494
468
  if (nsSeparator === undefined) nsSeparator = ':';
495
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
496
- let namespaces = options.ns || this.options.defaultNS || [];
469
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
470
+ let namespaces = opt.ns || this.options.defaultNS || [];
497
471
  const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
498
- const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
472
+ const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !opt.keySeparator && !this.options.userDefinedNsSeparator && !opt.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
499
473
  if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
500
474
  const m = key.match(this.interpolator.nestingRegexp);
501
475
  if (m && m.length > 0) {
@@ -513,28 +487,32 @@ class Translator extends EventEmitter {
513
487
  namespaces: isString(namespaces) ? [namespaces] : namespaces
514
488
  };
515
489
  }
516
- translate(keys, options, lastKey) {
517
- if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
518
- options = this.options.overloadTranslationOptionHandler(arguments);
490
+ translate(keys, o, lastKey) {
491
+ let opt = typeof o === 'object' ? {
492
+ ...o
493
+ } : o;
494
+ if (typeof opt !== 'object' && this.options.overloadTranslationOptionHandler) {
495
+ opt = this.options.overloadTranslationOptionHandler(arguments);
519
496
  }
520
- if (typeof options === 'object') options = {
521
- ...options
497
+ if (typeof options === 'object') opt = {
498
+ ...opt
522
499
  };
523
- if (!options) options = {};
500
+ if (!opt) opt = {};
524
501
  if (keys == null) return '';
525
502
  if (!Array.isArray(keys)) keys = [String(keys)];
526
- const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
527
- const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
503
+ const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
504
+ const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
528
505
  const {
529
506
  key,
530
507
  namespaces
531
- } = this.extractFromKey(keys[keys.length - 1], options);
508
+ } = this.extractFromKey(keys[keys.length - 1], opt);
532
509
  const namespace = namespaces[namespaces.length - 1];
533
- const lng = options.lng || this.language;
534
- const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
510
+ let nsSeparator = opt.nsSeparator !== undefined ? opt.nsSeparator : this.options.nsSeparator;
511
+ if (nsSeparator === undefined) nsSeparator = ':';
512
+ const lng = opt.lng || this.language;
513
+ const appendNamespaceToCIMode = opt.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
535
514
  if (lng?.toLowerCase() === 'cimode') {
536
515
  if (appendNamespaceToCIMode) {
537
- const nsSeparator = options.nsSeparator || this.options.nsSeparator;
538
516
  if (returnDetails) {
539
517
  return {
540
518
  res: `${namespace}${nsSeparator}${key}`,
@@ -542,7 +520,7 @@ class Translator extends EventEmitter {
542
520
  exactUsedKey: key,
543
521
  usedLng: lng,
544
522
  usedNS: namespace,
545
- usedParams: this.getUsedParamsDetails(options)
523
+ usedParams: this.getUsedParamsDetails(opt)
546
524
  };
547
525
  }
548
526
  return `${namespace}${nsSeparator}${key}`;
@@ -554,26 +532,26 @@ class Translator extends EventEmitter {
554
532
  exactUsedKey: key,
555
533
  usedLng: lng,
556
534
  usedNS: namespace,
557
- usedParams: this.getUsedParamsDetails(options)
535
+ usedParams: this.getUsedParamsDetails(opt)
558
536
  };
559
537
  }
560
538
  return key;
561
539
  }
562
- const resolved = this.resolve(keys, options);
540
+ const resolved = this.resolve(keys, opt);
563
541
  let res = resolved?.res;
564
542
  const resUsedKey = resolved?.usedKey || key;
565
543
  const resExactUsedKey = resolved?.exactUsedKey || key;
566
544
  const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
567
- const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
545
+ const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
568
546
  const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
569
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
570
- const hasDefaultValue = Translator.hasDefaultValue(options);
571
- const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
572
- const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
547
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
548
+ const hasDefaultValue = Translator.hasDefaultValue(opt);
549
+ const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, opt) : '';
550
+ const defaultValueSuffixOrdinalFallback = opt.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, opt.count, {
573
551
  ordinal: false
574
552
  }) : '';
575
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
576
- const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
553
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
554
+ const defaultValue = needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] || opt[`defaultValue${defaultValueSuffix}`] || opt[`defaultValue${defaultValueSuffixOrdinalFallback}`] || opt.defaultValue;
577
555
  let resForObjHndl = res;
578
556
  if (handleAsObjectInI18nFormat && !res && hasDefaultValue) {
579
557
  resForObjHndl = defaultValue;
@@ -581,17 +559,17 @@ class Translator extends EventEmitter {
581
559
  const handleAsObject = shouldHandleAsObject(resForObjHndl);
582
560
  const resType = Object.prototype.toString.apply(resForObjHndl);
583
561
  if (handleAsObjectInI18nFormat && resForObjHndl && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(resForObjHndl))) {
584
- if (!options.returnObjects && !this.options.returnObjects) {
562
+ if (!opt.returnObjects && !this.options.returnObjects) {
585
563
  if (!this.options.returnedObjectHandler) {
586
564
  this.logger.warn('accessing an object - but returnObjects options is not enabled!');
587
565
  }
588
566
  const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, resForObjHndl, {
589
- ...options,
567
+ ...opt,
590
568
  ns: namespaces
591
569
  }) : `key '${key} (${this.language})' returned an object instead of string.`;
592
570
  if (returnDetails) {
593
571
  resolved.res = r;
594
- resolved.usedParams = this.getUsedParamsDetails(options);
572
+ resolved.usedParams = this.getUsedParamsDetails(opt);
595
573
  return resolved;
596
574
  }
597
575
  return r;
@@ -605,7 +583,7 @@ class Translator extends EventEmitter {
605
583
  const deepKey = `${newKeyToUse}${keySeparator}${m}`;
606
584
  if (hasDefaultValue && !res) {
607
585
  copy[m] = this.translate(deepKey, {
608
- ...options,
586
+ ...opt,
609
587
  defaultValue: shouldHandleAsObject(defaultValue) ? defaultValue[m] : undefined,
610
588
  ...{
611
589
  joinArrays: false,
@@ -614,7 +592,7 @@ class Translator extends EventEmitter {
614
592
  });
615
593
  } else {
616
594
  copy[m] = this.translate(deepKey, {
617
- ...options,
595
+ ...opt,
618
596
  ...{
619
597
  joinArrays: false,
620
598
  ns: namespaces
@@ -628,7 +606,7 @@ class Translator extends EventEmitter {
628
606
  }
629
607
  } else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
630
608
  res = res.join(joinArrays);
631
- if (res) res = this.extendTranslation(res, keys, options, lastKey);
609
+ if (res) res = this.extendTranslation(res, keys, opt, lastKey);
632
610
  } else {
633
611
  let usedDefault = false;
634
612
  let usedKey = false;
@@ -640,47 +618,47 @@ class Translator extends EventEmitter {
640
618
  usedKey = true;
641
619
  res = key;
642
620
  }
643
- const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
621
+ const missingKeyNoValueFallbackToKey = opt.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
644
622
  const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
645
623
  const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
646
624
  if (usedKey || usedDefault || updateMissing) {
647
625
  this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
648
626
  if (keySeparator) {
649
627
  const fk = this.resolve(key, {
650
- ...options,
628
+ ...opt,
651
629
  keySeparator: false
652
630
  });
653
631
  if (fk && fk.res) this.logger.warn('Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.');
654
632
  }
655
633
  let lngs = [];
656
- const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
634
+ const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, opt.lng || this.language);
657
635
  if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
658
636
  for (let i = 0; i < fallbackLngs.length; i++) {
659
637
  lngs.push(fallbackLngs[i]);
660
638
  }
661
639
  } else if (this.options.saveMissingTo === 'all') {
662
- lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
640
+ lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
663
641
  } else {
664
- lngs.push(options.lng || this.language);
642
+ lngs.push(opt.lng || this.language);
665
643
  }
666
644
  const send = (l, k, specificDefaultValue) => {
667
645
  const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
668
646
  if (this.options.missingKeyHandler) {
669
- this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
647
+ this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, opt);
670
648
  } else if (this.backendConnector?.saveMissing) {
671
- this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
649
+ this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, opt);
672
650
  }
673
651
  this.emit('missingKey', l, namespace, k, res);
674
652
  };
675
653
  if (this.options.saveMissing) {
676
654
  if (this.options.saveMissingPlurals && needsPluralHandling) {
677
655
  lngs.forEach(language => {
678
- const suffixes = this.pluralResolver.getSuffixes(language, options);
679
- if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
656
+ const suffixes = this.pluralResolver.getSuffixes(language, opt);
657
+ if (needsZeroSuffixLookup && opt[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
680
658
  suffixes.push(`${this.options.pluralSeparator}zero`);
681
659
  }
682
660
  suffixes.forEach(suffix => {
683
- send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
661
+ send([language], key + suffix, opt[`defaultValue${suffix}`] || defaultValue);
684
662
  });
685
663
  });
686
664
  } else {
@@ -688,83 +666,80 @@ class Translator extends EventEmitter {
688
666
  }
689
667
  }
690
668
  }
691
- res = this.extendTranslation(res, keys, options, resolved, lastKey);
692
- if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
669
+ res = this.extendTranslation(res, keys, opt, resolved, lastKey);
670
+ if (usedKey && res === key && this.options.appendNamespaceToMissingKey) {
671
+ res = `${namespace}${nsSeparator}${key}`;
672
+ }
693
673
  if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
694
- res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
674
+ res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}${nsSeparator}${key}` : key, usedDefault ? res : undefined, opt);
695
675
  }
696
676
  }
697
677
  if (returnDetails) {
698
678
  resolved.res = res;
699
- resolved.usedParams = this.getUsedParamsDetails(options);
679
+ resolved.usedParams = this.getUsedParamsDetails(opt);
700
680
  return resolved;
701
681
  }
702
682
  return res;
703
683
  }
704
- extendTranslation(res, key, options, resolved, lastKey) {
705
- var _this = this;
684
+ extendTranslation(res, key, opt, resolved, lastKey) {
706
685
  if (this.i18nFormat?.parse) {
707
686
  res = this.i18nFormat.parse(res, {
708
687
  ...this.options.interpolation.defaultVariables,
709
- ...options
710
- }, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
688
+ ...opt
689
+ }, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
711
690
  resolved
712
691
  });
713
- } else if (!options.skipInterpolation) {
714
- if (options.interpolation) this.interpolator.init({
715
- ...options,
692
+ } else if (!opt.skipInterpolation) {
693
+ if (opt.interpolation) this.interpolator.init({
694
+ ...opt,
716
695
  ...{
717
696
  interpolation: {
718
697
  ...this.options.interpolation,
719
- ...options.interpolation
698
+ ...opt.interpolation
720
699
  }
721
700
  }
722
701
  });
723
- const skipOnVariables = isString(res) && (options?.interpolation?.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
702
+ const skipOnVariables = isString(res) && (opt?.interpolation?.skipOnVariables !== undefined ? opt.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
724
703
  let nestBef;
725
704
  if (skipOnVariables) {
726
705
  const nb = res.match(this.interpolator.nestingRegexp);
727
706
  nestBef = nb && nb.length;
728
707
  }
729
- let data = options.replace && !isString(options.replace) ? options.replace : options;
708
+ let data = opt.replace && !isString(opt.replace) ? opt.replace : opt;
730
709
  if (this.options.interpolation.defaultVariables) data = {
731
710
  ...this.options.interpolation.defaultVariables,
732
711
  ...data
733
712
  };
734
- res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
713
+ res = this.interpolator.interpolate(res, data, opt.lng || this.language || resolved.usedLng, opt);
735
714
  if (skipOnVariables) {
736
715
  const na = res.match(this.interpolator.nestingRegexp);
737
716
  const nestAft = na && na.length;
738
- if (nestBef < nestAft) options.nest = false;
717
+ if (nestBef < nestAft) opt.nest = false;
739
718
  }
740
- if (!options.lng && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
741
- if (options.nest !== false) res = this.interpolator.nest(res, function () {
742
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
743
- args[_key] = arguments[_key];
744
- }
745
- if (lastKey?.[0] === args[0] && !options.context) {
746
- _this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
719
+ if (!opt.lng && resolved && resolved.res) opt.lng = this.language || resolved.usedLng;
720
+ if (opt.nest !== false) res = this.interpolator.nest(res, (...args) => {
721
+ if (lastKey?.[0] === args[0] && !opt.context) {
722
+ this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
747
723
  return null;
748
724
  }
749
- return _this.translate(...args, key);
750
- }, options);
751
- if (options.interpolation) this.interpolator.reset();
725
+ return this.translate(...args, key);
726
+ }, opt);
727
+ if (opt.interpolation) this.interpolator.reset();
752
728
  }
753
- const postProcess = options.postProcess || this.options.postProcess;
729
+ const postProcess = opt.postProcess || this.options.postProcess;
754
730
  const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
755
- if (res != null && postProcessorNames?.length && options.applyPostProcessor !== false) {
731
+ if (res != null && postProcessorNames?.length && opt.applyPostProcessor !== false) {
756
732
  res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
757
733
  i18nResolved: {
758
734
  ...resolved,
759
- usedParams: this.getUsedParamsDetails(options)
735
+ usedParams: this.getUsedParamsDetails(opt)
760
736
  },
761
- ...options
762
- } : options, this);
737
+ ...opt
738
+ } : opt, this);
763
739
  }
764
740
  return res;
765
741
  }
766
- resolve(keys) {
767
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
742
+ resolve(keys, opt = {}) {
768
743
  let found;
769
744
  let usedKey;
770
745
  let exactUsedKey;
@@ -773,15 +748,15 @@ class Translator extends EventEmitter {
773
748
  if (isString(keys)) keys = [keys];
774
749
  keys.forEach(k => {
775
750
  if (this.isValidLookup(found)) return;
776
- const extracted = this.extractFromKey(k, options);
751
+ const extracted = this.extractFromKey(k, opt);
777
752
  const key = extracted.key;
778
753
  usedKey = key;
779
754
  let namespaces = extracted.namespaces;
780
755
  if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
781
- const needsPluralHandling = options.count !== undefined && !isString(options.count);
782
- const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0;
783
- const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
784
- const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
756
+ const needsPluralHandling = opt.count !== undefined && !isString(opt.count);
757
+ const needsZeroSuffixLookup = needsPluralHandling && !opt.ordinal && opt.count === 0;
758
+ const needsContextHandling = opt.context !== undefined && (isString(opt.context) || typeof opt.context === 'number') && opt.context !== '';
759
+ const codes = opt.lngs ? opt.lngs : this.languageUtils.toResolveHierarchy(opt.lng || this.language, opt.fallbackLng);
785
760
  namespaces.forEach(ns => {
786
761
  if (this.isValidLookup(found)) return;
787
762
  usedNS = ns;
@@ -794,15 +769,15 @@ class Translator extends EventEmitter {
794
769
  usedLng = code;
795
770
  const finalKeys = [key];
796
771
  if (this.i18nFormat?.addLookupKeys) {
797
- this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
772
+ this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
798
773
  } else {
799
774
  let pluralSuffix;
800
- if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
775
+ if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, opt.count, opt);
801
776
  const zeroSuffix = `${this.options.pluralSeparator}zero`;
802
777
  const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
803
778
  if (needsPluralHandling) {
804
779
  finalKeys.push(key + pluralSuffix);
805
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
780
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
806
781
  finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
807
782
  }
808
783
  if (needsZeroSuffixLookup) {
@@ -810,11 +785,11 @@ class Translator extends EventEmitter {
810
785
  }
811
786
  }
812
787
  if (needsContextHandling) {
813
- const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
788
+ const contextKey = `${key}${this.options.contextSeparator}${opt.context}`;
814
789
  finalKeys.push(contextKey);
815
790
  if (needsPluralHandling) {
816
791
  finalKeys.push(contextKey + pluralSuffix);
817
- if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
792
+ if (opt.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
818
793
  finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
819
794
  }
820
795
  if (needsZeroSuffixLookup) {
@@ -827,7 +802,7 @@ class Translator extends EventEmitter {
827
802
  while (possibleKey = finalKeys.pop()) {
828
803
  if (!this.isValidLookup(found)) {
829
804
  exactUsedKey = possibleKey;
830
- found = this.getResource(code, ns, possibleKey, options);
805
+ found = this.getResource(code, ns, possibleKey, opt);
831
806
  }
832
807
  }
833
808
  });
@@ -844,13 +819,11 @@ class Translator extends EventEmitter {
844
819
  isValidLookup(res) {
845
820
  return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
846
821
  }
847
- getResource(code, ns, key) {
848
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
822
+ getResource(code, ns, key, options = {}) {
849
823
  if (this.i18nFormat?.getResource) return this.i18nFormat.getResource(code, ns, key, options);
850
824
  return this.resourceStore.getResource(code, ns, key, options);
851
825
  }
852
- getUsedParamsDetails() {
853
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
826
+ getUsedParamsDetails(options = {}) {
854
827
  const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
855
828
  const useOptionsReplaceForData = options.replace && !isString(options.replace);
856
829
  let data = useOptionsReplaceForData ? options.replace : options;
@@ -939,6 +912,8 @@ class LanguageUtil {
939
912
  if (!found && this.options.supportedLngs) {
940
913
  codes.forEach(code => {
941
914
  if (found) return;
915
+ const lngScOnly = this.getScriptPartFromCode(code);
916
+ if (this.isSupportedCode(lngScOnly)) return found = lngScOnly;
942
917
  const lngOnly = this.getLanguagePartFromCode(code);
943
918
  if (this.isSupportedCode(lngOnly)) return found = lngOnly;
944
919
  found = this.options.supportedLngs.find(supportedLng => {
@@ -966,7 +941,7 @@ class LanguageUtil {
966
941
  return found || [];
967
942
  }
968
943
  toResolveHierarchy(code, fallbackCode) {
969
- const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
944
+ const fallbackCodes = this.getFallbackCodes((fallbackCode === false ? [] : fallbackCode) || this.options.fallbackLng || [], code);
970
945
  const codes = [];
971
946
  const addCode = c => {
972
947
  if (!c) return;
@@ -1005,8 +980,7 @@ const dummyRule = {
1005
980
  })
1006
981
  };
1007
982
  class PluralResolver {
1008
- constructor(languageUtils) {
1009
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
983
+ constructor(languageUtils, options = {}) {
1010
984
  this.languageUtils = languageUtils;
1011
985
  this.options = options;
1012
986
  this.logger = baseLogger.create('pluralResolver');
@@ -1018,8 +992,7 @@ class PluralResolver {
1018
992
  clearCache() {
1019
993
  this.pluralRulesCache = {};
1020
994
  }
1021
- getRule(code) {
1022
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
995
+ getRule(code, options = {}) {
1023
996
  const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
1024
997
  const type = options.ordinal ? 'ordinal' : 'cardinal';
1025
998
  const cacheKey = JSON.stringify({
@@ -1046,25 +1019,21 @@ class PluralResolver {
1046
1019
  this.pluralRulesCache[cacheKey] = rule;
1047
1020
  return rule;
1048
1021
  }
1049
- needsPlural(code) {
1050
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1022
+ needsPlural(code, options = {}) {
1051
1023
  let rule = this.getRule(code, options);
1052
1024
  if (!rule) rule = this.getRule('dev', options);
1053
1025
  return rule?.resolvedOptions().pluralCategories.length > 1;
1054
1026
  }
1055
- getPluralFormsOfKey(code, key) {
1056
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1027
+ getPluralFormsOfKey(code, key, options = {}) {
1057
1028
  return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
1058
1029
  }
1059
- getSuffixes(code) {
1060
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1030
+ getSuffixes(code, options = {}) {
1061
1031
  let rule = this.getRule(code, options);
1062
1032
  if (!rule) rule = this.getRule('dev', options);
1063
1033
  if (!rule) return [];
1064
1034
  return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
1065
1035
  }
1066
- getSuffix(code, count) {
1067
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1036
+ getSuffix(code, count, options = {}) {
1068
1037
  const rule = this.getRule(code, options);
1069
1038
  if (rule) {
1070
1039
  return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
@@ -1074,9 +1043,7 @@ class PluralResolver {
1074
1043
  }
1075
1044
  }
1076
1045
 
1077
- const deepFindWithDefaults = function (data, defaultData, key) {
1078
- let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
1079
- let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1046
+ const deepFindWithDefaults = (data, defaultData, key, keySeparator = '.', ignoreJSONStructure = true) => {
1080
1047
  let path = getPathWithDefaults(data, defaultData, key);
1081
1048
  if (!path && ignoreJSONStructure && isString(key)) {
1082
1049
  path = deepFind(data, key, keySeparator);
@@ -1086,15 +1053,13 @@ const deepFindWithDefaults = function (data, defaultData, key) {
1086
1053
  };
1087
1054
  const regexSafe = val => val.replace(/\$/g, '$$$$');
1088
1055
  class Interpolator {
1089
- constructor() {
1090
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1056
+ constructor(options = {}) {
1091
1057
  this.logger = baseLogger.create('interpolator');
1092
1058
  this.options = options;
1093
1059
  this.format = options?.interpolation?.format || (value => value);
1094
1060
  this.init(options);
1095
1061
  }
1096
- init() {
1097
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1062
+ init(options = {}) {
1098
1063
  if (!options.interpolation) options.interpolation = {
1099
1064
  escapeValue: true
1100
1065
  };
@@ -1217,8 +1182,7 @@ class Interpolator {
1217
1182
  });
1218
1183
  return str;
1219
1184
  }
1220
- nest(str, fc) {
1221
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1185
+ nest(str, fc, options = {}) {
1222
1186
  let match;
1223
1187
  let value;
1224
1188
  let clonedOptions;
@@ -1255,12 +1219,10 @@ class Interpolator {
1255
1219
  clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
1256
1220
  clonedOptions.applyPostProcessor = false;
1257
1221
  delete clonedOptions.defaultValue;
1258
- let doReduce = false;
1259
- if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
1260
- const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
1261
- match[1] = r.shift();
1262
- formatters = r;
1263
- doReduce = true;
1222
+ const keyEndIndex = /{.*}/.test(match[1]) ? match[1].lastIndexOf('}') + 1 : match[1].indexOf(this.formatSeparator);
1223
+ if (keyEndIndex !== -1) {
1224
+ formatters = match[1].slice(keyEndIndex).split(this.formatSeparator).map(elem => elem.trim()).filter(Boolean);
1225
+ match[1] = match[1].slice(0, keyEndIndex);
1264
1226
  }
1265
1227
  value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
1266
1228
  if (value && match[0] === str && !isString(value)) return value;
@@ -1269,7 +1231,7 @@ class Interpolator {
1269
1231
  this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
1270
1232
  value = '';
1271
1233
  }
1272
- if (doReduce) {
1234
+ if (formatters.length) {
1273
1235
  value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
1274
1236
  ...options,
1275
1237
  interpolationkey: match[1].trim()
@@ -1315,68 +1277,68 @@ const parseFormatStr = formatStr => {
1315
1277
  };
1316
1278
  const createCachedFormatter = fn => {
1317
1279
  const cache = {};
1318
- return (val, lng, options) => {
1319
- let optForCache = options;
1320
- if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
1280
+ return (v, l, o) => {
1281
+ let optForCache = o;
1282
+ if (o && o.interpolationkey && o.formatParams && o.formatParams[o.interpolationkey] && o[o.interpolationkey]) {
1321
1283
  optForCache = {
1322
1284
  ...optForCache,
1323
- [options.interpolationkey]: undefined
1285
+ [o.interpolationkey]: undefined
1324
1286
  };
1325
1287
  }
1326
- const key = lng + JSON.stringify(optForCache);
1327
- let formatter = cache[key];
1328
- if (!formatter) {
1329
- formatter = fn(getCleanedCode(lng), options);
1330
- cache[key] = formatter;
1288
+ const key = l + JSON.stringify(optForCache);
1289
+ let frm = cache[key];
1290
+ if (!frm) {
1291
+ frm = fn(getCleanedCode(l), o);
1292
+ cache[key] = frm;
1331
1293
  }
1332
- return formatter(val);
1294
+ return frm(v);
1333
1295
  };
1334
1296
  };
1297
+ const createNonCachedFormatter = fn => (v, l, o) => fn(getCleanedCode(l), o)(v);
1335
1298
  class Formatter {
1336
- constructor() {
1337
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1299
+ constructor(options = {}) {
1338
1300
  this.logger = baseLogger.create('formatter');
1339
1301
  this.options = options;
1302
+ this.init(options);
1303
+ }
1304
+ init(services, options = {
1305
+ interpolation: {}
1306
+ }) {
1307
+ this.formatSeparator = options.interpolation.formatSeparator || ',';
1308
+ const cf = options.cacheInBuiltFormats ? createCachedFormatter : createNonCachedFormatter;
1340
1309
  this.formats = {
1341
- number: createCachedFormatter((lng, opt) => {
1310
+ number: cf((lng, opt) => {
1342
1311
  const formatter = new Intl.NumberFormat(lng, {
1343
1312
  ...opt
1344
1313
  });
1345
1314
  return val => formatter.format(val);
1346
1315
  }),
1347
- currency: createCachedFormatter((lng, opt) => {
1316
+ currency: cf((lng, opt) => {
1348
1317
  const formatter = new Intl.NumberFormat(lng, {
1349
1318
  ...opt,
1350
1319
  style: 'currency'
1351
1320
  });
1352
1321
  return val => formatter.format(val);
1353
1322
  }),
1354
- datetime: createCachedFormatter((lng, opt) => {
1323
+ datetime: cf((lng, opt) => {
1355
1324
  const formatter = new Intl.DateTimeFormat(lng, {
1356
1325
  ...opt
1357
1326
  });
1358
1327
  return val => formatter.format(val);
1359
1328
  }),
1360
- relativetime: createCachedFormatter((lng, opt) => {
1329
+ relativetime: cf((lng, opt) => {
1361
1330
  const formatter = new Intl.RelativeTimeFormat(lng, {
1362
1331
  ...opt
1363
1332
  });
1364
1333
  return val => formatter.format(val, opt.range || 'day');
1365
1334
  }),
1366
- list: createCachedFormatter((lng, opt) => {
1335
+ list: cf((lng, opt) => {
1367
1336
  const formatter = new Intl.ListFormat(lng, {
1368
1337
  ...opt
1369
1338
  });
1370
1339
  return val => formatter.format(val);
1371
1340
  })
1372
1341
  };
1373
- this.init(options);
1374
- }
1375
- init(services) {
1376
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
1377
- interpolation: {}
1378
- };
1379
- this.formatSeparator = options.interpolation.formatSeparator || ',';
1380
1342
  }
1381
1343
  add(name, fc) {
1382
1344
  this.formats[name.toLowerCase().trim()] = fc;
@@ -1384,8 +1346,7 @@ class Formatter {
1384
1346
  addCached(name, fc) {
1385
1347
  this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
1386
1348
  }
1387
- format(value, format, lng) {
1388
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1349
+ format(value, format, lng, options = {}) {
1389
1350
  const formats = format.split(this.formatSeparator);
1390
1351
  if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
1391
1352
  const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
@@ -1426,8 +1387,7 @@ const removePending = (q, name) => {
1426
1387
  }
1427
1388
  };
1428
1389
  class Connector extends EventEmitter {
1429
- constructor(backend, store, services) {
1430
- let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
1390
+ constructor(backend, store, services, options = {}) {
1431
1391
  super();
1432
1392
  this.backend = backend;
1433
1393
  this.store = store;
@@ -1521,10 +1481,7 @@ class Connector extends EventEmitter {
1521
1481
  this.emit('loaded', loaded);
1522
1482
  this.queue = this.queue.filter(q => !q.done);
1523
1483
  }
1524
- read(lng, ns, fcName) {
1525
- let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1526
- let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
1527
- let callback = arguments.length > 5 ? arguments[5] : undefined;
1484
+ read(lng, ns, fcName, tried = 0, wait = this.retryTimeout, callback) {
1528
1485
  if (!lng.length) return callback(null, {});
1529
1486
  if (this.readingCalls >= this.maxParallelReads) {
1530
1487
  this.waitingReads.push({
@@ -1568,9 +1525,7 @@ class Connector extends EventEmitter {
1568
1525
  }
1569
1526
  return fc(lng, ns, resolver);
1570
1527
  }
1571
- prepareLoading(languages, namespaces) {
1572
- let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1573
- let callback = arguments.length > 3 ? arguments[3] : undefined;
1528
+ prepareLoading(languages, namespaces, options = {}, callback) {
1574
1529
  if (!this.backend) {
1575
1530
  this.logger.warn('No backend was added via i18next.use. Will not load resources.');
1576
1531
  return callback && callback();
@@ -1594,8 +1549,7 @@ class Connector extends EventEmitter {
1594
1549
  reload: true
1595
1550
  }, callback);
1596
1551
  }
1597
- loadOne(name) {
1598
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
1552
+ loadOne(name, prefix = '') {
1599
1553
  const s = name.split('|');
1600
1554
  const lng = s[0];
1601
1555
  const ns = s[1];
@@ -1605,9 +1559,7 @@ class Connector extends EventEmitter {
1605
1559
  this.loaded(name, err, data);
1606
1560
  });
1607
1561
  }
1608
- saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
1609
- let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
1610
- let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
1562
+ saveMissing(languages, namespace, key, fallbackValue, isUpdate, options = {}, clb = () => {}) {
1611
1563
  if (this.services?.utils?.hasLoadedNamespace && !this.services?.utils?.hasLoadedNamespace(namespace)) {
1612
1564
  this.logger.warn(`did not save key "${key}" as the namespace "${namespace}" was not yet loaded`, 'This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!');
1613
1565
  return;
@@ -1702,7 +1654,8 @@ const get = () => ({
1702
1654
  nestingOptionsSeparator: ',',
1703
1655
  maxReplaces: 1000,
1704
1656
  skipOnVariables: true
1705
- }
1657
+ },
1658
+ cacheInBuiltFormats: true
1706
1659
  });
1707
1660
  const transformOptions = options => {
1708
1661
  if (isString(options.ns)) options.ns = [options.ns];
@@ -1725,9 +1678,7 @@ const bindMemberFunctions = inst => {
1725
1678
  });
1726
1679
  };
1727
1680
  class I18n extends EventEmitter {
1728
- constructor() {
1729
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1730
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1681
+ constructor(options = {}, callback) {
1731
1682
  super();
1732
1683
  this.options = transformOptions(options);
1733
1684
  this.services = {};
@@ -1746,10 +1697,7 @@ class I18n extends EventEmitter {
1746
1697
  }, 0);
1747
1698
  }
1748
1699
  }
1749
- init() {
1750
- var _this = this;
1751
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1752
- let callback = arguments.length > 1 ? arguments[1] : undefined;
1700
+ init(options = {}, callback) {
1753
1701
  this.isInitializing = true;
1754
1702
  if (typeof options === 'function') {
1755
1703
  callback = options;
@@ -1805,9 +1753,13 @@ class I18n extends EventEmitter {
1805
1753
  prepend: this.options.pluralSeparator,
1806
1754
  simplifyPluralSuffix: this.options.simplifyPluralSuffix
1807
1755
  });
1756
+ const usingLegacyFormatFunction = this.options.interpolation.format && this.options.interpolation.format !== defOpts.interpolation.format;
1757
+ if (usingLegacyFormatFunction) {
1758
+ this.logger.warn(`init: you are still using the legacy format function, please use the new approach: https://www.i18next.com/translation-function/formatting`);
1759
+ }
1808
1760
  if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
1809
1761
  s.formatter = createClassOnDemand(formatter);
1810
- s.formatter.init(s, this.options);
1762
+ if (s.formatter.init) s.formatter.init(s, this.options);
1811
1763
  this.options.interpolation.format = s.formatter.format.bind(s.formatter);
1812
1764
  }
1813
1765
  s.interpolator = new Interpolator(this.options);
@@ -1815,11 +1767,8 @@ class I18n extends EventEmitter {
1815
1767
  hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
1816
1768
  };
1817
1769
  s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
1818
- s.backendConnector.on('*', function (event) {
1819
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1820
- args[_key - 1] = arguments[_key];
1821
- }
1822
- _this.emit(event, ...args);
1770
+ s.backendConnector.on('*', (event, ...args) => {
1771
+ this.emit(event, ...args);
1823
1772
  });
1824
1773
  if (this.modules.languageDetector) {
1825
1774
  s.languageDetector = createClassOnDemand(this.modules.languageDetector);
@@ -1830,11 +1779,8 @@ class I18n extends EventEmitter {
1830
1779
  if (s.i18nFormat.init) s.i18nFormat.init(this);
1831
1780
  }
1832
1781
  this.translator = new Translator(this.services, this.options);
1833
- this.translator.on('*', function (event) {
1834
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1835
- args[_key2 - 1] = arguments[_key2];
1836
- }
1837
- _this.emit(event, ...args);
1782
+ this.translator.on('*', (event, ...args) => {
1783
+ this.emit(event, ...args);
1838
1784
  });
1839
1785
  this.modules.external.forEach(m => {
1840
1786
  if (m.init) m.init(this);
@@ -1851,15 +1797,13 @@ class I18n extends EventEmitter {
1851
1797
  }
1852
1798
  const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
1853
1799
  storeApi.forEach(fcName => {
1854
- this[fcName] = function () {
1855
- return _this.store[fcName](...arguments);
1856
- };
1800
+ this[fcName] = (...args) => this.store[fcName](...args);
1857
1801
  });
1858
1802
  const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
1859
1803
  storeApiChained.forEach(fcName => {
1860
- this[fcName] = function () {
1861
- _this.store[fcName](...arguments);
1862
- return _this;
1804
+ this[fcName] = (...args) => {
1805
+ this.store[fcName](...args);
1806
+ return this;
1863
1807
  };
1864
1808
  });
1865
1809
  const deferred = defer();
@@ -1883,8 +1827,7 @@ class I18n extends EventEmitter {
1883
1827
  }
1884
1828
  return deferred;
1885
1829
  }
1886
- loadResources(language) {
1887
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
1830
+ loadResources(language, callback = noop) {
1888
1831
  let usedCallback = callback;
1889
1832
  const usedLng = isString(language) ? language : this.language;
1890
1833
  if (typeof language === 'function') usedCallback = language;
@@ -1971,9 +1914,12 @@ class I18n extends EventEmitter {
1971
1914
  break;
1972
1915
  }
1973
1916
  }
1917
+ if (!this.resolvedLanguage && this.languages.indexOf(l) < 0 && this.store.hasLanguageSomeTranslations(l)) {
1918
+ this.resolvedLanguage = l;
1919
+ this.languages.unshift(l);
1920
+ }
1974
1921
  }
1975
1922
  changeLanguage(lng, callback) {
1976
- var _this2 = this;
1977
1923
  this.isLanguageChangingTo = lng;
1978
1924
  const deferred = defer();
1979
1925
  this.emit('languageChanging', lng);
@@ -1985,24 +1931,23 @@ class I18n extends EventEmitter {
1985
1931
  };
1986
1932
  const done = (err, l) => {
1987
1933
  if (l) {
1988
- setLngProps(l);
1989
- this.translator.changeLanguage(l);
1990
- this.isLanguageChangingTo = undefined;
1991
- this.emit('languageChanged', l);
1992
- this.logger.log('languageChanged', l);
1934
+ if (this.isLanguageChangingTo === lng) {
1935
+ setLngProps(l);
1936
+ this.translator.changeLanguage(l);
1937
+ this.isLanguageChangingTo = undefined;
1938
+ this.emit('languageChanged', l);
1939
+ this.logger.log('languageChanged', l);
1940
+ }
1993
1941
  } else {
1994
1942
  this.isLanguageChangingTo = undefined;
1995
1943
  }
1996
- deferred.resolve(function () {
1997
- return _this2.t(...arguments);
1998
- });
1999
- if (callback) callback(err, function () {
2000
- return _this2.t(...arguments);
2001
- });
1944
+ deferred.resolve((...args) => this.t(...args));
1945
+ if (callback) callback(err, (...args) => this.t(...args));
2002
1946
  };
2003
1947
  const setLng = lngs => {
2004
1948
  if (!lng && !lngs && this.services.languageDetector) lngs = [];
2005
- const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
1949
+ const fl = isString(lngs) ? lngs : lngs && lngs[0];
1950
+ const l = this.store.hasLanguageSomeTranslations(fl) ? fl : this.services.languageUtils.getBestMatchFromCodes(isString(lngs) ? [lngs] : lngs);
2006
1951
  if (l) {
2007
1952
  if (!this.language) {
2008
1953
  setLngProps(l);
@@ -2028,31 +1973,27 @@ class I18n extends EventEmitter {
2028
1973
  return deferred;
2029
1974
  }
2030
1975
  getFixedT(lng, ns, keyPrefix) {
2031
- var _this3 = this;
2032
- const fixedT = function (key, opts) {
2033
- let options;
1976
+ const fixedT = (key, opts, ...rest) => {
1977
+ let o;
2034
1978
  if (typeof opts !== 'object') {
2035
- for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
2036
- rest[_key3 - 2] = arguments[_key3];
2037
- }
2038
- options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
1979
+ o = this.options.overloadTranslationOptionHandler([key, opts].concat(rest));
2039
1980
  } else {
2040
- options = {
1981
+ o = {
2041
1982
  ...opts
2042
1983
  };
2043
1984
  }
2044
- options.lng = options.lng || fixedT.lng;
2045
- options.lngs = options.lngs || fixedT.lngs;
2046
- options.ns = options.ns || fixedT.ns;
2047
- if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
2048
- const keySeparator = _this3.options.keySeparator || '.';
1985
+ o.lng = o.lng || fixedT.lng;
1986
+ o.lngs = o.lngs || fixedT.lngs;
1987
+ o.ns = o.ns || fixedT.ns;
1988
+ if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
1989
+ const keySeparator = this.options.keySeparator || '.';
2049
1990
  let resultKey;
2050
- if (options.keyPrefix && Array.isArray(key)) {
2051
- resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
1991
+ if (o.keyPrefix && Array.isArray(key)) {
1992
+ resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
2052
1993
  } else {
2053
- resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
1994
+ resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
2054
1995
  }
2055
- return _this3.t(resultKey, options);
1996
+ return this.t(resultKey, o);
2056
1997
  };
2057
1998
  if (isString(lng)) {
2058
1999
  fixedT.lng = lng;
@@ -2063,23 +2004,16 @@ class I18n extends EventEmitter {
2063
2004
  fixedT.keyPrefix = keyPrefix;
2064
2005
  return fixedT;
2065
2006
  }
2066
- t() {
2067
- for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
2068
- args[_key4] = arguments[_key4];
2069
- }
2007
+ t(...args) {
2070
2008
  return this.translator?.translate(...args);
2071
2009
  }
2072
- exists() {
2073
- for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
2074
- args[_key5] = arguments[_key5];
2075
- }
2010
+ exists(...args) {
2076
2011
  return this.translator?.exists(...args);
2077
2012
  }
2078
2013
  setDefaultNamespace(ns) {
2079
2014
  this.options.defaultNS = ns;
2080
2015
  }
2081
- hasLoadedNamespace(ns) {
2082
- let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2016
+ hasLoadedNamespace(ns, options = {}) {
2083
2017
  if (!this.isInitialized) {
2084
2018
  this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
2085
2019
  return false;
@@ -2140,18 +2074,22 @@ class I18n extends EventEmitter {
2140
2074
  dir(lng) {
2141
2075
  if (!lng) lng = this.resolvedLanguage || (this.languages?.length > 0 ? this.languages[0] : this.language);
2142
2076
  if (!lng) return 'rtl';
2077
+ try {
2078
+ const l = new Intl.Locale(lng);
2079
+ if (l && l.getTextInfo) {
2080
+ const ti = l.getTextInfo();
2081
+ if (ti && ti.direction) return ti.direction;
2082
+ }
2083
+ } catch (e) {}
2143
2084
  const rtlLngs = ['ar', 'shu', 'sqr', 'ssh', 'xaa', 'yhd', 'yud', 'aao', 'abh', 'abv', 'acm', 'acq', 'acw', 'acx', 'acy', 'adf', 'ads', 'aeb', 'aec', 'afb', 'ajp', 'apc', 'apd', 'arb', 'arq', 'ars', 'ary', 'arz', 'auz', 'avl', 'ayh', 'ayl', 'ayn', 'ayp', 'bbz', 'pga', 'he', 'iw', 'ps', 'pbt', 'pbu', 'pst', 'prp', 'prd', 'ug', 'ur', 'ydd', 'yds', 'yih', 'ji', 'yi', 'hbo', 'men', 'xmn', 'fa', 'jpr', 'peo', 'pes', 'prs', 'dv', 'sam', 'ckb'];
2144
2085
  const languageUtils = this.services?.languageUtils || new LanguageUtil(get());
2086
+ if (lng.toLowerCase().indexOf('-latn') > 1) return 'ltr';
2145
2087
  return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
2146
2088
  }
2147
- static createInstance() {
2148
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2149
- let callback = arguments.length > 1 ? arguments[1] : undefined;
2089
+ static createInstance(options = {}, callback) {
2150
2090
  return new I18n(options, callback);
2151
2091
  }
2152
- cloneInstance() {
2153
- let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2154
- let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
2092
+ cloneInstance(options = {}, callback = noop) {
2155
2093
  const forkResourceStore = options.forkResourceStore;
2156
2094
  if (forkResourceStore) delete options.forkResourceStore;
2157
2095
  const mergedOptions = {
@@ -2180,21 +2118,19 @@ class I18n extends EventEmitter {
2180
2118
  prev[l] = {
2181
2119
  ...this.store.data[l]
2182
2120
  };
2183
- return Object.keys(prev[l]).reduce((acc, n) => {
2121
+ prev[l] = Object.keys(prev[l]).reduce((acc, n) => {
2184
2122
  acc[n] = {
2185
2123
  ...prev[l][n]
2186
2124
  };
2187
2125
  return acc;
2188
- }, {});
2126
+ }, prev[l]);
2127
+ return prev;
2189
2128
  }, {});
2190
2129
  clone.store = new ResourceStore(clonedData, mergedOptions);
2191
2130
  clone.services.resourceStore = clone.store;
2192
2131
  }
2193
2132
  clone.translator = new Translator(clone.services, mergedOptions);
2194
- clone.translator.on('*', function (event) {
2195
- for (var _len6 = arguments.length, args = new Array(_len6 > 1 ? _len6 - 1 : 0), _key6 = 1; _key6 < _len6; _key6++) {
2196
- args[_key6 - 1] = arguments[_key6];
2197
- }
2133
+ clone.translator.on('*', (event, ...args) => {
2198
2134
  clone.emit(event, ...args);
2199
2135
  });
2200
2136
  clone.init(mergedOptions, callback);
@@ -2222,7 +2158,7 @@ function getWindow() {
2222
2158
  }
2223
2159
  function getAtomicEnvironment() {
2224
2160
  return {
2225
- version: "3.31.2-pre.cd43f025b9",
2161
+ version: "3.31.2-pre.da74c43571",
2226
2162
  headlessVersion: headless.VERSION,
2227
2163
  };
2228
2164
  }
@@ -2985,4 +2921,4 @@ exports.getNextAnalyticsConfig = getNextAnalyticsConfig;
2985
2921
  exports.instance = instance;
2986
2922
  exports.mismatchedInterfaceAndEnginePropError = mismatchedInterfaceAndEnginePropError;
2987
2923
 
2988
- //# sourceMappingURL=analytics-config-0a4776c9.js.map
2924
+ //# sourceMappingURL=analytics-config-e18c57f7.js.map