@coveo/atomic 3.31.2-pre.d1ef280b84 → 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.
- package/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/atomic.esm.js.map +1 -1
- package/dist/atomic/components/_index.d.ts +0 -4
- package/dist/atomic/components/_index.js +0 -2
- package/dist/atomic/components/analytics-config.js +235 -299
- package/dist/atomic/components/analytics-config.js.map +1 -1
- package/dist/atomic/components/atomic-category-facet.js +1 -1
- package/dist/atomic/components/atomic-facet.js +1 -1
- package/dist/atomic/components/atomic-format-currency.js +1 -1
- package/dist/atomic/components/atomic-format-number.js +1 -1
- package/dist/atomic/components/atomic-format-unit.js +1 -1
- package/dist/atomic/components/atomic-numeric-facet.js +1 -1
- package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
- package/dist/atomic/components/atomic-quickview.js +1 -1
- package/dist/atomic/components/atomic-result-children.js +1 -1
- package/dist/atomic/components/atomic-result-fields-list.js +1 -1
- package/dist/atomic/components/atomic-result-link.js +1 -1
- package/dist/atomic/components/atomic-result-list.js +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +1 -1
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +1 -1
- package/dist/atomic/components/atomic-search-interface.js +1 -7
- package/dist/atomic/components/atomic-search-interface.js.map +1 -1
- package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
- package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
- package/dist/atomic/components/atomic-sort-expression.js +1 -1
- package/dist/atomic/components/atomic-tab-manager.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/analytics-config.js +2 -0
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +21 -27
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-layout/atomic-commerce-layout.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-load-more-products/atomic-commerce-load-more-products.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-product-list/atomic-commerce-product-list.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +22 -36
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-list/atomic-commerce-recommendation-list.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-refine-modal/atomic-commerce-refine-modal.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-refine-toggle/atomic-commerce-refine-toggle.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +3 -0
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-sort-dropdown/atomic-commerce-sort-dropdown.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product/atomic-product.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-children/atomic-product-children.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-description/atomic-product-description.js +149 -0
- package/dist/atomic/components/components/commerce/atomic-product-description/atomic-product-description.tw.css.js +3 -0
- package/dist/atomic/components/components/commerce/atomic-product-excerpt/atomic-product-excerpt.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-link/atomic-product-link.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-multi-value-text/atomic-product-multi-value-text.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-price/atomic-product-price.tw.css.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product-template/atomic-product-template.js +1 -0
- package/dist/atomic/components/components/commerce/index.js +1 -0
- package/dist/atomic/components/components/commerce/lazy-index.js +1 -0
- package/dist/atomic/components/components/common/atomic-aria-live/atomic-aria-live.js +102 -0
- package/dist/atomic/components/components/common/atomic-icon/atomic-icon.tw.css.js +1 -1
- package/dist/atomic/components/components/common/facets/facet-common.tw.css.js +1 -1
- package/dist/atomic/components/components/common/facets/facet-search/facet-search.tw.css.js +1 -1
- package/dist/atomic/components/components/common/facets/facet-value-box/facet-value-box.tw.css.js +1 -1
- package/dist/atomic/components/components/common/facets/facet-value-checkbox/facet-value-checkbox.tw.css.js +1 -1
- package/dist/atomic/components/components/common/facets/facet-value-exclude/facet-value-exclude.tw.css.js +1 -1
- package/dist/atomic/components/components/common/index.js +1 -0
- package/dist/atomic/components/components/common/interface/analytics-config.js +38 -0
- package/dist/atomic/components/components/common/interface/interface-controller.js +89 -0
- package/dist/atomic/components/components/common/lazy-index.js +1 -0
- package/dist/atomic/components/components/common/refine-modal/refine-modal-common.tw.css.js +1 -1
- package/dist/atomic/components/debounce-utils.js +1 -34
- package/dist/atomic/components/debounce-utils.js.map +1 -1
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/global/tailwind.default.css.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/components/stencil-accessibility-utils.js.map +1 -1
- package/dist/atomic/components/stencil-facet-show-more-less.js +7 -1
- package/dist/atomic/components/stencil-facet-show-more-less.js.map +1 -1
- package/dist/atomic/components/themes/accessible.css.js +1 -1
- package/dist/atomic/components/themes/coveo.css.js +1 -1
- package/dist/atomic/components/utils/coveo.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/aspect-square.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/components.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/hide-scrollbar.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/link-style.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/set-font-size.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind-utilities/utilities.tw.css.js +1 -1
- package/dist/atomic/components/utils/tailwind.global.tw.css.js +1 -1
- package/dist/atomic/p-01c91b69.js +2 -0
- package/dist/atomic/p-01c91b69.js.map +1 -0
- package/dist/atomic/{p-1b491649.entry.js → p-0af927f0.entry.js} +2 -2
- package/dist/atomic/{p-b043958c.entry.js → p-0b9cd281.entry.js} +2 -2
- package/dist/atomic/{p-e44ba87e.entry.js → p-0f5ae66e.entry.js} +2 -2
- package/dist/atomic/{p-0674783d.entry.js → p-1b329f85.entry.js} +2 -2
- package/dist/atomic/p-271cf67e.entry.js +2 -0
- package/dist/atomic/p-271cf67e.entry.js.map +1 -0
- package/dist/atomic/p-306161d1.entry.js +2 -0
- package/dist/atomic/p-417b1b64.js +2 -0
- package/dist/atomic/{p-c100197d.js.map → p-417b1b64.js.map} +1 -1
- package/dist/atomic/p-44a3c052.entry.js +2 -0
- package/dist/atomic/{p-e215ba76.entry.js.map → p-44a3c052.entry.js.map} +1 -1
- package/dist/atomic/{p-a0445771.entry.js → p-4c5702ba.entry.js} +2 -2
- package/dist/atomic/{p-acc4d5de.js → p-53bcc515.js} +2 -2
- package/dist/atomic/{p-e2560da8.entry.js → p-5f64bbe0.entry.js} +2 -2
- package/dist/atomic/{p-fc73190d.entry.js → p-6638ca39.entry.js} +2 -2
- package/dist/atomic/{p-0c35973c.entry.js → p-6c412aa0.entry.js} +2 -2
- package/dist/atomic/{p-1176959c.entry.js → p-6f8ae3d2.entry.js} +2 -2
- package/dist/atomic/{p-0ed0e8b8.entry.js → p-731f82ed.entry.js} +2 -2
- package/dist/atomic/{p-25f8b8d8.entry.js → p-7a07530d.entry.js} +2 -2
- package/dist/atomic/{p-c8d47706.entry.js → p-7a5d346b.entry.js} +2 -2
- package/dist/atomic/{p-09af5eb5.entry.js → p-7db6d666.entry.js} +2 -2
- package/dist/atomic/p-8434625a.entry.js +2 -0
- package/dist/atomic/{p-8bb323e8.entry.js.map → p-8434625a.entry.js.map} +1 -1
- package/dist/atomic/{p-5b888121.entry.js → p-89721f11.entry.js} +2 -2
- package/dist/atomic/p-91477908.entry.js +2 -0
- package/dist/atomic/{p-3f881919.entry.js.map → p-91477908.entry.js.map} +1 -1
- package/dist/atomic/p-91d52cad.entry.js +2 -0
- package/dist/atomic/{p-4e77fe24.entry.js.map → p-91d52cad.entry.js.map} +1 -1
- package/dist/atomic/p-96a6f84f.js.map +1 -1
- package/dist/atomic/{p-11dd759c.entry.js → p-b1f7ac63.entry.js} +2 -2
- package/dist/atomic/{p-5fc9f751.entry.js → p-bf5d5c79.entry.js} +2 -2
- package/dist/atomic/{p-716e9e1d.entry.js → p-c0025d4c.entry.js} +2 -2
- package/dist/atomic/p-d99e359b.js +2 -0
- package/dist/atomic/p-d99e359b.js.map +1 -0
- package/dist/atomic/{p-494c57a0.entry.js → p-e406cacd.entry.js} +2 -2
- package/dist/atomic/p-e8ba8acd.entry.js +2 -0
- package/dist/atomic/{p-0873c1b8.entry.js.map → p-e8ba8acd.entry.js.map} +1 -1
- package/dist/atomic/{p-f7e6b154.entry.js → p-ef45ff5c.entry.js} +2 -2
- package/dist/atomic/p-f0e861c5.entry.js +2 -0
- package/dist/atomic/{p-391c26ba.entry.js → p-f9bfd18b.entry.js} +2 -2
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/{analytics-config-2b794369.js → analytics-config-e18c57f7.js} +236 -300
- package/dist/cjs/analytics-config-e18c57f7.js.map +1 -0
- package/dist/cjs/atomic-category-facet.cjs.entry.js +2 -3
- package/dist/cjs/atomic-category-facet.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-color-facet.cjs.entry.js +1 -2
- package/dist/cjs/atomic-color-facet.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-commerce-category-facet_4.cjs.entry.js +1 -2
- package/dist/cjs/atomic-commerce-category-facet_4.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-facet.cjs.entry.js +2 -3
- package/dist/cjs/atomic-facet.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
- package/dist/cjs/atomic-generated-answer.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-facet.cjs.entry.js +1 -2
- package/dist/cjs/atomic-insight-facet.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-generated-answer.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js +2 -2
- package/dist/cjs/atomic-numeric-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/{atomic-aria-live_2.cjs.entry.js → atomic-relevance-inspector.cjs.entry.js} +1 -68
- package/dist/cjs/atomic-relevance-inspector.cjs.entry.js.map +1 -0
- package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +2 -2
- package/dist/cjs/atomic-search-box.cjs.entry.js +2 -2
- package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
- package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
- package/dist/cjs/atomic.cjs.js +1 -1
- package/dist/cjs/debounce-utils-d26bcad4.js +15 -0
- package/dist/cjs/debounce-utils-d26bcad4.js.map +1 -0
- package/dist/cjs/index-757bc886.js +4 -8
- package/dist/cjs/stencil-accessibility-utils-aa4c9f6c.js.map +1 -1
- package/dist/cjs/{stencil-facet-show-more-less-21d22973.js → stencil-facet-show-more-less-541e1544.js} +10 -4
- package/dist/cjs/stencil-facet-show-more-less-541e1544.js.map +1 -0
- package/dist/cjs/{stencil-suggestion-manager-6f778cf0.js → stencil-suggestion-manager-5fa3ac70.js} +2 -2
- package/dist/cjs/{stencil-suggestion-manager-6f778cf0.js.map → stencil-suggestion-manager-5fa3ac70.js.map} +1 -1
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_loader.js +1 -1
- package/dist/esm/{analytics-config-482346f6.js → analytics-config-b8b6bdbb.js} +236 -300
- package/dist/esm/analytics-config-b8b6bdbb.js.map +1 -0
- package/dist/esm/atomic-category-facet.entry.js +2 -3
- package/dist/esm/atomic-category-facet.entry.js.map +1 -1
- package/dist/esm/atomic-color-facet.entry.js +1 -2
- package/dist/esm/atomic-color-facet.entry.js.map +1 -1
- package/dist/esm/atomic-commerce-category-facet_4.entry.js +1 -2
- package/dist/esm/atomic-commerce-category-facet_4.entry.js.map +1 -1
- package/dist/esm/atomic-facet.entry.js +2 -3
- package/dist/esm/atomic-facet.entry.js.map +1 -1
- package/dist/esm/atomic-format-currency.entry.js +1 -1
- package/dist/esm/atomic-format-number.entry.js +1 -1
- package/dist/esm/atomic-format-unit.entry.js +1 -1
- package/dist/esm/atomic-generated-answer.entry.js +1 -1
- package/dist/esm/atomic-insight-facet.entry.js +1 -2
- package/dist/esm/atomic-insight-facet.entry.js.map +1 -1
- package/dist/esm/atomic-insight-generated-answer.entry.js +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-insight-search-box.entry.js +2 -2
- package/dist/esm/atomic-numeric-facet.entry.js +1 -1
- package/dist/esm/atomic-quickview-modal.entry.js +1 -1
- package/dist/esm/atomic-quickview.entry.js +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/{atomic-aria-live_2.entry.js → atomic-relevance-inspector.entry.js} +3 -69
- package/dist/esm/atomic-relevance-inspector.entry.js.map +1 -0
- package/dist/esm/atomic-result-children.entry.js +1 -1
- package/dist/esm/atomic-result-fields-list.entry.js +1 -1
- package/dist/esm/atomic-result-link.entry.js +1 -1
- package/dist/esm/atomic-result-list.entry.js +1 -1
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +2 -2
- package/dist/esm/atomic-search-box.entry.js +2 -2
- package/dist/esm/atomic-search-interface.entry.js +1 -1
- package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
- package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
- package/dist/esm/atomic-sort-expression.entry.js +1 -1
- package/dist/esm/atomic-tab-manager.entry.js +1 -1
- package/dist/esm/atomic.js +1 -1
- package/dist/esm/debounce-utils-8619dece.js +13 -0
- package/dist/esm/{debounce-utils-efa015c0.js.map → debounce-utils-8619dece.js.map} +1 -1
- package/dist/esm/index-3f35faca.js +4 -8
- package/dist/esm/stencil-accessibility-utils-bc273be5.js.map +1 -1
- package/dist/esm/{stencil-facet-show-more-less-4b023ee3.js → stencil-facet-show-more-less-1198472f.js} +8 -2
- package/dist/esm/stencil-facet-show-more-less-1198472f.js.map +1 -0
- package/dist/esm/{stencil-suggestion-manager-91706623.js → stencil-suggestion-manager-f52c6e39.js} +2 -2
- package/dist/esm/{stencil-suggestion-manager-91706623.js.map → stencil-suggestion-manager-f52c6e39.js.map} +1 -1
- package/dist/esm/version.js +2 -2
- package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +3 -4
- package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +5 -6
- package/dist/types/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.d.ts +3 -0
- package/dist/types/components/commerce/atomic-product-description/atomic-product-description.d.ts +21 -10
- package/dist/types/components/commerce/atomic-product-template/atomic-product-template.d.ts +1 -0
- package/dist/types/components/commerce/index.d.ts +1 -0
- package/dist/types/components/common/atomic-aria-live/atomic-aria-live.d.ts +38 -0
- package/dist/types/components/common/index.d.ts +1 -0
- package/dist/types/components/common/interface/i18n.d.ts +1 -1
- package/dist/types/components/common/interface/{interface-common.d.ts → interface-controller.d.ts} +14 -11
- package/dist/types/components.d.ts +0 -78
- package/dist/types/utils/accessibility-utils.d.ts +2 -1
- package/dist/types/utils/stencil-accessibility-utils.d.ts +2 -1
- package/docs/atomic-docs.json +33 -194
- package/package.json +6 -6
- package/dist/atomic/components/atomic-aria-live.d.ts +0 -11
- package/dist/atomic/components/atomic-aria-live.js +0 -8
- package/dist/atomic/components/atomic-aria-live.js.map +0 -1
- package/dist/atomic/components/atomic-aria-live2.js +0 -87
- package/dist/atomic/components/atomic-aria-live2.js.map +0 -1
- package/dist/atomic/components/atomic-product-description.d.ts +0 -11
- package/dist/atomic/components/atomic-product-description.js +0 -153
- package/dist/atomic/components/atomic-product-description.js.map +0 -1
- package/dist/atomic/components/components/common/interface/interface-common.js +0 -95
- package/dist/atomic/components/plus.js +0 -10
- package/dist/atomic/components/plus.js.map +0 -1
- package/dist/atomic/p-0873c1b8.entry.js +0 -2
- package/dist/atomic/p-37b7705c.js +0 -2
- package/dist/atomic/p-37b7705c.js.map +0 -1
- package/dist/atomic/p-3f2442d3.entry.js +0 -2
- package/dist/atomic/p-3f2442d3.entry.js.map +0 -1
- package/dist/atomic/p-3f881919.entry.js +0 -2
- package/dist/atomic/p-4e77fe24.entry.js +0 -2
- package/dist/atomic/p-605a2e24.js +0 -2
- package/dist/atomic/p-605a2e24.js.map +0 -1
- package/dist/atomic/p-8bb323e8.entry.js +0 -2
- package/dist/atomic/p-8f20d930.js +0 -2
- package/dist/atomic/p-8f20d930.js.map +0 -1
- package/dist/atomic/p-c100197d.js +0 -2
- package/dist/atomic/p-e215ba76.entry.js +0 -2
- package/dist/atomic/p-e790d557.entry.js +0 -2
- package/dist/atomic/p-efd2bb5f.entry.js +0 -2
- package/dist/atomic/p-f2d31b97.entry.js +0 -2
- package/dist/atomic/p-f2d31b97.entry.js.map +0 -1
- package/dist/cjs/analytics-config-2b794369.js.map +0 -1
- package/dist/cjs/atomic-aria-live_2.cjs.entry.js.map +0 -1
- package/dist/cjs/atomic-product-description.cjs.entry.js +0 -141
- package/dist/cjs/atomic-product-description.cjs.entry.js.map +0 -1
- package/dist/cjs/debounce-utils-e014935f.js +0 -49
- package/dist/cjs/debounce-utils-e014935f.js.map +0 -1
- package/dist/cjs/plus-07843914.js +0 -13
- package/dist/cjs/plus-07843914.js.map +0 -1
- package/dist/cjs/stencil-facet-show-more-less-21d22973.js.map +0 -1
- package/dist/esm/analytics-config-482346f6.js.map +0 -1
- package/dist/esm/atomic-aria-live_2.entry.js.map +0 -1
- package/dist/esm/atomic-product-description.entry.js +0 -137
- package/dist/esm/atomic-product-description.entry.js.map +0 -1
- package/dist/esm/debounce-utils-efa015c0.js +0 -46
- package/dist/esm/plus-00840ff6.js +0 -10
- package/dist/esm/plus-00840ff6.js.map +0 -1
- package/dist/esm/stencil-facet-show-more-less-4b023ee3.js.map +0 -1
- package/dist/types/components/search/atomic-search-interface/atomic-aria-live.d.ts +0 -23
- /package/dist/atomic/{p-1b491649.entry.js.map → p-0af927f0.entry.js.map} +0 -0
- /package/dist/atomic/{p-b043958c.entry.js.map → p-0b9cd281.entry.js.map} +0 -0
- /package/dist/atomic/{p-e44ba87e.entry.js.map → p-0f5ae66e.entry.js.map} +0 -0
- /package/dist/atomic/{p-0674783d.entry.js.map → p-1b329f85.entry.js.map} +0 -0
- /package/dist/atomic/{p-efd2bb5f.entry.js.map → p-306161d1.entry.js.map} +0 -0
- /package/dist/atomic/{p-a0445771.entry.js.map → p-4c5702ba.entry.js.map} +0 -0
- /package/dist/atomic/{p-acc4d5de.js.map → p-53bcc515.js.map} +0 -0
- /package/dist/atomic/{p-e2560da8.entry.js.map → p-5f64bbe0.entry.js.map} +0 -0
- /package/dist/atomic/{p-fc73190d.entry.js.map → p-6638ca39.entry.js.map} +0 -0
- /package/dist/atomic/{p-0c35973c.entry.js.map → p-6c412aa0.entry.js.map} +0 -0
- /package/dist/atomic/{p-1176959c.entry.js.map → p-6f8ae3d2.entry.js.map} +0 -0
- /package/dist/atomic/{p-0ed0e8b8.entry.js.map → p-731f82ed.entry.js.map} +0 -0
- /package/dist/atomic/{p-25f8b8d8.entry.js.map → p-7a07530d.entry.js.map} +0 -0
- /package/dist/atomic/{p-c8d47706.entry.js.map → p-7a5d346b.entry.js.map} +0 -0
- /package/dist/atomic/{p-09af5eb5.entry.js.map → p-7db6d666.entry.js.map} +0 -0
- /package/dist/atomic/{p-5b888121.entry.js.map → p-89721f11.entry.js.map} +0 -0
- /package/dist/atomic/{p-11dd759c.entry.js.map → p-b1f7ac63.entry.js.map} +0 -0
- /package/dist/atomic/{p-5fc9f751.entry.js.map → p-bf5d5c79.entry.js.map} +0 -0
- /package/dist/atomic/{p-716e9e1d.entry.js.map → p-c0025d4c.entry.js.map} +0 -0
- /package/dist/atomic/{p-494c57a0.entry.js.map → p-e406cacd.entry.js.map} +0 -0
- /package/dist/atomic/{p-f7e6b154.entry.js.map → p-ef45ff5c.entry.js.map} +0 -0
- /package/dist/atomic/{p-e790d557.entry.js.map → p-f0e861c5.entry.js.map} +0 -0
- /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 =
|
|
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(
|
|
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(
|
|
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
|
-
|
|
321
|
-
|
|
322
|
-
|
|
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
|
-
|
|
375
|
-
|
|
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
|
-
|
|
391
|
-
|
|
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
|
-
|
|
402
|
-
|
|
403
|
-
|
|
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
|
-
|
|
484
|
-
|
|
456
|
+
exists(key, o = {
|
|
457
|
+
interpolation: {}
|
|
458
|
+
}) {
|
|
459
|
+
const opt = {
|
|
460
|
+
...o
|
|
485
461
|
};
|
|
486
|
-
if (key == null)
|
|
487
|
-
|
|
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,
|
|
493
|
-
let 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 =
|
|
496
|
-
let namespaces =
|
|
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 && !
|
|
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,
|
|
517
|
-
|
|
518
|
-
|
|
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')
|
|
521
|
-
...
|
|
497
|
+
if (typeof options === 'object') opt = {
|
|
498
|
+
...opt
|
|
522
499
|
};
|
|
523
|
-
if (!
|
|
500
|
+
if (!opt) opt = {};
|
|
524
501
|
if (keys == null) return '';
|
|
525
502
|
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
526
|
-
const returnDetails =
|
|
527
|
-
const 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],
|
|
508
|
+
} = this.extractFromKey(keys[keys.length - 1], opt);
|
|
532
509
|
const namespace = namespaces[namespaces.length - 1];
|
|
533
|
-
|
|
534
|
-
|
|
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(
|
|
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(
|
|
535
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
558
536
|
};
|
|
559
537
|
}
|
|
560
538
|
return key;
|
|
561
539
|
}
|
|
562
|
-
const resolved = this.resolve(keys,
|
|
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 =
|
|
545
|
+
const joinArrays = opt.joinArrays !== undefined ? opt.joinArrays : this.options.joinArrays;
|
|
568
546
|
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
569
|
-
const needsPluralHandling =
|
|
570
|
-
const hasDefaultValue = Translator.hasDefaultValue(
|
|
571
|
-
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng,
|
|
572
|
-
const defaultValueSuffixOrdinalFallback =
|
|
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 && !
|
|
576
|
-
const defaultValue = needsZeroSuffixLookup &&
|
|
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 (!
|
|
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
|
-
...
|
|
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(
|
|
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
|
-
...
|
|
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
|
-
...
|
|
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,
|
|
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 =
|
|
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
|
-
...
|
|
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,
|
|
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(
|
|
640
|
+
lngs = this.languageUtils.toResolveHierarchy(opt.lng || this.language);
|
|
663
641
|
} else {
|
|
664
|
-
lngs.push(
|
|
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,
|
|
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,
|
|
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,
|
|
679
|
-
if (needsZeroSuffixLookup &&
|
|
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,
|
|
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,
|
|
692
|
-
if (usedKey && res === key && this.options.appendNamespaceToMissingKey)
|
|
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}
|
|
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(
|
|
679
|
+
resolved.usedParams = this.getUsedParamsDetails(opt);
|
|
700
680
|
return resolved;
|
|
701
681
|
}
|
|
702
682
|
return res;
|
|
703
683
|
}
|
|
704
|
-
extendTranslation(res, key,
|
|
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
|
-
...
|
|
710
|
-
},
|
|
688
|
+
...opt
|
|
689
|
+
}, opt.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
711
690
|
resolved
|
|
712
691
|
});
|
|
713
|
-
} else if (!
|
|
714
|
-
if (
|
|
715
|
-
...
|
|
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
|
-
...
|
|
698
|
+
...opt.interpolation
|
|
720
699
|
}
|
|
721
700
|
}
|
|
722
701
|
});
|
|
723
|
-
const skipOnVariables = isString(res) && (
|
|
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 =
|
|
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,
|
|
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)
|
|
717
|
+
if (nestBef < nestAft) opt.nest = false;
|
|
739
718
|
}
|
|
740
|
-
if (!
|
|
741
|
-
if (
|
|
742
|
-
|
|
743
|
-
args[
|
|
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
|
|
750
|
-
},
|
|
751
|
-
if (
|
|
725
|
+
return this.translate(...args, key);
|
|
726
|
+
}, opt);
|
|
727
|
+
if (opt.interpolation) this.interpolator.reset();
|
|
752
728
|
}
|
|
753
|
-
const postProcess =
|
|
729
|
+
const postProcess = opt.postProcess || this.options.postProcess;
|
|
754
730
|
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
755
|
-
if (res != null && postProcessorNames?.length &&
|
|
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(
|
|
735
|
+
usedParams: this.getUsedParamsDetails(opt)
|
|
760
736
|
},
|
|
761
|
-
...
|
|
762
|
-
} :
|
|
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,
|
|
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 =
|
|
782
|
-
const needsZeroSuffixLookup = needsPluralHandling && !
|
|
783
|
-
const needsContextHandling =
|
|
784
|
-
const codes =
|
|
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,
|
|
772
|
+
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, opt);
|
|
798
773
|
} else {
|
|
799
774
|
let pluralSuffix;
|
|
800
|
-
if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code,
|
|
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 (
|
|
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}${
|
|
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 (
|
|
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,
|
|
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 =
|
|
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
|
-
|
|
1259
|
-
if (
|
|
1260
|
-
|
|
1261
|
-
match[1] =
|
|
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 (
|
|
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 (
|
|
1319
|
-
let optForCache =
|
|
1320
|
-
if (
|
|
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
|
-
[
|
|
1285
|
+
[o.interpolationkey]: undefined
|
|
1324
1286
|
};
|
|
1325
1287
|
}
|
|
1326
|
-
const key =
|
|
1327
|
-
let
|
|
1328
|
-
if (!
|
|
1329
|
-
|
|
1330
|
-
cache[key] =
|
|
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
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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('*',
|
|
1819
|
-
|
|
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('*',
|
|
1834
|
-
|
|
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] =
|
|
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] =
|
|
1861
|
-
|
|
1862
|
-
return
|
|
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
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
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(
|
|
1997
|
-
|
|
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
|
|
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
|
-
|
|
2032
|
-
|
|
2033
|
-
let options;
|
|
1976
|
+
const fixedT = (key, opts, ...rest) => {
|
|
1977
|
+
let o;
|
|
2034
1978
|
if (typeof opts !== 'object') {
|
|
2035
|
-
|
|
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
|
-
|
|
1981
|
+
o = {
|
|
2041
1982
|
...opts
|
|
2042
1983
|
};
|
|
2043
1984
|
}
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
if (
|
|
2048
|
-
const 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 (
|
|
2051
|
-
resultKey = key.map(k => `${
|
|
1991
|
+
if (o.keyPrefix && Array.isArray(key)) {
|
|
1992
|
+
resultKey = key.map(k => `${o.keyPrefix}${keySeparator}${k}`);
|
|
2052
1993
|
} else {
|
|
2053
|
-
resultKey =
|
|
1994
|
+
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
2054
1995
|
}
|
|
2055
|
-
return
|
|
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
|
-
|
|
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('*',
|
|
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.
|
|
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-
|
|
2924
|
+
//# sourceMappingURL=analytics-config-e18c57f7.js.map
|