@sankhyalabs/ezui 6.1.0-dev.2 → 6.1.0-dev.21
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/cjs/{ApplicationUtils-c9d1205c.js → ApplicationUtils-39807831.js} +43 -15
- package/dist/cjs/RichToolbarHelper-ea12328f.js +33 -0
- package/dist/cjs/_commonjsHelpers-537d719a.js +20 -0
- package/dist/cjs/app-globals-86776e90.js +12 -0
- package/dist/cjs/{constants-569271bc.js → constants-72b7e05e.js} +0 -2
- package/dist/cjs/ez-actions-button.cjs.entry.js +3 -2
- package/dist/cjs/ez-alert-list.cjs.entry.js +6 -4
- package/dist/cjs/ez-alert.cjs.entry.js +1 -1
- package/dist/cjs/ez-application.cjs.entry.js +1 -1
- package/dist/cjs/ez-avatar.cjs.entry.js +7 -2
- package/dist/cjs/ez-badge.cjs.entry.js +1 -1
- package/dist/cjs/ez-breadcrumb.cjs.entry.js +1 -1
- package/dist/cjs/ez-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-calendar.cjs.entry.js +8 -7
- package/dist/cjs/ez-card-item_2.cjs.entry.js +2 -2
- package/dist/cjs/ez-chart.cjs.entry.js +4 -19
- package/dist/cjs/ez-check.cjs.entry.js +2 -2
- package/dist/cjs/ez-chip.cjs.entry.js +3 -2
- package/dist/cjs/ez-collapsible-box.cjs.entry.js +15 -12
- package/dist/cjs/{ez-combo-box-list_3.cjs.entry.js → ez-combo-box-list_4.cjs.entry.js} +292 -6
- package/dist/cjs/ez-combo-box.cjs.entry.js +33 -15
- package/dist/cjs/ez-date-input.cjs.entry.js +6 -2
- package/dist/cjs/ez-date-time-input.cjs.entry.js +6 -2
- package/dist/cjs/ez-dialog.cjs.entry.js +9 -7
- package/dist/cjs/ez-double-list.cjs.entry.js +13 -5
- package/dist/cjs/ez-dropdown.cjs.entry.js +1 -1
- package/dist/cjs/ez-empty-card.cjs.entry.js +34 -0
- package/dist/cjs/ez-file-item.cjs.entry.js +10 -7
- package/dist/cjs/ez-filter-input.cjs.entry.js +129 -0
- package/dist/cjs/ez-form-view.cjs.entry.js +13 -5
- package/dist/cjs/ez-form.cjs.entry.js +5 -4
- package/dist/cjs/ez-grid.cjs.entry.js +172 -133
- package/dist/cjs/ez-guide-navigator.cjs.entry.js +6 -2
- package/dist/cjs/ez-icon.cjs.entry.js +2 -2
- package/dist/cjs/ez-link-builder_6.cjs.entry.js +315 -0
- package/dist/cjs/ez-list.cjs.entry.js +5 -3
- package/dist/cjs/ez-loading-bar.cjs.entry.js +1 -1
- package/dist/cjs/ez-modal-container.cjs.entry.js +7 -3
- package/dist/cjs/ez-modal.cjs.entry.js +6 -2
- package/dist/cjs/ez-multi-selection-list.cjs.entry.js +10 -6
- package/dist/cjs/ez-number-input.cjs.entry.js +6 -2
- package/dist/cjs/ez-popover-plus_3.cjs.entry.js +1 -1
- package/dist/cjs/ez-popover.cjs.entry.js +1 -1
- package/dist/cjs/ez-popup.cjs.entry.js +1 -1
- package/dist/cjs/ez-radio-button.cjs.entry.js +1 -1
- package/dist/cjs/ez-rich-toolbar-item.cjs.entry.js +27 -0
- package/dist/cjs/ez-scroller_2.cjs.entry.js +1 -1
- package/dist/cjs/ez-search-plus.cjs.entry.js +19 -10
- package/dist/cjs/ez-search-result-list.cjs.entry.js +25 -8
- package/dist/cjs/ez-search.cjs.entry.js +9 -10
- package/dist/cjs/ez-sidebar-navigator.cjs.entry.js +6 -8
- package/dist/cjs/ez-skeleton.cjs.entry.js +6 -4
- package/dist/cjs/ez-sortable-list.cjs.entry.js +13 -6
- package/dist/cjs/ez-split-button.cjs.entry.js +6 -5
- package/dist/cjs/ez-split-item.cjs.entry.js +7 -3
- package/dist/cjs/ez-split-panel.cjs.entry.js +1 -1
- package/dist/cjs/ez-tabselector.cjs.entry.js +1 -1
- package/dist/cjs/ez-text-area.cjs.entry.js +35 -28
- package/dist/cjs/ez-text-input.cjs.entry.js +3 -2
- package/dist/cjs/ez-tile.cjs.entry.js +62 -0
- package/dist/cjs/ez-time-input.cjs.entry.js +13 -11
- package/dist/cjs/ez-toast.cjs.entry.js +1 -1
- package/dist/cjs/{ez-filter-input_2.cjs.entry.js → ez-tooltip.cjs.entry.js} +2 -124
- package/dist/cjs/ez-tree.cjs.entry.js +6 -2
- package/dist/cjs/ez-upload.cjs.entry.js +18 -12
- package/dist/cjs/ez-view-stack.cjs.entry.js +1 -1
- package/dist/cjs/ezui.cjs.js +6 -2
- package/dist/cjs/filter-column.cjs.entry.js +9 -5
- package/dist/cjs/index-02854309.js +3672 -0
- package/dist/cjs/{index-9e5554cb.js → index-a7b0c73d.js} +32 -15
- package/dist/cjs/loader.cjs.js +6 -2
- package/dist/cjs/purify-a7dc3a08.js +1354 -0
- package/dist/cjs/{search-column-1d3c9fa5.js → search-column-82c52e20.js} +11 -5
- package/dist/collection/collection-manifest.json +27 -1
- package/dist/collection/components/ez-alert-list/ez-alert-list.js +5 -3
- package/dist/collection/components/ez-avatar/ez-avatar.js +5 -1
- package/dist/collection/components/ez-calendar/ez-calendar.js +7 -6
- package/dist/collection/components/ez-check/ez-check.css +1 -1
- package/dist/collection/components/ez-chip/ez-chip.js +20 -1
- package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.css +1 -0
- package/dist/collection/components/ez-collapsible-box/ez-collapsible-box.js +12 -9
- package/dist/collection/components/ez-combo-box/ez-combo-box-list/ez-combo-box-list.js +7 -4
- package/dist/collection/components/ez-combo-box/ez-combo-box.js +50 -15
- package/dist/collection/components/ez-date-input/ez-date-input.js +5 -1
- package/dist/collection/components/ez-date-time-input/ez-date-time-input.js +5 -1
- package/dist/collection/components/ez-dialog/ez-dialog.js +8 -6
- package/dist/collection/components/ez-double-list/ez-double-list.js +12 -4
- package/dist/collection/components/ez-empty-card/ez-empty-card.css +55 -0
- package/dist/collection/components/ez-empty-card/ez-empty-card.js +91 -0
- package/dist/collection/components/ez-file-item/ez-file-item.js +9 -6
- package/dist/collection/components/ez-form/ez-form.js +1 -1
- package/dist/collection/components/ez-form-view/ez-form-view.js +4 -3
- package/dist/collection/components/ez-form-view/fieldbuilder/FieldBuilder.js +5 -2
- package/dist/collection/components/ez-form-view/fieldbuilder/templates/RichText.tpl.js +4 -0
- package/dist/collection/components/ez-grid/controller/ag-grid/AgGridController.js +38 -11
- package/dist/collection/components/ez-grid/controller/ag-grid/DataSource.js +14 -4
- package/dist/collection/components/ez-grid/controller/ag-grid/GridEditionManager.js +4 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.js +3 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/utils/buildLocaleText.js +67 -0
- package/dist/collection/components/ez-grid/ez-grid.js +15 -13
- package/dist/collection/components/ez-grid/subcomponents/filter-column.js +7 -3
- package/dist/collection/components/ez-grid/subcomponents/selection-counter.js +2 -2
- package/dist/collection/components/ez-grid/subcomponents/utils/selectionCounterUtils.js +11 -7
- package/dist/collection/components/ez-guide-navigator/ez-guide-navigator.js +5 -1
- package/dist/collection/components/ez-icon/ez-icon.css +147 -140
- package/dist/collection/components/ez-list/ez-list.js +4 -2
- package/dist/collection/components/ez-modal/ez-modal.js +5 -1
- package/dist/collection/components/ez-modal-container/ez-modal-container.css +2 -0
- package/dist/collection/components/ez-modal-container/ez-modal-container.js +5 -1
- package/dist/collection/components/ez-multi-selection-list/ez-multi-selection-list.js +9 -5
- package/dist/collection/components/ez-number-input/ez-number-input.js +5 -1
- package/dist/collection/components/ez-popover-plus/subcomponent/ez-popover-core.css +3 -2
- package/dist/collection/components/ez-rich-text/ez-link-builder/ez-link-builder.css +22 -0
- package/dist/collection/components/ez-rich-text/ez-link-builder/ez-link-builder.js +135 -0
- package/dist/collection/components/ez-rich-text/ez-rich-text.css +30 -0
- package/dist/collection/components/ez-rich-text/ez-rich-text.js +575 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/RichToolbarHelper.js +27 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.css +4 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.js +23 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.css +4 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.js +23 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.css +20 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.js +122 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.css +4 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.js +23 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.css +42 -0
- package/dist/collection/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.js +187 -0
- package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.css +70 -0
- package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.js +220 -0
- package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/test/resource/imageBase64.js +1 -0
- package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/utils/fileToBase64.js +14 -0
- package/dist/collection/components/ez-rich-text/ez-simple-image-uploader/utils/formatBytes.js +10 -0
- package/dist/collection/components/ez-search/ez-search.js +7 -8
- package/dist/collection/components/ez-search-plus/ez-search-plus.css +2 -0
- package/dist/collection/components/ez-search-plus/ez-search-plus.js +16 -7
- package/dist/collection/components/ez-search-plus/subcomponent/ez-search-result-list/ez-search-result-list.js +27 -7
- package/dist/collection/components/ez-sidebar-navigator/ez-sidebar-navigator.js +5 -2
- package/dist/collection/components/ez-skeleton/ez-skeleton.constants.js +0 -1
- package/dist/collection/components/ez-skeleton/ez-skeleton.js +4 -2
- package/dist/collection/components/ez-sortable-list/ez-sortable-list.js +15 -11
- package/dist/collection/components/ez-split-button/ez-split-button.js +6 -6
- package/dist/collection/components/ez-split-panel/structure/item/ez-split-item.js +5 -1
- package/dist/collection/components/ez-text-area/ez-text-area.css +244 -212
- package/dist/collection/components/ez-text-area/ez-text-area.js +35 -28
- package/dist/collection/components/ez-text-edit/ez-text-edit.js +5 -1
- package/dist/collection/components/ez-text-input/ez-text-input.js +2 -1
- package/dist/collection/components/ez-tile/ez-tile.css +151 -0
- package/dist/collection/components/ez-tile/ez-tile.js +269 -0
- package/dist/collection/components/ez-time-input/ez-time-input.js +12 -10
- package/dist/collection/components/ez-tooltip/ez-tooltip.js +1 -1
- package/dist/collection/components/ez-tree/ez-tree.js +5 -1
- package/dist/collection/components/ez-upload/ez-upload.js +18 -12
- package/dist/collection/global/app-init.js +6 -0
- package/dist/collection/setupTests.js +1 -1
- package/dist/collection/utils/ApplicationUtils.js +43 -15
- package/dist/collection/utils/constants.js +0 -1
- package/dist/collection/utils/i18n/elanguages.js +6 -0
- package/dist/collection/utils/i18n/i18nUtils.js +20 -0
- package/dist/collection/utils/i18n/index.js +30 -0
- package/dist/collection/utils/i18n/locales/en-us.js +275 -0
- package/dist/collection/utils/i18n/locales/es-es.js +275 -0
- package/dist/collection/utils/i18n/locales/pt-br.js +275 -0
- package/dist/collection/utils/i18n/translations.js +9 -0
- package/dist/collection/utils/validators/recordvalidator/RecordValidationProcessor.js +8 -2
- package/dist/custom-elements/index.d.ts +60 -0
- package/dist/custom-elements/index.js +6252 -308
- package/dist/esm/{ApplicationUtils-eaf91331.js → ApplicationUtils-72f474e8.js} +43 -15
- package/dist/esm/RichToolbarHelper-f3a149c4.js +29 -0
- package/dist/esm/_commonjsHelpers-9943807e.js +17 -0
- package/dist/esm/app-globals-2ccb253f.js +10 -0
- package/dist/esm/{constants-b036528f.js → constants-3fabe81e.js} +1 -2
- package/dist/esm/ez-actions-button.entry.js +3 -2
- package/dist/esm/ez-alert-list.entry.js +6 -4
- package/dist/esm/ez-alert.entry.js +1 -1
- package/dist/esm/ez-application.entry.js +1 -1
- package/dist/esm/ez-avatar.entry.js +7 -2
- package/dist/esm/ez-badge.entry.js +1 -1
- package/dist/esm/ez-breadcrumb.entry.js +1 -1
- package/dist/esm/ez-button.entry.js +1 -1
- package/dist/esm/ez-calendar.entry.js +8 -7
- package/dist/esm/ez-card-item_2.entry.js +2 -2
- package/dist/esm/ez-chart.entry.js +2 -17
- package/dist/esm/ez-check.entry.js +2 -2
- package/dist/esm/ez-chip.entry.js +3 -2
- package/dist/esm/ez-collapsible-box.entry.js +15 -12
- package/dist/esm/{ez-combo-box-list_3.entry.js → ez-combo-box-list_4.entry.js} +293 -8
- package/dist/esm/ez-combo-box.entry.js +33 -15
- package/dist/esm/ez-date-input.entry.js +6 -2
- package/dist/esm/ez-date-time-input.entry.js +6 -2
- package/dist/esm/ez-dialog.entry.js +9 -7
- package/dist/esm/ez-double-list.entry.js +13 -5
- package/dist/esm/ez-dropdown.entry.js +1 -1
- package/dist/esm/ez-empty-card.entry.js +30 -0
- package/dist/esm/ez-file-item.entry.js +10 -7
- package/dist/esm/ez-filter-input.entry.js +125 -0
- package/dist/esm/ez-form-view.entry.js +13 -5
- package/dist/esm/ez-form.entry.js +5 -4
- package/dist/esm/ez-grid.entry.js +155 -116
- package/dist/esm/ez-guide-navigator.entry.js +6 -2
- package/dist/esm/ez-icon.entry.js +2 -2
- package/dist/esm/ez-link-builder_6.entry.js +306 -0
- package/dist/esm/ez-list.entry.js +5 -3
- package/dist/esm/ez-loading-bar.entry.js +1 -1
- package/dist/esm/ez-modal-container.entry.js +7 -3
- package/dist/esm/ez-modal.entry.js +6 -2
- package/dist/esm/ez-multi-selection-list.entry.js +10 -6
- package/dist/esm/ez-number-input.entry.js +6 -2
- package/dist/esm/ez-popover-plus_3.entry.js +1 -1
- package/dist/esm/ez-popover.entry.js +1 -1
- package/dist/esm/ez-popup.entry.js +1 -1
- package/dist/esm/ez-radio-button.entry.js +1 -1
- package/dist/esm/ez-rich-toolbar-item.entry.js +23 -0
- package/dist/esm/ez-scroller_2.entry.js +1 -1
- package/dist/esm/ez-search-plus.entry.js +19 -10
- package/dist/esm/ez-search-result-list.entry.js +25 -8
- package/dist/esm/ez-search.entry.js +9 -10
- package/dist/esm/ez-sidebar-navigator.entry.js +6 -8
- package/dist/esm/ez-skeleton.entry.js +6 -4
- package/dist/esm/ez-sortable-list.entry.js +13 -6
- package/dist/esm/ez-split-button.entry.js +6 -5
- package/dist/esm/ez-split-item.entry.js +7 -3
- package/dist/esm/ez-split-panel.entry.js +1 -1
- package/dist/esm/ez-tabselector.entry.js +1 -1
- package/dist/esm/ez-text-area.entry.js +35 -28
- package/dist/esm/ez-text-input.entry.js +3 -2
- package/dist/esm/ez-tile.entry.js +58 -0
- package/dist/esm/ez-time-input.entry.js +13 -11
- package/dist/esm/ez-toast.entry.js +1 -1
- package/dist/esm/{ez-filter-input_2.entry.js → ez-tooltip.entry.js} +3 -124
- package/dist/esm/ez-tree.entry.js +6 -2
- package/dist/esm/ez-upload.entry.js +18 -12
- package/dist/esm/ez-view-stack.entry.js +1 -1
- package/dist/esm/ezui.js +7 -3
- package/dist/esm/filter-column.entry.js +9 -5
- package/dist/esm/index-b623906e.js +3669 -0
- package/dist/esm/{index-5a720e56.js → index-baa5e267.js} +33 -15
- package/dist/esm/loader.js +7 -3
- package/dist/esm/purify-da6317bb.js +1352 -0
- package/dist/esm/{search-column-35f4ad93.js → search-column-5a55f676.js} +10 -4
- package/dist/ezui/ezui.esm.js +1 -1
- package/dist/ezui/p-0603bcc7.entry.js +1 -0
- package/dist/ezui/p-0ec7aa3a.entry.js +1 -0
- package/dist/ezui/p-0f0f3efe.entry.js +1 -0
- package/dist/ezui/p-112455b1.js +1 -0
- package/dist/ezui/{p-87f5a060.entry.js → p-1bcfd88c.entry.js} +1 -1
- package/dist/ezui/p-1c3efd36.entry.js +1 -0
- package/dist/ezui/p-1c55dda0.js +3 -0
- package/dist/ezui/{p-81461d2f.entry.js → p-1e7a8633.entry.js} +1 -1
- package/dist/ezui/{p-6b51c9cc.entry.js → p-1f50fa05.entry.js} +1 -1
- package/dist/ezui/p-1ffb75d5.js +1 -0
- package/dist/ezui/p-20c024f7.entry.js +1 -0
- package/dist/ezui/p-22934e19.entry.js +1 -0
- package/dist/ezui/{p-e4c7eb39.js → p-23a36bb6.js} +2 -2
- package/dist/ezui/{p-06f1b8e4.entry.js → p-288631d1.entry.js} +1 -1
- package/dist/ezui/p-2f471aca.entry.js +1 -0
- package/dist/ezui/p-303b3b8c.entry.js +1 -0
- package/dist/ezui/p-3b89a9a0.entry.js +1 -0
- package/dist/ezui/p-3e71ca08.entry.js +1 -0
- package/dist/ezui/p-3e767a74.js +1 -0
- package/dist/ezui/p-3e88fbb6.entry.js +1 -0
- package/dist/ezui/p-4044a7d7.entry.js +1 -0
- package/dist/ezui/{p-0378416a.entry.js → p-44caad9a.entry.js} +1 -1
- package/dist/ezui/p-45c9b292.entry.js +1 -0
- package/dist/ezui/p-45e64547.entry.js +1 -0
- package/dist/ezui/p-46913da7.js +1 -0
- package/dist/ezui/p-4773ff4c.js +1 -0
- package/dist/ezui/{p-769632d5.entry.js → p-4b67138e.entry.js} +1 -1
- package/dist/ezui/{p-4a876b8b.entry.js → p-4d30b703.entry.js} +1 -1
- package/dist/ezui/p-4fc5f926.entry.js +1 -0
- package/dist/ezui/p-53bc30a1.entry.js +1 -0
- package/dist/ezui/{p-6fc26622.entry.js → p-5ed81457.entry.js} +1 -1
- package/dist/ezui/p-627ff5a2.entry.js +1 -0
- package/dist/ezui/p-629e32e2.entry.js +1 -0
- package/dist/ezui/p-6369a0cd.entry.js +1 -0
- package/dist/ezui/{p-80764ff6.entry.js → p-6562b5c8.entry.js} +46 -46
- package/dist/ezui/p-6d596a5a.entry.js +1 -0
- package/dist/ezui/p-6e6fccfb.entry.js +1 -0
- package/dist/ezui/p-713dc93e.entry.js +1 -0
- package/dist/ezui/p-79044c3e.entry.js +1 -0
- package/dist/ezui/{p-5b85d3de.entry.js → p-7f792043.entry.js} +1 -1
- package/dist/ezui/p-80461324.entry.js +1 -0
- package/dist/ezui/p-84a136bf.entry.js +1 -0
- package/dist/ezui/{p-b3b3c99a.entry.js → p-8afb6e8a.entry.js} +1 -1
- package/dist/ezui/{p-82fa4b09.entry.js → p-8df1ca33.entry.js} +1 -1
- package/dist/ezui/p-91c9d50e.entry.js +1 -0
- package/dist/ezui/p-973e6a40.entry.js +1 -0
- package/dist/ezui/{p-18e71523.entry.js → p-9c5cd3b2.entry.js} +1 -1
- package/dist/ezui/{p-c2b20f78.entry.js → p-9f5fa3f9.entry.js} +1 -1
- package/dist/ezui/p-a12f6074.entry.js +1 -0
- package/dist/ezui/p-a482aae1.entry.js +1 -0
- package/dist/ezui/p-a687f14c.entry.js +7 -0
- package/dist/ezui/{p-dfca5946.entry.js → p-a80b1287.entry.js} +1 -1
- package/dist/ezui/p-adbc3261.entry.js +1 -0
- package/dist/ezui/p-b115058e.entry.js +1 -0
- package/dist/ezui/p-b1e45320.js +1 -0
- package/dist/ezui/p-b4215a04.entry.js +1 -0
- package/dist/ezui/p-b8ed876d.entry.js +1 -0
- package/dist/ezui/p-ba07b3df.js +1 -0
- package/dist/ezui/p-bc2f844e.entry.js +1 -0
- package/dist/ezui/p-beb42de1.entry.js +1 -0
- package/dist/ezui/p-c00ad772.entry.js +1 -0
- package/dist/ezui/{p-92748142.entry.js → p-c0d9c4f8.entry.js} +1 -1
- package/dist/ezui/p-c2a8139d.entry.js +1 -0
- package/dist/ezui/p-caf2584a.entry.js +1 -0
- package/dist/ezui/p-d1d0868b.entry.js +1 -0
- package/dist/ezui/p-d2645bdf.entry.js +1 -0
- package/dist/ezui/p-e5260556.entry.js +1 -0
- package/dist/ezui/{p-000159dc.entry.js → p-e75c7a23.entry.js} +1 -1
- package/dist/ezui/p-e7a7c594.entry.js +1 -0
- package/dist/ezui/p-ed3bed1e.entry.js +1 -0
- package/dist/ezui/{p-44b39e81.entry.js → p-fa6732f2.entry.js} +1 -1
- package/dist/types/components/ez-alert-list/ez-alert-list.d.ts +2 -1
- package/dist/types/components/ez-avatar/ez-avatar.d.ts +2 -0
- package/dist/types/components/ez-calendar/ez-calendar.d.ts +2 -3
- package/dist/types/components/ez-chip/ez-chip.d.ts +4 -0
- package/dist/types/components/ez-collapsible-box/ez-collapsible-box.d.ts +2 -0
- package/dist/types/components/ez-combo-box/ez-combo-box-list/ez-combo-box-list.d.ts +2 -0
- package/dist/types/components/ez-combo-box/ez-combo-box.d.ts +9 -2
- package/dist/types/components/ez-date-input/ez-date-input.d.ts +2 -0
- package/dist/types/components/ez-date-time-input/ez-date-time-input.d.ts +2 -0
- package/dist/types/components/ez-dialog/ez-dialog.d.ts +2 -2
- package/dist/types/components/ez-double-list/ez-double-list.d.ts +2 -0
- package/dist/types/components/ez-empty-card/ez-empty-card.d.ts +18 -0
- package/dist/types/components/ez-file-item/ez-file-item.d.ts +2 -0
- package/dist/types/components/ez-form-view/fieldbuilder/templates/RichText.tpl.d.ts +2 -0
- package/dist/types/components/ez-grid/controller/EzGridController.d.ts +5 -0
- package/dist/types/components/ez-grid/controller/ag-grid/AgGridController.d.ts +2 -0
- package/dist/types/components/ez-grid/controller/ag-grid/DataSource.d.ts +1 -0
- package/dist/types/components/ez-grid/controller/ag-grid/GridEditionManager.d.ts +1 -0
- package/dist/types/components/ez-grid/controller/ag-grid/test/constants/GridEditionMock.d.ts +1 -1
- package/dist/types/components/ez-grid/controller/ag-grid/utils/buildLocaleText.d.ts +66 -0
- package/dist/types/components/ez-grid/ez-grid.d.ts +2 -2
- package/dist/types/components/ez-grid/subcomponents/filter-column.d.ts +2 -0
- package/dist/types/components/ez-grid/subcomponents/selection-counter.d.ts +2 -0
- package/dist/types/components/ez-grid/subcomponents/utils/selectionCounterUtils.d.ts +2 -2
- package/dist/types/components/ez-guide-navigator/ez-guide-navigator.d.ts +2 -0
- package/dist/types/components/ez-list/ez-list.d.ts +2 -1
- package/dist/types/components/ez-modal/ez-modal.d.ts +2 -0
- package/dist/types/components/ez-modal-container/ez-modal-container.d.ts +2 -0
- package/dist/types/components/ez-multi-selection-list/ez-multi-selection-list.d.ts +2 -0
- package/dist/types/components/ez-number-input/ez-number-input.d.ts +2 -0
- package/dist/types/components/ez-rich-text/ez-link-builder/ez-link-builder.d.ts +19 -0
- package/dist/types/components/ez-rich-text/ez-rich-text.d.ts +105 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/RichToolbarHelper.d.ts +31 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-arrows/ez-rich-toolbar-arrows.d.ts +5 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-configs/ez-rich-toolbar-configs.d.ts +5 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-item/ez-rich-toolbar-item.d.ts +11 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar-letters/ez-rich-toolbar-letters.d.ts +5 -0
- package/dist/types/components/ez-rich-text/ez-rich-toolbar/ez-rich-toolbar.d.ts +35 -0
- package/dist/types/components/ez-rich-text/ez-simple-image-uploader/ez-simple-image-uploader.d.ts +39 -0
- package/dist/types/components/ez-rich-text/ez-simple-image-uploader/test/resource/imageBase64.d.ts +1 -0
- package/dist/types/components/ez-rich-text/ez-simple-image-uploader/utils/fileToBase64.d.ts +1 -0
- package/dist/types/components/ez-rich-text/ez-simple-image-uploader/utils/formatBytes.d.ts +1 -0
- package/dist/types/components/ez-search/ez-search.d.ts +2 -3
- package/dist/types/components/ez-search-plus/ez-search-plus.d.ts +4 -1
- package/dist/types/components/ez-search-plus/subcomponent/ez-search-result-list/ez-search-result-list.d.ts +4 -1
- package/dist/types/components/ez-sidebar-navigator/ez-sidebar-navigator.d.ts +2 -0
- package/dist/types/components/ez-skeleton/ez-skeleton.constants.d.ts +0 -1
- package/dist/types/components/ez-skeleton/ez-skeleton.d.ts +2 -1
- package/dist/types/components/ez-sortable-list/ez-sortable-list.d.ts +2 -0
- package/dist/types/components/ez-split-button/ez-split-button.d.ts +2 -2
- package/dist/types/components/ez-split-panel/structure/item/ez-split-item.d.ts +2 -0
- package/dist/types/components/ez-text-area/ez-text-area.d.ts +6 -3
- package/dist/types/components/ez-text-edit/ez-text-edit.d.ts +2 -0
- package/dist/types/components/ez-tile/ez-tile.d.ts +58 -0
- package/dist/types/components/ez-time-input/ez-time-input.d.ts +2 -1
- package/dist/types/components/ez-tree/ez-tree.d.ts +2 -0
- package/dist/types/components/ez-upload/ez-upload.d.ts +3 -1
- package/dist/types/components.d.ts +447 -2
- package/dist/types/global/app-init.d.ts +1 -0
- package/dist/types/utils/ApplicationUtils.d.ts +3 -1
- package/dist/types/utils/constants.d.ts +0 -1
- package/dist/types/utils/i18n/elanguages.d.ts +5 -0
- package/dist/types/utils/i18n/i18nUtils.d.ts +2 -0
- package/dist/types/utils/i18n/index.d.ts +5 -0
- package/dist/types/utils/i18n/locales/en-us.d.ts +276 -0
- package/dist/types/utils/i18n/locales/es-es.d.ts +276 -0
- package/dist/types/utils/i18n/locales/pt-br.d.ts +276 -0
- package/dist/types/utils/i18n/translations.d.ts +828 -0
- package/dist/types/utils/validators/recordvalidator/RecordValidationProcessor.d.ts +1 -0
- package/package.json +8 -1
- package/react/components.d.ts +10 -0
- package/react/components.js +10 -0
- package/react/components.js.map +1 -1
- package/dist/collection/components/ez-grid/controller/ag-grid/i18n/pt-BR.js +0 -75
- package/dist/collection/components/ez-sidebar-navigator/messages/constants.js +0 -5
- package/dist/ezui/p-01b72d7e.entry.js +0 -1
- package/dist/ezui/p-07594da0.entry.js +0 -1
- package/dist/ezui/p-11bfeca3.entry.js +0 -1
- package/dist/ezui/p-175154a0.js +0 -1
- package/dist/ezui/p-1fefb37a.entry.js +0 -1
- package/dist/ezui/p-2187f86c.js +0 -1
- package/dist/ezui/p-220b9944.entry.js +0 -1
- package/dist/ezui/p-28987410.entry.js +0 -1
- package/dist/ezui/p-2d10bb18.entry.js +0 -1
- package/dist/ezui/p-2f351332.entry.js +0 -1
- package/dist/ezui/p-4e66eaeb.entry.js +0 -1
- package/dist/ezui/p-545bd5d5.entry.js +0 -7
- package/dist/ezui/p-5eea9886.js +0 -1
- package/dist/ezui/p-61f5c258.entry.js +0 -1
- package/dist/ezui/p-6b2cc9b8.entry.js +0 -1
- package/dist/ezui/p-6b3fddee.entry.js +0 -1
- package/dist/ezui/p-6ec40dec.entry.js +0 -1
- package/dist/ezui/p-700c1320.entry.js +0 -1
- package/dist/ezui/p-708b196e.entry.js +0 -1
- package/dist/ezui/p-7567ccdd.entry.js +0 -1
- package/dist/ezui/p-791f4e43.entry.js +0 -1
- package/dist/ezui/p-7db20f8e.entry.js +0 -1
- package/dist/ezui/p-7ec3f335.entry.js +0 -1
- package/dist/ezui/p-85d7b78a.entry.js +0 -1
- package/dist/ezui/p-90c90351.entry.js +0 -1
- package/dist/ezui/p-90e91173.entry.js +0 -1
- package/dist/ezui/p-91ccae0c.entry.js +0 -1
- package/dist/ezui/p-926a0bde.entry.js +0 -1
- package/dist/ezui/p-97d94ef3.entry.js +0 -1
- package/dist/ezui/p-9e95bfeb.entry.js +0 -1
- package/dist/ezui/p-a11827ca.entry.js +0 -1
- package/dist/ezui/p-c7035d65.entry.js +0 -1
- package/dist/ezui/p-c8e6204f.entry.js +0 -1
- package/dist/ezui/p-d2290004.entry.js +0 -1
- package/dist/ezui/p-d4d6d5fe.entry.js +0 -1
- package/dist/ezui/p-ddb22a70.entry.js +0 -1
- package/dist/ezui/p-ddd0bd61.entry.js +0 -1
- package/dist/ezui/p-e4ae4ddb.entry.js +0 -1
- package/dist/ezui/p-e4ead194.entry.js +0 -1
- package/dist/ezui/p-e6b38ade.entry.js +0 -1
- package/dist/ezui/p-ed48a632.entry.js +0 -1
- package/dist/ezui/p-fc194825.entry.js +0 -1
- package/dist/types/components/ez-grid/controller/ag-grid/i18n/pt-BR.d.ts +0 -2
- package/dist/types/components/ez-sidebar-navigator/messages/constants.d.ts +0 -5
|
@@ -0,0 +1,3669 @@
|
|
|
1
|
+
import { ApplicationContext } from '@sankhyalabs/core';
|
|
2
|
+
|
|
3
|
+
const isString = obj => typeof obj === 'string';
|
|
4
|
+
const defer = () => {
|
|
5
|
+
let res;
|
|
6
|
+
let rej;
|
|
7
|
+
const promise = new Promise((resolve, reject) => {
|
|
8
|
+
res = resolve;
|
|
9
|
+
rej = reject;
|
|
10
|
+
});
|
|
11
|
+
promise.resolve = res;
|
|
12
|
+
promise.reject = rej;
|
|
13
|
+
return promise;
|
|
14
|
+
};
|
|
15
|
+
const makeString = object => {
|
|
16
|
+
if (object == null) return '';
|
|
17
|
+
return '' + object;
|
|
18
|
+
};
|
|
19
|
+
const copy = (a, s, t) => {
|
|
20
|
+
a.forEach(m => {
|
|
21
|
+
if (s[m]) t[m] = s[m];
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
const lastOfPathSeparatorRegExp = /###/g;
|
|
25
|
+
const cleanKey = key => key && key.indexOf('###') > -1 ? key.replace(lastOfPathSeparatorRegExp, '.') : key;
|
|
26
|
+
const canNotTraverseDeeper = object => !object || isString(object);
|
|
27
|
+
const getLastOfPath = (object, path, Empty) => {
|
|
28
|
+
const stack = !isString(path) ? path : path.split('.');
|
|
29
|
+
let stackIndex = 0;
|
|
30
|
+
while (stackIndex < stack.length - 1) {
|
|
31
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
32
|
+
const key = cleanKey(stack[stackIndex]);
|
|
33
|
+
if (!object[key] && Empty) object[key] = new Empty();
|
|
34
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
35
|
+
object = object[key];
|
|
36
|
+
} else {
|
|
37
|
+
object = {};
|
|
38
|
+
}
|
|
39
|
+
++stackIndex;
|
|
40
|
+
}
|
|
41
|
+
if (canNotTraverseDeeper(object)) return {};
|
|
42
|
+
return {
|
|
43
|
+
obj: object,
|
|
44
|
+
k: cleanKey(stack[stackIndex])
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
const setPath = (object, path, newValue) => {
|
|
48
|
+
const {
|
|
49
|
+
obj,
|
|
50
|
+
k
|
|
51
|
+
} = getLastOfPath(object, path, Object);
|
|
52
|
+
if (obj !== undefined || path.length === 1) {
|
|
53
|
+
obj[k] = newValue;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let e = path[path.length - 1];
|
|
57
|
+
let p = path.slice(0, path.length - 1);
|
|
58
|
+
let last = getLastOfPath(object, p, Object);
|
|
59
|
+
while (last.obj === undefined && p.length) {
|
|
60
|
+
e = `${p[p.length - 1]}.${e}`;
|
|
61
|
+
p = p.slice(0, p.length - 1);
|
|
62
|
+
last = getLastOfPath(object, p, Object);
|
|
63
|
+
if (last && last.obj && typeof last.obj[`${last.k}.${e}`] !== 'undefined') {
|
|
64
|
+
last.obj = undefined;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
last.obj[`${last.k}.${e}`] = newValue;
|
|
68
|
+
};
|
|
69
|
+
const pushPath = (object, path, newValue, concat) => {
|
|
70
|
+
const {
|
|
71
|
+
obj,
|
|
72
|
+
k
|
|
73
|
+
} = getLastOfPath(object, path, Object);
|
|
74
|
+
obj[k] = obj[k] || [];
|
|
75
|
+
obj[k].push(newValue);
|
|
76
|
+
};
|
|
77
|
+
const getPath = (object, path) => {
|
|
78
|
+
const {
|
|
79
|
+
obj,
|
|
80
|
+
k
|
|
81
|
+
} = getLastOfPath(object, path);
|
|
82
|
+
if (!obj) return undefined;
|
|
83
|
+
return obj[k];
|
|
84
|
+
};
|
|
85
|
+
const getPathWithDefaults = (data, defaultData, key) => {
|
|
86
|
+
const value = getPath(data, key);
|
|
87
|
+
if (value !== undefined) {
|
|
88
|
+
return value;
|
|
89
|
+
}
|
|
90
|
+
return getPath(defaultData, key);
|
|
91
|
+
};
|
|
92
|
+
const deepExtend = (target, source, overwrite) => {
|
|
93
|
+
for (const prop in source) {
|
|
94
|
+
if (prop !== '__proto__' && prop !== 'constructor') {
|
|
95
|
+
if (prop in target) {
|
|
96
|
+
if (isString(target[prop]) || target[prop] instanceof String || isString(source[prop]) || source[prop] instanceof String) {
|
|
97
|
+
if (overwrite) target[prop] = source[prop];
|
|
98
|
+
} else {
|
|
99
|
+
deepExtend(target[prop], source[prop], overwrite);
|
|
100
|
+
}
|
|
101
|
+
} else {
|
|
102
|
+
target[prop] = source[prop];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return target;
|
|
107
|
+
};
|
|
108
|
+
const regexEscape = str => str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
|
109
|
+
var _entityMap = {
|
|
110
|
+
'&': '&',
|
|
111
|
+
'<': '<',
|
|
112
|
+
'>': '>',
|
|
113
|
+
'"': '"',
|
|
114
|
+
"'": ''',
|
|
115
|
+
'/': '/'
|
|
116
|
+
};
|
|
117
|
+
const escape = data => {
|
|
118
|
+
if (isString(data)) {
|
|
119
|
+
return data.replace(/[&<>"'\/]/g, s => _entityMap[s]);
|
|
120
|
+
}
|
|
121
|
+
return data;
|
|
122
|
+
};
|
|
123
|
+
class RegExpCache {
|
|
124
|
+
constructor(capacity) {
|
|
125
|
+
this.capacity = capacity;
|
|
126
|
+
this.regExpMap = new Map();
|
|
127
|
+
this.regExpQueue = [];
|
|
128
|
+
}
|
|
129
|
+
getRegExp(pattern) {
|
|
130
|
+
const regExpFromCache = this.regExpMap.get(pattern);
|
|
131
|
+
if (regExpFromCache !== undefined) {
|
|
132
|
+
return regExpFromCache;
|
|
133
|
+
}
|
|
134
|
+
const regExpNew = new RegExp(pattern);
|
|
135
|
+
if (this.regExpQueue.length === this.capacity) {
|
|
136
|
+
this.regExpMap.delete(this.regExpQueue.shift());
|
|
137
|
+
}
|
|
138
|
+
this.regExpMap.set(pattern, regExpNew);
|
|
139
|
+
this.regExpQueue.push(pattern);
|
|
140
|
+
return regExpNew;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const chars = [' ', ',', '?', '!', ';'];
|
|
144
|
+
const looksLikeObjectPathRegExpCache = new RegExpCache(20);
|
|
145
|
+
const looksLikeObjectPath = (key, nsSeparator, keySeparator) => {
|
|
146
|
+
nsSeparator = nsSeparator || '';
|
|
147
|
+
keySeparator = keySeparator || '';
|
|
148
|
+
const possibleChars = chars.filter(c => nsSeparator.indexOf(c) < 0 && keySeparator.indexOf(c) < 0);
|
|
149
|
+
if (possibleChars.length === 0) return true;
|
|
150
|
+
const r = looksLikeObjectPathRegExpCache.getRegExp(`(${possibleChars.map(c => c === '?' ? '\\?' : c).join('|')})`);
|
|
151
|
+
let matched = !r.test(key);
|
|
152
|
+
if (!matched) {
|
|
153
|
+
const ki = key.indexOf(keySeparator);
|
|
154
|
+
if (ki > 0 && !r.test(key.substring(0, ki))) {
|
|
155
|
+
matched = true;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return matched;
|
|
159
|
+
};
|
|
160
|
+
const deepFind = function (obj, path) {
|
|
161
|
+
let keySeparator = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '.';
|
|
162
|
+
if (!obj) return undefined;
|
|
163
|
+
if (obj[path]) return obj[path];
|
|
164
|
+
const tokens = path.split(keySeparator);
|
|
165
|
+
let current = obj;
|
|
166
|
+
for (let i = 0; i < tokens.length;) {
|
|
167
|
+
if (!current || typeof current !== 'object') {
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
let next;
|
|
171
|
+
let nextPath = '';
|
|
172
|
+
for (let j = i; j < tokens.length; ++j) {
|
|
173
|
+
if (j !== i) {
|
|
174
|
+
nextPath += keySeparator;
|
|
175
|
+
}
|
|
176
|
+
nextPath += tokens[j];
|
|
177
|
+
next = current[nextPath];
|
|
178
|
+
if (next !== undefined) {
|
|
179
|
+
if (['string', 'number', 'boolean'].indexOf(typeof next) > -1 && j < tokens.length - 1) {
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
i += j - i + 1;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
current = next;
|
|
187
|
+
}
|
|
188
|
+
return current;
|
|
189
|
+
};
|
|
190
|
+
const getCleanedCode = code => code && code.replace('_', '-');
|
|
191
|
+
|
|
192
|
+
const consoleLogger = {
|
|
193
|
+
type: 'logger',
|
|
194
|
+
log(args) {
|
|
195
|
+
this.output('log', args);
|
|
196
|
+
},
|
|
197
|
+
warn(args) {
|
|
198
|
+
this.output('warn', args);
|
|
199
|
+
},
|
|
200
|
+
error(args) {
|
|
201
|
+
this.output('error', args);
|
|
202
|
+
},
|
|
203
|
+
output(type, args) {
|
|
204
|
+
if (console && console[type]) console[type].apply(console, args);
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
class Logger {
|
|
208
|
+
constructor(concreteLogger) {
|
|
209
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
210
|
+
this.init(concreteLogger, options);
|
|
211
|
+
}
|
|
212
|
+
init(concreteLogger) {
|
|
213
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
214
|
+
this.prefix = options.prefix || 'i18next:';
|
|
215
|
+
this.logger = concreteLogger || consoleLogger;
|
|
216
|
+
this.options = options;
|
|
217
|
+
this.debug = options.debug;
|
|
218
|
+
}
|
|
219
|
+
log() {
|
|
220
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
221
|
+
args[_key] = arguments[_key];
|
|
222
|
+
}
|
|
223
|
+
return this.forward(args, 'log', '', true);
|
|
224
|
+
}
|
|
225
|
+
warn() {
|
|
226
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
227
|
+
args[_key2] = arguments[_key2];
|
|
228
|
+
}
|
|
229
|
+
return this.forward(args, 'warn', '', true);
|
|
230
|
+
}
|
|
231
|
+
error() {
|
|
232
|
+
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
233
|
+
args[_key3] = arguments[_key3];
|
|
234
|
+
}
|
|
235
|
+
return this.forward(args, 'error', '');
|
|
236
|
+
}
|
|
237
|
+
deprecate() {
|
|
238
|
+
for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
239
|
+
args[_key4] = arguments[_key4];
|
|
240
|
+
}
|
|
241
|
+
return this.forward(args, 'warn', 'WARNING DEPRECATED: ', true);
|
|
242
|
+
}
|
|
243
|
+
forward(args, lvl, prefix, debugOnly) {
|
|
244
|
+
if (debugOnly && !this.debug) return null;
|
|
245
|
+
if (isString(args[0])) args[0] = `${prefix}${this.prefix} ${args[0]}`;
|
|
246
|
+
return this.logger[lvl](args);
|
|
247
|
+
}
|
|
248
|
+
create(moduleName) {
|
|
249
|
+
return new Logger(this.logger, {
|
|
250
|
+
...{
|
|
251
|
+
prefix: `${this.prefix}:${moduleName}:`
|
|
252
|
+
},
|
|
253
|
+
...this.options
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
clone(options) {
|
|
257
|
+
options = options || this.options;
|
|
258
|
+
options.prefix = options.prefix || this.prefix;
|
|
259
|
+
return new Logger(this.logger, options);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
var baseLogger = new Logger();
|
|
263
|
+
|
|
264
|
+
class EventEmitter {
|
|
265
|
+
constructor() {
|
|
266
|
+
this.observers = {};
|
|
267
|
+
}
|
|
268
|
+
on(events, listener) {
|
|
269
|
+
events.split(' ').forEach(event => {
|
|
270
|
+
if (!this.observers[event]) this.observers[event] = new Map();
|
|
271
|
+
const numListeners = this.observers[event].get(listener) || 0;
|
|
272
|
+
this.observers[event].set(listener, numListeners + 1);
|
|
273
|
+
});
|
|
274
|
+
return this;
|
|
275
|
+
}
|
|
276
|
+
off(event, listener) {
|
|
277
|
+
if (!this.observers[event]) return;
|
|
278
|
+
if (!listener) {
|
|
279
|
+
delete this.observers[event];
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
this.observers[event].delete(listener);
|
|
283
|
+
}
|
|
284
|
+
emit(event) {
|
|
285
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
286
|
+
args[_key - 1] = arguments[_key];
|
|
287
|
+
}
|
|
288
|
+
if (this.observers[event]) {
|
|
289
|
+
const cloned = Array.from(this.observers[event].entries());
|
|
290
|
+
cloned.forEach(_ref => {
|
|
291
|
+
let [observer, numTimesAdded] = _ref;
|
|
292
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
|
293
|
+
observer(...args);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
if (this.observers['*']) {
|
|
298
|
+
const cloned = Array.from(this.observers['*'].entries());
|
|
299
|
+
cloned.forEach(_ref2 => {
|
|
300
|
+
let [observer, numTimesAdded] = _ref2;
|
|
301
|
+
for (let i = 0; i < numTimesAdded; i++) {
|
|
302
|
+
observer.apply(observer, [event, ...args]);
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
class ResourceStore extends EventEmitter {
|
|
310
|
+
constructor(data) {
|
|
311
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
312
|
+
ns: ['translation'],
|
|
313
|
+
defaultNS: 'translation'
|
|
314
|
+
};
|
|
315
|
+
super();
|
|
316
|
+
this.data = data || {};
|
|
317
|
+
this.options = options;
|
|
318
|
+
if (this.options.keySeparator === undefined) {
|
|
319
|
+
this.options.keySeparator = '.';
|
|
320
|
+
}
|
|
321
|
+
if (this.options.ignoreJSONStructure === undefined) {
|
|
322
|
+
this.options.ignoreJSONStructure = true;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
addNamespaces(ns) {
|
|
326
|
+
if (this.options.ns.indexOf(ns) < 0) {
|
|
327
|
+
this.options.ns.push(ns);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
removeNamespaces(ns) {
|
|
331
|
+
const index = this.options.ns.indexOf(ns);
|
|
332
|
+
if (index > -1) {
|
|
333
|
+
this.options.ns.splice(index, 1);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
getResource(lng, ns, key) {
|
|
337
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
338
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
339
|
+
const ignoreJSONStructure = options.ignoreJSONStructure !== undefined ? options.ignoreJSONStructure : this.options.ignoreJSONStructure;
|
|
340
|
+
let path;
|
|
341
|
+
if (lng.indexOf('.') > -1) {
|
|
342
|
+
path = lng.split('.');
|
|
343
|
+
} else {
|
|
344
|
+
path = [lng, ns];
|
|
345
|
+
if (key) {
|
|
346
|
+
if (Array.isArray(key)) {
|
|
347
|
+
path.push(...key);
|
|
348
|
+
} else if (isString(key) && keySeparator) {
|
|
349
|
+
path.push(...key.split(keySeparator));
|
|
350
|
+
} else {
|
|
351
|
+
path.push(key);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
const result = getPath(this.data, path);
|
|
356
|
+
if (!result && !ns && !key && lng.indexOf('.') > -1) {
|
|
357
|
+
lng = path[0];
|
|
358
|
+
ns = path[1];
|
|
359
|
+
key = path.slice(2).join('.');
|
|
360
|
+
}
|
|
361
|
+
if (result || !ignoreJSONStructure || !isString(key)) return result;
|
|
362
|
+
return deepFind(this.data && this.data[lng] && this.data[lng][ns], key, keySeparator);
|
|
363
|
+
}
|
|
364
|
+
addResource(lng, ns, key, value) {
|
|
365
|
+
let options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
366
|
+
silent: false
|
|
367
|
+
};
|
|
368
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
369
|
+
let path = [lng, ns];
|
|
370
|
+
if (key) path = path.concat(keySeparator ? key.split(keySeparator) : key);
|
|
371
|
+
if (lng.indexOf('.') > -1) {
|
|
372
|
+
path = lng.split('.');
|
|
373
|
+
value = ns;
|
|
374
|
+
ns = path[1];
|
|
375
|
+
}
|
|
376
|
+
this.addNamespaces(ns);
|
|
377
|
+
setPath(this.data, path, value);
|
|
378
|
+
if (!options.silent) this.emit('added', lng, ns, key, value);
|
|
379
|
+
}
|
|
380
|
+
addResources(lng, ns, resources) {
|
|
381
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {
|
|
382
|
+
silent: false
|
|
383
|
+
};
|
|
384
|
+
for (const m in resources) {
|
|
385
|
+
if (isString(resources[m]) || Array.isArray(resources[m])) this.addResource(lng, ns, m, resources[m], {
|
|
386
|
+
silent: true
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
390
|
+
}
|
|
391
|
+
addResourceBundle(lng, ns, resources, deep, overwrite) {
|
|
392
|
+
let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
393
|
+
silent: false,
|
|
394
|
+
skipCopy: false
|
|
395
|
+
};
|
|
396
|
+
let path = [lng, ns];
|
|
397
|
+
if (lng.indexOf('.') > -1) {
|
|
398
|
+
path = lng.split('.');
|
|
399
|
+
deep = resources;
|
|
400
|
+
resources = ns;
|
|
401
|
+
ns = path[1];
|
|
402
|
+
}
|
|
403
|
+
this.addNamespaces(ns);
|
|
404
|
+
let pack = getPath(this.data, path) || {};
|
|
405
|
+
if (!options.skipCopy) resources = JSON.parse(JSON.stringify(resources));
|
|
406
|
+
if (deep) {
|
|
407
|
+
deepExtend(pack, resources, overwrite);
|
|
408
|
+
} else {
|
|
409
|
+
pack = {
|
|
410
|
+
...pack,
|
|
411
|
+
...resources
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
setPath(this.data, path, pack);
|
|
415
|
+
if (!options.silent) this.emit('added', lng, ns, resources);
|
|
416
|
+
}
|
|
417
|
+
removeResourceBundle(lng, ns) {
|
|
418
|
+
if (this.hasResourceBundle(lng, ns)) {
|
|
419
|
+
delete this.data[lng][ns];
|
|
420
|
+
}
|
|
421
|
+
this.removeNamespaces(ns);
|
|
422
|
+
this.emit('removed', lng, ns);
|
|
423
|
+
}
|
|
424
|
+
hasResourceBundle(lng, ns) {
|
|
425
|
+
return this.getResource(lng, ns) !== undefined;
|
|
426
|
+
}
|
|
427
|
+
getResourceBundle(lng, ns) {
|
|
428
|
+
if (!ns) ns = this.options.defaultNS;
|
|
429
|
+
if (this.options.compatibilityAPI === 'v1') return {
|
|
430
|
+
...{},
|
|
431
|
+
...this.getResource(lng, ns)
|
|
432
|
+
};
|
|
433
|
+
return this.getResource(lng, ns);
|
|
434
|
+
}
|
|
435
|
+
getDataByLanguage(lng) {
|
|
436
|
+
return this.data[lng];
|
|
437
|
+
}
|
|
438
|
+
hasLanguageSomeTranslations(lng) {
|
|
439
|
+
const data = this.getDataByLanguage(lng);
|
|
440
|
+
const n = data && Object.keys(data) || [];
|
|
441
|
+
return !!n.find(v => data[v] && Object.keys(data[v]).length > 0);
|
|
442
|
+
}
|
|
443
|
+
toJSON() {
|
|
444
|
+
return this.data;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
var postProcessor = {
|
|
449
|
+
processors: {},
|
|
450
|
+
addPostProcessor(module) {
|
|
451
|
+
this.processors[module.name] = module;
|
|
452
|
+
},
|
|
453
|
+
handle(processors, value, key, options, translator) {
|
|
454
|
+
processors.forEach(processor => {
|
|
455
|
+
if (this.processors[processor]) value = this.processors[processor].process(value, key, options, translator);
|
|
456
|
+
});
|
|
457
|
+
return value;
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
const checkedLoadedFor = {};
|
|
462
|
+
class Translator extends EventEmitter {
|
|
463
|
+
constructor(services) {
|
|
464
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
465
|
+
super();
|
|
466
|
+
copy(['resourceStore', 'languageUtils', 'pluralResolver', 'interpolator', 'backendConnector', 'i18nFormat', 'utils'], services, this);
|
|
467
|
+
this.options = options;
|
|
468
|
+
if (this.options.keySeparator === undefined) {
|
|
469
|
+
this.options.keySeparator = '.';
|
|
470
|
+
}
|
|
471
|
+
this.logger = baseLogger.create('translator');
|
|
472
|
+
}
|
|
473
|
+
changeLanguage(lng) {
|
|
474
|
+
if (lng) this.language = lng;
|
|
475
|
+
}
|
|
476
|
+
exists(key) {
|
|
477
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
478
|
+
interpolation: {}
|
|
479
|
+
};
|
|
480
|
+
if (key === undefined || key === null) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
const resolved = this.resolve(key, options);
|
|
484
|
+
return resolved && resolved.res !== undefined;
|
|
485
|
+
}
|
|
486
|
+
extractFromKey(key, options) {
|
|
487
|
+
let nsSeparator = options.nsSeparator !== undefined ? options.nsSeparator : this.options.nsSeparator;
|
|
488
|
+
if (nsSeparator === undefined) nsSeparator = ':';
|
|
489
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
490
|
+
let namespaces = options.ns || this.options.defaultNS || [];
|
|
491
|
+
const wouldCheckForNsInKey = nsSeparator && key.indexOf(nsSeparator) > -1;
|
|
492
|
+
const seemsNaturalLanguage = !this.options.userDefinedKeySeparator && !options.keySeparator && !this.options.userDefinedNsSeparator && !options.nsSeparator && !looksLikeObjectPath(key, nsSeparator, keySeparator);
|
|
493
|
+
if (wouldCheckForNsInKey && !seemsNaturalLanguage) {
|
|
494
|
+
const m = key.match(this.interpolator.nestingRegexp);
|
|
495
|
+
if (m && m.length > 0) {
|
|
496
|
+
return {
|
|
497
|
+
key,
|
|
498
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
const parts = key.split(nsSeparator);
|
|
502
|
+
if (nsSeparator !== keySeparator || nsSeparator === keySeparator && this.options.ns.indexOf(parts[0]) > -1) namespaces = parts.shift();
|
|
503
|
+
key = parts.join(keySeparator);
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
key,
|
|
507
|
+
namespaces: isString(namespaces) ? [namespaces] : namespaces
|
|
508
|
+
};
|
|
509
|
+
}
|
|
510
|
+
translate(keys, options, lastKey) {
|
|
511
|
+
if (typeof options !== 'object' && this.options.overloadTranslationOptionHandler) {
|
|
512
|
+
options = this.options.overloadTranslationOptionHandler(arguments);
|
|
513
|
+
}
|
|
514
|
+
if (typeof options === 'object') options = {
|
|
515
|
+
...options
|
|
516
|
+
};
|
|
517
|
+
if (!options) options = {};
|
|
518
|
+
if (keys === undefined || keys === null) return '';
|
|
519
|
+
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
520
|
+
const returnDetails = options.returnDetails !== undefined ? options.returnDetails : this.options.returnDetails;
|
|
521
|
+
const keySeparator = options.keySeparator !== undefined ? options.keySeparator : this.options.keySeparator;
|
|
522
|
+
const {
|
|
523
|
+
key,
|
|
524
|
+
namespaces
|
|
525
|
+
} = this.extractFromKey(keys[keys.length - 1], options);
|
|
526
|
+
const namespace = namespaces[namespaces.length - 1];
|
|
527
|
+
const lng = options.lng || this.language;
|
|
528
|
+
const appendNamespaceToCIMode = options.appendNamespaceToCIMode || this.options.appendNamespaceToCIMode;
|
|
529
|
+
if (lng && lng.toLowerCase() === 'cimode') {
|
|
530
|
+
if (appendNamespaceToCIMode) {
|
|
531
|
+
const nsSeparator = options.nsSeparator || this.options.nsSeparator;
|
|
532
|
+
if (returnDetails) {
|
|
533
|
+
return {
|
|
534
|
+
res: `${namespace}${nsSeparator}${key}`,
|
|
535
|
+
usedKey: key,
|
|
536
|
+
exactUsedKey: key,
|
|
537
|
+
usedLng: lng,
|
|
538
|
+
usedNS: namespace,
|
|
539
|
+
usedParams: this.getUsedParamsDetails(options)
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
return `${namespace}${nsSeparator}${key}`;
|
|
543
|
+
}
|
|
544
|
+
if (returnDetails) {
|
|
545
|
+
return {
|
|
546
|
+
res: key,
|
|
547
|
+
usedKey: key,
|
|
548
|
+
exactUsedKey: key,
|
|
549
|
+
usedLng: lng,
|
|
550
|
+
usedNS: namespace,
|
|
551
|
+
usedParams: this.getUsedParamsDetails(options)
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
return key;
|
|
555
|
+
}
|
|
556
|
+
const resolved = this.resolve(keys, options);
|
|
557
|
+
let res = resolved && resolved.res;
|
|
558
|
+
const resUsedKey = resolved && resolved.usedKey || key;
|
|
559
|
+
const resExactUsedKey = resolved && resolved.exactUsedKey || key;
|
|
560
|
+
const resType = Object.prototype.toString.apply(res);
|
|
561
|
+
const noObject = ['[object Number]', '[object Function]', '[object RegExp]'];
|
|
562
|
+
const joinArrays = options.joinArrays !== undefined ? options.joinArrays : this.options.joinArrays;
|
|
563
|
+
const handleAsObjectInI18nFormat = !this.i18nFormat || this.i18nFormat.handleAsObject;
|
|
564
|
+
const handleAsObject = !isString(res) && typeof res !== 'boolean' && typeof res !== 'number';
|
|
565
|
+
if (handleAsObjectInI18nFormat && res && handleAsObject && noObject.indexOf(resType) < 0 && !(isString(joinArrays) && Array.isArray(res))) {
|
|
566
|
+
if (!options.returnObjects && !this.options.returnObjects) {
|
|
567
|
+
if (!this.options.returnedObjectHandler) {
|
|
568
|
+
this.logger.warn('accessing an object - but returnObjects options is not enabled!');
|
|
569
|
+
}
|
|
570
|
+
const r = this.options.returnedObjectHandler ? this.options.returnedObjectHandler(resUsedKey, res, {
|
|
571
|
+
...options,
|
|
572
|
+
ns: namespaces
|
|
573
|
+
}) : `key '${key} (${this.language})' returned an object instead of string.`;
|
|
574
|
+
if (returnDetails) {
|
|
575
|
+
resolved.res = r;
|
|
576
|
+
resolved.usedParams = this.getUsedParamsDetails(options);
|
|
577
|
+
return resolved;
|
|
578
|
+
}
|
|
579
|
+
return r;
|
|
580
|
+
}
|
|
581
|
+
if (keySeparator) {
|
|
582
|
+
const resTypeIsArray = Array.isArray(res);
|
|
583
|
+
const copy = resTypeIsArray ? [] : {};
|
|
584
|
+
const newKeyToUse = resTypeIsArray ? resExactUsedKey : resUsedKey;
|
|
585
|
+
for (const m in res) {
|
|
586
|
+
if (Object.prototype.hasOwnProperty.call(res, m)) {
|
|
587
|
+
const deepKey = `${newKeyToUse}${keySeparator}${m}`;
|
|
588
|
+
copy[m] = this.translate(deepKey, {
|
|
589
|
+
...options,
|
|
590
|
+
...{
|
|
591
|
+
joinArrays: false,
|
|
592
|
+
ns: namespaces
|
|
593
|
+
}
|
|
594
|
+
});
|
|
595
|
+
if (copy[m] === deepKey) copy[m] = res[m];
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
res = copy;
|
|
599
|
+
}
|
|
600
|
+
} else if (handleAsObjectInI18nFormat && isString(joinArrays) && Array.isArray(res)) {
|
|
601
|
+
res = res.join(joinArrays);
|
|
602
|
+
if (res) res = this.extendTranslation(res, keys, options, lastKey);
|
|
603
|
+
} else {
|
|
604
|
+
let usedDefault = false;
|
|
605
|
+
let usedKey = false;
|
|
606
|
+
const needsPluralHandling = options.count !== undefined && !isString(options.count);
|
|
607
|
+
const hasDefaultValue = Translator.hasDefaultValue(options);
|
|
608
|
+
const defaultValueSuffix = needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, options) : '';
|
|
609
|
+
const defaultValueSuffixOrdinalFallback = options.ordinal && needsPluralHandling ? this.pluralResolver.getSuffix(lng, options.count, {
|
|
610
|
+
ordinal: false
|
|
611
|
+
}) : '';
|
|
612
|
+
const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
|
|
613
|
+
const defaultValue = needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] || options[`defaultValue${defaultValueSuffix}`] || options[`defaultValue${defaultValueSuffixOrdinalFallback}`] || options.defaultValue;
|
|
614
|
+
if (!this.isValidLookup(res) && hasDefaultValue) {
|
|
615
|
+
usedDefault = true;
|
|
616
|
+
res = defaultValue;
|
|
617
|
+
}
|
|
618
|
+
if (!this.isValidLookup(res)) {
|
|
619
|
+
usedKey = true;
|
|
620
|
+
res = key;
|
|
621
|
+
}
|
|
622
|
+
const missingKeyNoValueFallbackToKey = options.missingKeyNoValueFallbackToKey || this.options.missingKeyNoValueFallbackToKey;
|
|
623
|
+
const resForMissing = missingKeyNoValueFallbackToKey && usedKey ? undefined : res;
|
|
624
|
+
const updateMissing = hasDefaultValue && defaultValue !== res && this.options.updateMissing;
|
|
625
|
+
if (usedKey || usedDefault || updateMissing) {
|
|
626
|
+
this.logger.log(updateMissing ? 'updateKey' : 'missingKey', lng, namespace, key, updateMissing ? defaultValue : res);
|
|
627
|
+
if (keySeparator) {
|
|
628
|
+
const fk = this.resolve(key, {
|
|
629
|
+
...options,
|
|
630
|
+
keySeparator: false
|
|
631
|
+
});
|
|
632
|
+
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.');
|
|
633
|
+
}
|
|
634
|
+
let lngs = [];
|
|
635
|
+
const fallbackLngs = this.languageUtils.getFallbackCodes(this.options.fallbackLng, options.lng || this.language);
|
|
636
|
+
if (this.options.saveMissingTo === 'fallback' && fallbackLngs && fallbackLngs[0]) {
|
|
637
|
+
for (let i = 0; i < fallbackLngs.length; i++) {
|
|
638
|
+
lngs.push(fallbackLngs[i]);
|
|
639
|
+
}
|
|
640
|
+
} else if (this.options.saveMissingTo === 'all') {
|
|
641
|
+
lngs = this.languageUtils.toResolveHierarchy(options.lng || this.language);
|
|
642
|
+
} else {
|
|
643
|
+
lngs.push(options.lng || this.language);
|
|
644
|
+
}
|
|
645
|
+
const send = (l, k, specificDefaultValue) => {
|
|
646
|
+
const defaultForMissing = hasDefaultValue && specificDefaultValue !== res ? specificDefaultValue : resForMissing;
|
|
647
|
+
if (this.options.missingKeyHandler) {
|
|
648
|
+
this.options.missingKeyHandler(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
649
|
+
} else if (this.backendConnector && this.backendConnector.saveMissing) {
|
|
650
|
+
this.backendConnector.saveMissing(l, namespace, k, defaultForMissing, updateMissing, options);
|
|
651
|
+
}
|
|
652
|
+
this.emit('missingKey', l, namespace, k, res);
|
|
653
|
+
};
|
|
654
|
+
if (this.options.saveMissing) {
|
|
655
|
+
if (this.options.saveMissingPlurals && needsPluralHandling) {
|
|
656
|
+
lngs.forEach(language => {
|
|
657
|
+
const suffixes = this.pluralResolver.getSuffixes(language, options);
|
|
658
|
+
if (needsZeroSuffixLookup && options[`defaultValue${this.options.pluralSeparator}zero`] && suffixes.indexOf(`${this.options.pluralSeparator}zero`) < 0) {
|
|
659
|
+
suffixes.push(`${this.options.pluralSeparator}zero`);
|
|
660
|
+
}
|
|
661
|
+
suffixes.forEach(suffix => {
|
|
662
|
+
send([language], key + suffix, options[`defaultValue${suffix}`] || defaultValue);
|
|
663
|
+
});
|
|
664
|
+
});
|
|
665
|
+
} else {
|
|
666
|
+
send(lngs, key, defaultValue);
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
res = this.extendTranslation(res, keys, options, resolved, lastKey);
|
|
671
|
+
if (usedKey && res === key && this.options.appendNamespaceToMissingKey) res = `${namespace}:${key}`;
|
|
672
|
+
if ((usedKey || usedDefault) && this.options.parseMissingKeyHandler) {
|
|
673
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
674
|
+
res = this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey ? `${namespace}:${key}` : key, usedDefault ? res : undefined);
|
|
675
|
+
} else {
|
|
676
|
+
res = this.options.parseMissingKeyHandler(res);
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (returnDetails) {
|
|
681
|
+
resolved.res = res;
|
|
682
|
+
resolved.usedParams = this.getUsedParamsDetails(options);
|
|
683
|
+
return resolved;
|
|
684
|
+
}
|
|
685
|
+
return res;
|
|
686
|
+
}
|
|
687
|
+
extendTranslation(res, key, options, resolved, lastKey) {
|
|
688
|
+
var _this = this;
|
|
689
|
+
if (this.i18nFormat && this.i18nFormat.parse) {
|
|
690
|
+
res = this.i18nFormat.parse(res, {
|
|
691
|
+
...this.options.interpolation.defaultVariables,
|
|
692
|
+
...options
|
|
693
|
+
}, options.lng || this.language || resolved.usedLng, resolved.usedNS, resolved.usedKey, {
|
|
694
|
+
resolved
|
|
695
|
+
});
|
|
696
|
+
} else if (!options.skipInterpolation) {
|
|
697
|
+
if (options.interpolation) this.interpolator.init({
|
|
698
|
+
...options,
|
|
699
|
+
...{
|
|
700
|
+
interpolation: {
|
|
701
|
+
...this.options.interpolation,
|
|
702
|
+
...options.interpolation
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
});
|
|
706
|
+
const skipOnVariables = isString(res) && (options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables);
|
|
707
|
+
let nestBef;
|
|
708
|
+
if (skipOnVariables) {
|
|
709
|
+
const nb = res.match(this.interpolator.nestingRegexp);
|
|
710
|
+
nestBef = nb && nb.length;
|
|
711
|
+
}
|
|
712
|
+
let data = options.replace && !isString(options.replace) ? options.replace : options;
|
|
713
|
+
if (this.options.interpolation.defaultVariables) data = {
|
|
714
|
+
...this.options.interpolation.defaultVariables,
|
|
715
|
+
...data
|
|
716
|
+
};
|
|
717
|
+
res = this.interpolator.interpolate(res, data, options.lng || this.language || resolved.usedLng, options);
|
|
718
|
+
if (skipOnVariables) {
|
|
719
|
+
const na = res.match(this.interpolator.nestingRegexp);
|
|
720
|
+
const nestAft = na && na.length;
|
|
721
|
+
if (nestBef < nestAft) options.nest = false;
|
|
722
|
+
}
|
|
723
|
+
if (!options.lng && this.options.compatibilityAPI !== 'v1' && resolved && resolved.res) options.lng = this.language || resolved.usedLng;
|
|
724
|
+
if (options.nest !== false) res = this.interpolator.nest(res, function () {
|
|
725
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
726
|
+
args[_key] = arguments[_key];
|
|
727
|
+
}
|
|
728
|
+
if (lastKey && lastKey[0] === args[0] && !options.context) {
|
|
729
|
+
_this.logger.warn(`It seems you are nesting recursively key: ${args[0]} in key: ${key[0]}`);
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
return _this.translate(...args, key);
|
|
733
|
+
}, options);
|
|
734
|
+
if (options.interpolation) this.interpolator.reset();
|
|
735
|
+
}
|
|
736
|
+
const postProcess = options.postProcess || this.options.postProcess;
|
|
737
|
+
const postProcessorNames = isString(postProcess) ? [postProcess] : postProcess;
|
|
738
|
+
if (res !== undefined && res !== null && postProcessorNames && postProcessorNames.length && options.applyPostProcessor !== false) {
|
|
739
|
+
res = postProcessor.handle(postProcessorNames, res, key, this.options && this.options.postProcessPassResolved ? {
|
|
740
|
+
i18nResolved: {
|
|
741
|
+
...resolved,
|
|
742
|
+
usedParams: this.getUsedParamsDetails(options)
|
|
743
|
+
},
|
|
744
|
+
...options
|
|
745
|
+
} : options, this);
|
|
746
|
+
}
|
|
747
|
+
return res;
|
|
748
|
+
}
|
|
749
|
+
resolve(keys) {
|
|
750
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
751
|
+
let found;
|
|
752
|
+
let usedKey;
|
|
753
|
+
let exactUsedKey;
|
|
754
|
+
let usedLng;
|
|
755
|
+
let usedNS;
|
|
756
|
+
if (isString(keys)) keys = [keys];
|
|
757
|
+
keys.forEach(k => {
|
|
758
|
+
if (this.isValidLookup(found)) return;
|
|
759
|
+
const extracted = this.extractFromKey(k, options);
|
|
760
|
+
const key = extracted.key;
|
|
761
|
+
usedKey = key;
|
|
762
|
+
let namespaces = extracted.namespaces;
|
|
763
|
+
if (this.options.fallbackNS) namespaces = namespaces.concat(this.options.fallbackNS);
|
|
764
|
+
const needsPluralHandling = options.count !== undefined && !isString(options.count);
|
|
765
|
+
const needsZeroSuffixLookup = needsPluralHandling && !options.ordinal && options.count === 0 && this.pluralResolver.shouldUseIntlApi();
|
|
766
|
+
const needsContextHandling = options.context !== undefined && (isString(options.context) || typeof options.context === 'number') && options.context !== '';
|
|
767
|
+
const codes = options.lngs ? options.lngs : this.languageUtils.toResolveHierarchy(options.lng || this.language, options.fallbackLng);
|
|
768
|
+
namespaces.forEach(ns => {
|
|
769
|
+
if (this.isValidLookup(found)) return;
|
|
770
|
+
usedNS = ns;
|
|
771
|
+
if (!checkedLoadedFor[`${codes[0]}-${ns}`] && this.utils && this.utils.hasLoadedNamespace && !this.utils.hasLoadedNamespace(usedNS)) {
|
|
772
|
+
checkedLoadedFor[`${codes[0]}-${ns}`] = true;
|
|
773
|
+
this.logger.warn(`key "${usedKey}" for languages "${codes.join(', ')}" won't get resolved as namespace "${usedNS}" 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!!!');
|
|
774
|
+
}
|
|
775
|
+
codes.forEach(code => {
|
|
776
|
+
if (this.isValidLookup(found)) return;
|
|
777
|
+
usedLng = code;
|
|
778
|
+
const finalKeys = [key];
|
|
779
|
+
if (this.i18nFormat && this.i18nFormat.addLookupKeys) {
|
|
780
|
+
this.i18nFormat.addLookupKeys(finalKeys, key, code, ns, options);
|
|
781
|
+
} else {
|
|
782
|
+
let pluralSuffix;
|
|
783
|
+
if (needsPluralHandling) pluralSuffix = this.pluralResolver.getSuffix(code, options.count, options);
|
|
784
|
+
const zeroSuffix = `${this.options.pluralSeparator}zero`;
|
|
785
|
+
const ordinalPrefix = `${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;
|
|
786
|
+
if (needsPluralHandling) {
|
|
787
|
+
finalKeys.push(key + pluralSuffix);
|
|
788
|
+
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
789
|
+
finalKeys.push(key + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
790
|
+
}
|
|
791
|
+
if (needsZeroSuffixLookup) {
|
|
792
|
+
finalKeys.push(key + zeroSuffix);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
if (needsContextHandling) {
|
|
796
|
+
const contextKey = `${key}${this.options.contextSeparator}${options.context}`;
|
|
797
|
+
finalKeys.push(contextKey);
|
|
798
|
+
if (needsPluralHandling) {
|
|
799
|
+
finalKeys.push(contextKey + pluralSuffix);
|
|
800
|
+
if (options.ordinal && pluralSuffix.indexOf(ordinalPrefix) === 0) {
|
|
801
|
+
finalKeys.push(contextKey + pluralSuffix.replace(ordinalPrefix, this.options.pluralSeparator));
|
|
802
|
+
}
|
|
803
|
+
if (needsZeroSuffixLookup) {
|
|
804
|
+
finalKeys.push(contextKey + zeroSuffix);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
let possibleKey;
|
|
810
|
+
while (possibleKey = finalKeys.pop()) {
|
|
811
|
+
if (!this.isValidLookup(found)) {
|
|
812
|
+
exactUsedKey = possibleKey;
|
|
813
|
+
found = this.getResource(code, ns, possibleKey, options);
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
});
|
|
817
|
+
});
|
|
818
|
+
});
|
|
819
|
+
return {
|
|
820
|
+
res: found,
|
|
821
|
+
usedKey,
|
|
822
|
+
exactUsedKey,
|
|
823
|
+
usedLng,
|
|
824
|
+
usedNS
|
|
825
|
+
};
|
|
826
|
+
}
|
|
827
|
+
isValidLookup(res) {
|
|
828
|
+
return res !== undefined && !(!this.options.returnNull && res === null) && !(!this.options.returnEmptyString && res === '');
|
|
829
|
+
}
|
|
830
|
+
getResource(code, ns, key) {
|
|
831
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
832
|
+
if (this.i18nFormat && this.i18nFormat.getResource) return this.i18nFormat.getResource(code, ns, key, options);
|
|
833
|
+
return this.resourceStore.getResource(code, ns, key, options);
|
|
834
|
+
}
|
|
835
|
+
getUsedParamsDetails() {
|
|
836
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
837
|
+
const optionsKeys = ['defaultValue', 'ordinal', 'context', 'replace', 'lng', 'lngs', 'fallbackLng', 'ns', 'keySeparator', 'nsSeparator', 'returnObjects', 'returnDetails', 'joinArrays', 'postProcess', 'interpolation'];
|
|
838
|
+
const useOptionsReplaceForData = options.replace && !isString(options.replace);
|
|
839
|
+
let data = useOptionsReplaceForData ? options.replace : options;
|
|
840
|
+
if (useOptionsReplaceForData && typeof options.count !== 'undefined') {
|
|
841
|
+
data.count = options.count;
|
|
842
|
+
}
|
|
843
|
+
if (this.options.interpolation.defaultVariables) {
|
|
844
|
+
data = {
|
|
845
|
+
...this.options.interpolation.defaultVariables,
|
|
846
|
+
...data
|
|
847
|
+
};
|
|
848
|
+
}
|
|
849
|
+
if (!useOptionsReplaceForData) {
|
|
850
|
+
data = {
|
|
851
|
+
...data
|
|
852
|
+
};
|
|
853
|
+
for (const key of optionsKeys) {
|
|
854
|
+
delete data[key];
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
return data;
|
|
858
|
+
}
|
|
859
|
+
static hasDefaultValue(options) {
|
|
860
|
+
const prefix = 'defaultValue';
|
|
861
|
+
for (const option in options) {
|
|
862
|
+
if (Object.prototype.hasOwnProperty.call(options, option) && prefix === option.substring(0, prefix.length) && undefined !== options[option]) {
|
|
863
|
+
return true;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1);
|
|
871
|
+
class LanguageUtil {
|
|
872
|
+
constructor(options) {
|
|
873
|
+
this.options = options;
|
|
874
|
+
this.supportedLngs = this.options.supportedLngs || false;
|
|
875
|
+
this.logger = baseLogger.create('languageUtils');
|
|
876
|
+
}
|
|
877
|
+
getScriptPartFromCode(code) {
|
|
878
|
+
code = getCleanedCode(code);
|
|
879
|
+
if (!code || code.indexOf('-') < 0) return null;
|
|
880
|
+
const p = code.split('-');
|
|
881
|
+
if (p.length === 2) return null;
|
|
882
|
+
p.pop();
|
|
883
|
+
if (p[p.length - 1].toLowerCase() === 'x') return null;
|
|
884
|
+
return this.formatLanguageCode(p.join('-'));
|
|
885
|
+
}
|
|
886
|
+
getLanguagePartFromCode(code) {
|
|
887
|
+
code = getCleanedCode(code);
|
|
888
|
+
if (!code || code.indexOf('-') < 0) return code;
|
|
889
|
+
const p = code.split('-');
|
|
890
|
+
return this.formatLanguageCode(p[0]);
|
|
891
|
+
}
|
|
892
|
+
formatLanguageCode(code) {
|
|
893
|
+
if (isString(code) && code.indexOf('-') > -1) {
|
|
894
|
+
if (typeof Intl !== 'undefined' && typeof Intl.getCanonicalLocales !== 'undefined') {
|
|
895
|
+
try {
|
|
896
|
+
let formattedCode = Intl.getCanonicalLocales(code)[0];
|
|
897
|
+
if (formattedCode && this.options.lowerCaseLng) {
|
|
898
|
+
formattedCode = formattedCode.toLowerCase();
|
|
899
|
+
}
|
|
900
|
+
if (formattedCode) return formattedCode;
|
|
901
|
+
} catch (e) {}
|
|
902
|
+
}
|
|
903
|
+
const specialCases = ['hans', 'hant', 'latn', 'cyrl', 'cans', 'mong', 'arab'];
|
|
904
|
+
let p = code.split('-');
|
|
905
|
+
if (this.options.lowerCaseLng) {
|
|
906
|
+
p = p.map(part => part.toLowerCase());
|
|
907
|
+
} else if (p.length === 2) {
|
|
908
|
+
p[0] = p[0].toLowerCase();
|
|
909
|
+
p[1] = p[1].toUpperCase();
|
|
910
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
911
|
+
} else if (p.length === 3) {
|
|
912
|
+
p[0] = p[0].toLowerCase();
|
|
913
|
+
if (p[1].length === 2) p[1] = p[1].toUpperCase();
|
|
914
|
+
if (p[0] !== 'sgn' && p[2].length === 2) p[2] = p[2].toUpperCase();
|
|
915
|
+
if (specialCases.indexOf(p[1].toLowerCase()) > -1) p[1] = capitalize(p[1].toLowerCase());
|
|
916
|
+
if (specialCases.indexOf(p[2].toLowerCase()) > -1) p[2] = capitalize(p[2].toLowerCase());
|
|
917
|
+
}
|
|
918
|
+
return p.join('-');
|
|
919
|
+
}
|
|
920
|
+
return this.options.cleanCode || this.options.lowerCaseLng ? code.toLowerCase() : code;
|
|
921
|
+
}
|
|
922
|
+
isSupportedCode(code) {
|
|
923
|
+
if (this.options.load === 'languageOnly' || this.options.nonExplicitSupportedLngs) {
|
|
924
|
+
code = this.getLanguagePartFromCode(code);
|
|
925
|
+
}
|
|
926
|
+
return !this.supportedLngs || !this.supportedLngs.length || this.supportedLngs.indexOf(code) > -1;
|
|
927
|
+
}
|
|
928
|
+
getBestMatchFromCodes(codes) {
|
|
929
|
+
if (!codes) return null;
|
|
930
|
+
let found;
|
|
931
|
+
codes.forEach(code => {
|
|
932
|
+
if (found) return;
|
|
933
|
+
const cleanedLng = this.formatLanguageCode(code);
|
|
934
|
+
if (!this.options.supportedLngs || this.isSupportedCode(cleanedLng)) found = cleanedLng;
|
|
935
|
+
});
|
|
936
|
+
if (!found && this.options.supportedLngs) {
|
|
937
|
+
codes.forEach(code => {
|
|
938
|
+
if (found) return;
|
|
939
|
+
const lngOnly = this.getLanguagePartFromCode(code);
|
|
940
|
+
if (this.isSupportedCode(lngOnly)) return found = lngOnly;
|
|
941
|
+
found = this.options.supportedLngs.find(supportedLng => {
|
|
942
|
+
if (supportedLng === lngOnly) return supportedLng;
|
|
943
|
+
if (supportedLng.indexOf('-') < 0 && lngOnly.indexOf('-') < 0) return;
|
|
944
|
+
if (supportedLng.indexOf('-') > 0 && lngOnly.indexOf('-') < 0 && supportedLng.substring(0, supportedLng.indexOf('-')) === lngOnly) return supportedLng;
|
|
945
|
+
if (supportedLng.indexOf(lngOnly) === 0 && lngOnly.length > 1) return supportedLng;
|
|
946
|
+
});
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
if (!found) found = this.getFallbackCodes(this.options.fallbackLng)[0];
|
|
950
|
+
return found;
|
|
951
|
+
}
|
|
952
|
+
getFallbackCodes(fallbacks, code) {
|
|
953
|
+
if (!fallbacks) return [];
|
|
954
|
+
if (typeof fallbacks === 'function') fallbacks = fallbacks(code);
|
|
955
|
+
if (isString(fallbacks)) fallbacks = [fallbacks];
|
|
956
|
+
if (Array.isArray(fallbacks)) return fallbacks;
|
|
957
|
+
if (!code) return fallbacks.default || [];
|
|
958
|
+
let found = fallbacks[code];
|
|
959
|
+
if (!found) found = fallbacks[this.getScriptPartFromCode(code)];
|
|
960
|
+
if (!found) found = fallbacks[this.formatLanguageCode(code)];
|
|
961
|
+
if (!found) found = fallbacks[this.getLanguagePartFromCode(code)];
|
|
962
|
+
if (!found) found = fallbacks.default;
|
|
963
|
+
return found || [];
|
|
964
|
+
}
|
|
965
|
+
toResolveHierarchy(code, fallbackCode) {
|
|
966
|
+
const fallbackCodes = this.getFallbackCodes(fallbackCode || this.options.fallbackLng || [], code);
|
|
967
|
+
const codes = [];
|
|
968
|
+
const addCode = c => {
|
|
969
|
+
if (!c) return;
|
|
970
|
+
if (this.isSupportedCode(c)) {
|
|
971
|
+
codes.push(c);
|
|
972
|
+
} else {
|
|
973
|
+
this.logger.warn(`rejecting language code not found in supportedLngs: ${c}`);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
if (isString(code) && (code.indexOf('-') > -1 || code.indexOf('_') > -1)) {
|
|
977
|
+
if (this.options.load !== 'languageOnly') addCode(this.formatLanguageCode(code));
|
|
978
|
+
if (this.options.load !== 'languageOnly' && this.options.load !== 'currentOnly') addCode(this.getScriptPartFromCode(code));
|
|
979
|
+
if (this.options.load !== 'currentOnly') addCode(this.getLanguagePartFromCode(code));
|
|
980
|
+
} else if (isString(code)) {
|
|
981
|
+
addCode(this.formatLanguageCode(code));
|
|
982
|
+
}
|
|
983
|
+
fallbackCodes.forEach(fc => {
|
|
984
|
+
if (codes.indexOf(fc) < 0) addCode(this.formatLanguageCode(fc));
|
|
985
|
+
});
|
|
986
|
+
return codes;
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
let sets = [{
|
|
991
|
+
lngs: ['ach', 'ak', 'am', 'arn', 'br', 'fil', 'gun', 'ln', 'mfe', 'mg', 'mi', 'oc', 'pt', 'pt-BR', 'tg', 'tl', 'ti', 'tr', 'uz', 'wa'],
|
|
992
|
+
nr: [1, 2],
|
|
993
|
+
fc: 1
|
|
994
|
+
}, {
|
|
995
|
+
lngs: ['af', 'an', 'ast', 'az', 'bg', 'bn', 'ca', 'da', 'de', 'dev', 'el', 'en', 'eo', 'es', 'et', 'eu', 'fi', 'fo', 'fur', 'fy', 'gl', 'gu', 'ha', 'hi', 'hu', 'hy', 'ia', 'it', 'kk', 'kn', 'ku', 'lb', 'mai', 'ml', 'mn', 'mr', 'nah', 'nap', 'nb', 'ne', 'nl', 'nn', 'no', 'nso', 'pa', 'pap', 'pms', 'ps', 'pt-PT', 'rm', 'sco', 'se', 'si', 'so', 'son', 'sq', 'sv', 'sw', 'ta', 'te', 'tk', 'ur', 'yo'],
|
|
996
|
+
nr: [1, 2],
|
|
997
|
+
fc: 2
|
|
998
|
+
}, {
|
|
999
|
+
lngs: ['ay', 'bo', 'cgg', 'fa', 'ht', 'id', 'ja', 'jbo', 'ka', 'km', 'ko', 'ky', 'lo', 'ms', 'sah', 'su', 'th', 'tt', 'ug', 'vi', 'wo', 'zh'],
|
|
1000
|
+
nr: [1],
|
|
1001
|
+
fc: 3
|
|
1002
|
+
}, {
|
|
1003
|
+
lngs: ['be', 'bs', 'cnr', 'dz', 'hr', 'ru', 'sr', 'uk'],
|
|
1004
|
+
nr: [1, 2, 5],
|
|
1005
|
+
fc: 4
|
|
1006
|
+
}, {
|
|
1007
|
+
lngs: ['ar'],
|
|
1008
|
+
nr: [0, 1, 2, 3, 11, 100],
|
|
1009
|
+
fc: 5
|
|
1010
|
+
}, {
|
|
1011
|
+
lngs: ['cs', 'sk'],
|
|
1012
|
+
nr: [1, 2, 5],
|
|
1013
|
+
fc: 6
|
|
1014
|
+
}, {
|
|
1015
|
+
lngs: ['csb', 'pl'],
|
|
1016
|
+
nr: [1, 2, 5],
|
|
1017
|
+
fc: 7
|
|
1018
|
+
}, {
|
|
1019
|
+
lngs: ['cy'],
|
|
1020
|
+
nr: [1, 2, 3, 8],
|
|
1021
|
+
fc: 8
|
|
1022
|
+
}, {
|
|
1023
|
+
lngs: ['fr'],
|
|
1024
|
+
nr: [1, 2],
|
|
1025
|
+
fc: 9
|
|
1026
|
+
}, {
|
|
1027
|
+
lngs: ['ga'],
|
|
1028
|
+
nr: [1, 2, 3, 7, 11],
|
|
1029
|
+
fc: 10
|
|
1030
|
+
}, {
|
|
1031
|
+
lngs: ['gd'],
|
|
1032
|
+
nr: [1, 2, 3, 20],
|
|
1033
|
+
fc: 11
|
|
1034
|
+
}, {
|
|
1035
|
+
lngs: ['is'],
|
|
1036
|
+
nr: [1, 2],
|
|
1037
|
+
fc: 12
|
|
1038
|
+
}, {
|
|
1039
|
+
lngs: ['jv'],
|
|
1040
|
+
nr: [0, 1],
|
|
1041
|
+
fc: 13
|
|
1042
|
+
}, {
|
|
1043
|
+
lngs: ['kw'],
|
|
1044
|
+
nr: [1, 2, 3, 4],
|
|
1045
|
+
fc: 14
|
|
1046
|
+
}, {
|
|
1047
|
+
lngs: ['lt'],
|
|
1048
|
+
nr: [1, 2, 10],
|
|
1049
|
+
fc: 15
|
|
1050
|
+
}, {
|
|
1051
|
+
lngs: ['lv'],
|
|
1052
|
+
nr: [1, 2, 0],
|
|
1053
|
+
fc: 16
|
|
1054
|
+
}, {
|
|
1055
|
+
lngs: ['mk'],
|
|
1056
|
+
nr: [1, 2],
|
|
1057
|
+
fc: 17
|
|
1058
|
+
}, {
|
|
1059
|
+
lngs: ['mnk'],
|
|
1060
|
+
nr: [0, 1, 2],
|
|
1061
|
+
fc: 18
|
|
1062
|
+
}, {
|
|
1063
|
+
lngs: ['mt'],
|
|
1064
|
+
nr: [1, 2, 11, 20],
|
|
1065
|
+
fc: 19
|
|
1066
|
+
}, {
|
|
1067
|
+
lngs: ['or'],
|
|
1068
|
+
nr: [2, 1],
|
|
1069
|
+
fc: 2
|
|
1070
|
+
}, {
|
|
1071
|
+
lngs: ['ro'],
|
|
1072
|
+
nr: [1, 2, 20],
|
|
1073
|
+
fc: 20
|
|
1074
|
+
}, {
|
|
1075
|
+
lngs: ['sl'],
|
|
1076
|
+
nr: [5, 1, 2, 3],
|
|
1077
|
+
fc: 21
|
|
1078
|
+
}, {
|
|
1079
|
+
lngs: ['he', 'iw'],
|
|
1080
|
+
nr: [1, 2, 20, 21],
|
|
1081
|
+
fc: 22
|
|
1082
|
+
}];
|
|
1083
|
+
let _rulesPluralsTypes = {
|
|
1084
|
+
1: n => Number(n > 1),
|
|
1085
|
+
2: n => Number(n != 1),
|
|
1086
|
+
3: n => 0,
|
|
1087
|
+
4: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
1088
|
+
5: n => Number(n == 0 ? 0 : n == 1 ? 1 : n == 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5),
|
|
1089
|
+
6: n => Number(n == 1 ? 0 : n >= 2 && n <= 4 ? 1 : 2),
|
|
1090
|
+
7: n => Number(n == 1 ? 0 : n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
1091
|
+
8: n => Number(n == 1 ? 0 : n == 2 ? 1 : n != 8 && n != 11 ? 2 : 3),
|
|
1092
|
+
9: n => Number(n >= 2),
|
|
1093
|
+
10: n => Number(n == 1 ? 0 : n == 2 ? 1 : n < 7 ? 2 : n < 11 ? 3 : 4),
|
|
1094
|
+
11: n => Number(n == 1 || n == 11 ? 0 : n == 2 || n == 12 ? 1 : n > 2 && n < 20 ? 2 : 3),
|
|
1095
|
+
12: n => Number(n % 10 != 1 || n % 100 == 11),
|
|
1096
|
+
13: n => Number(n !== 0),
|
|
1097
|
+
14: n => Number(n == 1 ? 0 : n == 2 ? 1 : n == 3 ? 2 : 3),
|
|
1098
|
+
15: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2),
|
|
1099
|
+
16: n => Number(n % 10 == 1 && n % 100 != 11 ? 0 : n !== 0 ? 1 : 2),
|
|
1100
|
+
17: n => Number(n == 1 || n % 10 == 1 && n % 100 != 11 ? 0 : 1),
|
|
1101
|
+
18: n => Number(n == 0 ? 0 : n == 1 ? 1 : 2),
|
|
1102
|
+
19: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 1 && n % 100 < 11 ? 1 : n % 100 > 10 && n % 100 < 20 ? 2 : 3),
|
|
1103
|
+
20: n => Number(n == 1 ? 0 : n == 0 || n % 100 > 0 && n % 100 < 20 ? 1 : 2),
|
|
1104
|
+
21: n => Number(n % 100 == 1 ? 1 : n % 100 == 2 ? 2 : n % 100 == 3 || n % 100 == 4 ? 3 : 0),
|
|
1105
|
+
22: n => Number(n == 1 ? 0 : n == 2 ? 1 : (n < 0 || n > 10) && n % 10 == 0 ? 2 : 3)
|
|
1106
|
+
};
|
|
1107
|
+
const nonIntlVersions = ['v1', 'v2', 'v3'];
|
|
1108
|
+
const intlVersions = ['v4'];
|
|
1109
|
+
const suffixesOrder = {
|
|
1110
|
+
zero: 0,
|
|
1111
|
+
one: 1,
|
|
1112
|
+
two: 2,
|
|
1113
|
+
few: 3,
|
|
1114
|
+
many: 4,
|
|
1115
|
+
other: 5
|
|
1116
|
+
};
|
|
1117
|
+
const createRules = () => {
|
|
1118
|
+
const rules = {};
|
|
1119
|
+
sets.forEach(set => {
|
|
1120
|
+
set.lngs.forEach(l => {
|
|
1121
|
+
rules[l] = {
|
|
1122
|
+
numbers: set.nr,
|
|
1123
|
+
plurals: _rulesPluralsTypes[set.fc]
|
|
1124
|
+
};
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
return rules;
|
|
1128
|
+
};
|
|
1129
|
+
class PluralResolver {
|
|
1130
|
+
constructor(languageUtils) {
|
|
1131
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1132
|
+
this.languageUtils = languageUtils;
|
|
1133
|
+
this.options = options;
|
|
1134
|
+
this.logger = baseLogger.create('pluralResolver');
|
|
1135
|
+
if ((!this.options.compatibilityJSON || intlVersions.includes(this.options.compatibilityJSON)) && (typeof Intl === 'undefined' || !Intl.PluralRules)) {
|
|
1136
|
+
this.options.compatibilityJSON = 'v3';
|
|
1137
|
+
this.logger.error('Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.');
|
|
1138
|
+
}
|
|
1139
|
+
this.rules = createRules();
|
|
1140
|
+
this.pluralRulesCache = {};
|
|
1141
|
+
}
|
|
1142
|
+
addRule(lng, obj) {
|
|
1143
|
+
this.rules[lng] = obj;
|
|
1144
|
+
}
|
|
1145
|
+
clearCache() {
|
|
1146
|
+
this.pluralRulesCache = {};
|
|
1147
|
+
}
|
|
1148
|
+
getRule(code) {
|
|
1149
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1150
|
+
if (this.shouldUseIntlApi()) {
|
|
1151
|
+
const cleanedCode = getCleanedCode(code === 'dev' ? 'en' : code);
|
|
1152
|
+
const type = options.ordinal ? 'ordinal' : 'cardinal';
|
|
1153
|
+
const cacheKey = JSON.stringify({
|
|
1154
|
+
cleanedCode,
|
|
1155
|
+
type
|
|
1156
|
+
});
|
|
1157
|
+
if (cacheKey in this.pluralRulesCache) {
|
|
1158
|
+
return this.pluralRulesCache[cacheKey];
|
|
1159
|
+
}
|
|
1160
|
+
let rule;
|
|
1161
|
+
try {
|
|
1162
|
+
rule = new Intl.PluralRules(cleanedCode, {
|
|
1163
|
+
type
|
|
1164
|
+
});
|
|
1165
|
+
} catch (err) {
|
|
1166
|
+
if (!code.match(/-|_/)) return;
|
|
1167
|
+
const lngPart = this.languageUtils.getLanguagePartFromCode(code);
|
|
1168
|
+
rule = this.getRule(lngPart, options);
|
|
1169
|
+
}
|
|
1170
|
+
this.pluralRulesCache[cacheKey] = rule;
|
|
1171
|
+
return rule;
|
|
1172
|
+
}
|
|
1173
|
+
return this.rules[code] || this.rules[this.languageUtils.getLanguagePartFromCode(code)];
|
|
1174
|
+
}
|
|
1175
|
+
needsPlural(code) {
|
|
1176
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1177
|
+
const rule = this.getRule(code, options);
|
|
1178
|
+
if (this.shouldUseIntlApi()) {
|
|
1179
|
+
return rule && rule.resolvedOptions().pluralCategories.length > 1;
|
|
1180
|
+
}
|
|
1181
|
+
return rule && rule.numbers.length > 1;
|
|
1182
|
+
}
|
|
1183
|
+
getPluralFormsOfKey(code, key) {
|
|
1184
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1185
|
+
return this.getSuffixes(code, options).map(suffix => `${key}${suffix}`);
|
|
1186
|
+
}
|
|
1187
|
+
getSuffixes(code) {
|
|
1188
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1189
|
+
const rule = this.getRule(code, options);
|
|
1190
|
+
if (!rule) {
|
|
1191
|
+
return [];
|
|
1192
|
+
}
|
|
1193
|
+
if (this.shouldUseIntlApi()) {
|
|
1194
|
+
return rule.resolvedOptions().pluralCategories.sort((pluralCategory1, pluralCategory2) => suffixesOrder[pluralCategory1] - suffixesOrder[pluralCategory2]).map(pluralCategory => `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${pluralCategory}`);
|
|
1195
|
+
}
|
|
1196
|
+
return rule.numbers.map(number => this.getSuffix(code, number, options));
|
|
1197
|
+
}
|
|
1198
|
+
getSuffix(code, count) {
|
|
1199
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1200
|
+
const rule = this.getRule(code, options);
|
|
1201
|
+
if (rule) {
|
|
1202
|
+
if (this.shouldUseIntlApi()) {
|
|
1203
|
+
return `${this.options.prepend}${options.ordinal ? `ordinal${this.options.prepend}` : ''}${rule.select(count)}`;
|
|
1204
|
+
}
|
|
1205
|
+
return this.getSuffixRetroCompatible(rule, count);
|
|
1206
|
+
}
|
|
1207
|
+
this.logger.warn(`no plural rule found for: ${code}`);
|
|
1208
|
+
return '';
|
|
1209
|
+
}
|
|
1210
|
+
getSuffixRetroCompatible(rule, count) {
|
|
1211
|
+
const idx = rule.noAbs ? rule.plurals(count) : rule.plurals(Math.abs(count));
|
|
1212
|
+
let suffix = rule.numbers[idx];
|
|
1213
|
+
if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1214
|
+
if (suffix === 2) {
|
|
1215
|
+
suffix = 'plural';
|
|
1216
|
+
} else if (suffix === 1) {
|
|
1217
|
+
suffix = '';
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
const returnSuffix = () => this.options.prepend && suffix.toString() ? this.options.prepend + suffix.toString() : suffix.toString();
|
|
1221
|
+
if (this.options.compatibilityJSON === 'v1') {
|
|
1222
|
+
if (suffix === 1) return '';
|
|
1223
|
+
if (typeof suffix === 'number') return `_plural_${suffix.toString()}`;
|
|
1224
|
+
return returnSuffix();
|
|
1225
|
+
} else if (this.options.compatibilityJSON === 'v2') {
|
|
1226
|
+
return returnSuffix();
|
|
1227
|
+
} else if (this.options.simplifyPluralSuffix && rule.numbers.length === 2 && rule.numbers[0] === 1) {
|
|
1228
|
+
return returnSuffix();
|
|
1229
|
+
}
|
|
1230
|
+
return this.options.prepend && idx.toString() ? this.options.prepend + idx.toString() : idx.toString();
|
|
1231
|
+
}
|
|
1232
|
+
shouldUseIntlApi() {
|
|
1233
|
+
return !nonIntlVersions.includes(this.options.compatibilityJSON);
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
const deepFindWithDefaults = function (data, defaultData, key) {
|
|
1238
|
+
let keySeparator = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '.';
|
|
1239
|
+
let ignoreJSONStructure = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
1240
|
+
let path = getPathWithDefaults(data, defaultData, key);
|
|
1241
|
+
if (!path && ignoreJSONStructure && isString(key)) {
|
|
1242
|
+
path = deepFind(data, key, keySeparator);
|
|
1243
|
+
if (path === undefined) path = deepFind(defaultData, key, keySeparator);
|
|
1244
|
+
}
|
|
1245
|
+
return path;
|
|
1246
|
+
};
|
|
1247
|
+
const regexSafe = val => val.replace(/\$/g, '$$$$');
|
|
1248
|
+
class Interpolator {
|
|
1249
|
+
constructor() {
|
|
1250
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1251
|
+
this.logger = baseLogger.create('interpolator');
|
|
1252
|
+
this.options = options;
|
|
1253
|
+
this.format = options.interpolation && options.interpolation.format || (value => value);
|
|
1254
|
+
this.init(options);
|
|
1255
|
+
}
|
|
1256
|
+
init() {
|
|
1257
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1258
|
+
if (!options.interpolation) options.interpolation = {
|
|
1259
|
+
escapeValue: true
|
|
1260
|
+
};
|
|
1261
|
+
const {
|
|
1262
|
+
escape: escape$1,
|
|
1263
|
+
escapeValue,
|
|
1264
|
+
useRawValueToEscape,
|
|
1265
|
+
prefix,
|
|
1266
|
+
prefixEscaped,
|
|
1267
|
+
suffix,
|
|
1268
|
+
suffixEscaped,
|
|
1269
|
+
formatSeparator,
|
|
1270
|
+
unescapeSuffix,
|
|
1271
|
+
unescapePrefix,
|
|
1272
|
+
nestingPrefix,
|
|
1273
|
+
nestingPrefixEscaped,
|
|
1274
|
+
nestingSuffix,
|
|
1275
|
+
nestingSuffixEscaped,
|
|
1276
|
+
nestingOptionsSeparator,
|
|
1277
|
+
maxReplaces,
|
|
1278
|
+
alwaysFormat
|
|
1279
|
+
} = options.interpolation;
|
|
1280
|
+
this.escape = escape$1 !== undefined ? escape$1 : escape;
|
|
1281
|
+
this.escapeValue = escapeValue !== undefined ? escapeValue : true;
|
|
1282
|
+
this.useRawValueToEscape = useRawValueToEscape !== undefined ? useRawValueToEscape : false;
|
|
1283
|
+
this.prefix = prefix ? regexEscape(prefix) : prefixEscaped || '{{';
|
|
1284
|
+
this.suffix = suffix ? regexEscape(suffix) : suffixEscaped || '}}';
|
|
1285
|
+
this.formatSeparator = formatSeparator || ',';
|
|
1286
|
+
this.unescapePrefix = unescapeSuffix ? '' : unescapePrefix || '-';
|
|
1287
|
+
this.unescapeSuffix = this.unescapePrefix ? '' : unescapeSuffix || '';
|
|
1288
|
+
this.nestingPrefix = nestingPrefix ? regexEscape(nestingPrefix) : nestingPrefixEscaped || regexEscape('$t(');
|
|
1289
|
+
this.nestingSuffix = nestingSuffix ? regexEscape(nestingSuffix) : nestingSuffixEscaped || regexEscape(')');
|
|
1290
|
+
this.nestingOptionsSeparator = nestingOptionsSeparator || ',';
|
|
1291
|
+
this.maxReplaces = maxReplaces || 1000;
|
|
1292
|
+
this.alwaysFormat = alwaysFormat !== undefined ? alwaysFormat : false;
|
|
1293
|
+
this.resetRegExp();
|
|
1294
|
+
}
|
|
1295
|
+
reset() {
|
|
1296
|
+
if (this.options) this.init(this.options);
|
|
1297
|
+
}
|
|
1298
|
+
resetRegExp() {
|
|
1299
|
+
const getOrResetRegExp = (existingRegExp, pattern) => {
|
|
1300
|
+
if (existingRegExp && existingRegExp.source === pattern) {
|
|
1301
|
+
existingRegExp.lastIndex = 0;
|
|
1302
|
+
return existingRegExp;
|
|
1303
|
+
}
|
|
1304
|
+
return new RegExp(pattern, 'g');
|
|
1305
|
+
};
|
|
1306
|
+
this.regexp = getOrResetRegExp(this.regexp, `${this.prefix}(.+?)${this.suffix}`);
|
|
1307
|
+
this.regexpUnescape = getOrResetRegExp(this.regexpUnescape, `${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`);
|
|
1308
|
+
this.nestingRegexp = getOrResetRegExp(this.nestingRegexp, `${this.nestingPrefix}(.+?)${this.nestingSuffix}`);
|
|
1309
|
+
}
|
|
1310
|
+
interpolate(str, data, lng, options) {
|
|
1311
|
+
let match;
|
|
1312
|
+
let value;
|
|
1313
|
+
let replaces;
|
|
1314
|
+
const defaultData = this.options && this.options.interpolation && this.options.interpolation.defaultVariables || {};
|
|
1315
|
+
const handleFormat = key => {
|
|
1316
|
+
if (key.indexOf(this.formatSeparator) < 0) {
|
|
1317
|
+
const path = deepFindWithDefaults(data, defaultData, key, this.options.keySeparator, this.options.ignoreJSONStructure);
|
|
1318
|
+
return this.alwaysFormat ? this.format(path, undefined, lng, {
|
|
1319
|
+
...options,
|
|
1320
|
+
...data,
|
|
1321
|
+
interpolationkey: key
|
|
1322
|
+
}) : path;
|
|
1323
|
+
}
|
|
1324
|
+
const p = key.split(this.formatSeparator);
|
|
1325
|
+
const k = p.shift().trim();
|
|
1326
|
+
const f = p.join(this.formatSeparator).trim();
|
|
1327
|
+
return this.format(deepFindWithDefaults(data, defaultData, k, this.options.keySeparator, this.options.ignoreJSONStructure), f, lng, {
|
|
1328
|
+
...options,
|
|
1329
|
+
...data,
|
|
1330
|
+
interpolationkey: k
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1333
|
+
this.resetRegExp();
|
|
1334
|
+
const missingInterpolationHandler = options && options.missingInterpolationHandler || this.options.missingInterpolationHandler;
|
|
1335
|
+
const skipOnVariables = options && options.interpolation && options.interpolation.skipOnVariables !== undefined ? options.interpolation.skipOnVariables : this.options.interpolation.skipOnVariables;
|
|
1336
|
+
const todos = [{
|
|
1337
|
+
regex: this.regexpUnescape,
|
|
1338
|
+
safeValue: val => regexSafe(val)
|
|
1339
|
+
}, {
|
|
1340
|
+
regex: this.regexp,
|
|
1341
|
+
safeValue: val => this.escapeValue ? regexSafe(this.escape(val)) : regexSafe(val)
|
|
1342
|
+
}];
|
|
1343
|
+
todos.forEach(todo => {
|
|
1344
|
+
replaces = 0;
|
|
1345
|
+
while (match = todo.regex.exec(str)) {
|
|
1346
|
+
const matchedVar = match[1].trim();
|
|
1347
|
+
value = handleFormat(matchedVar);
|
|
1348
|
+
if (value === undefined) {
|
|
1349
|
+
if (typeof missingInterpolationHandler === 'function') {
|
|
1350
|
+
const temp = missingInterpolationHandler(str, match, options);
|
|
1351
|
+
value = isString(temp) ? temp : '';
|
|
1352
|
+
} else if (options && Object.prototype.hasOwnProperty.call(options, matchedVar)) {
|
|
1353
|
+
value = '';
|
|
1354
|
+
} else if (skipOnVariables) {
|
|
1355
|
+
value = match[0];
|
|
1356
|
+
continue;
|
|
1357
|
+
} else {
|
|
1358
|
+
this.logger.warn(`missed to pass in variable ${matchedVar} for interpolating ${str}`);
|
|
1359
|
+
value = '';
|
|
1360
|
+
}
|
|
1361
|
+
} else if (!isString(value) && !this.useRawValueToEscape) {
|
|
1362
|
+
value = makeString(value);
|
|
1363
|
+
}
|
|
1364
|
+
const safeValue = todo.safeValue(value);
|
|
1365
|
+
str = str.replace(match[0], safeValue);
|
|
1366
|
+
if (skipOnVariables) {
|
|
1367
|
+
todo.regex.lastIndex += value.length;
|
|
1368
|
+
todo.regex.lastIndex -= match[0].length;
|
|
1369
|
+
} else {
|
|
1370
|
+
todo.regex.lastIndex = 0;
|
|
1371
|
+
}
|
|
1372
|
+
replaces++;
|
|
1373
|
+
if (replaces >= this.maxReplaces) {
|
|
1374
|
+
break;
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
});
|
|
1378
|
+
return str;
|
|
1379
|
+
}
|
|
1380
|
+
nest(str, fc) {
|
|
1381
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1382
|
+
let match;
|
|
1383
|
+
let value;
|
|
1384
|
+
let clonedOptions;
|
|
1385
|
+
const handleHasOptions = (key, inheritedOptions) => {
|
|
1386
|
+
const sep = this.nestingOptionsSeparator;
|
|
1387
|
+
if (key.indexOf(sep) < 0) return key;
|
|
1388
|
+
const c = key.split(new RegExp(`${sep}[ ]*{`));
|
|
1389
|
+
let optionsString = `{${c[1]}`;
|
|
1390
|
+
key = c[0];
|
|
1391
|
+
optionsString = this.interpolate(optionsString, clonedOptions);
|
|
1392
|
+
const matchedSingleQuotes = optionsString.match(/'/g);
|
|
1393
|
+
const matchedDoubleQuotes = optionsString.match(/"/g);
|
|
1394
|
+
if (matchedSingleQuotes && matchedSingleQuotes.length % 2 === 0 && !matchedDoubleQuotes || matchedDoubleQuotes.length % 2 !== 0) {
|
|
1395
|
+
optionsString = optionsString.replace(/'/g, '"');
|
|
1396
|
+
}
|
|
1397
|
+
try {
|
|
1398
|
+
clonedOptions = JSON.parse(optionsString);
|
|
1399
|
+
if (inheritedOptions) clonedOptions = {
|
|
1400
|
+
...inheritedOptions,
|
|
1401
|
+
...clonedOptions
|
|
1402
|
+
};
|
|
1403
|
+
} catch (e) {
|
|
1404
|
+
this.logger.warn(`failed parsing options string in nesting for key ${key}`, e);
|
|
1405
|
+
return `${key}${sep}${optionsString}`;
|
|
1406
|
+
}
|
|
1407
|
+
if (clonedOptions.defaultValue && clonedOptions.defaultValue.indexOf(this.prefix) > -1) delete clonedOptions.defaultValue;
|
|
1408
|
+
return key;
|
|
1409
|
+
};
|
|
1410
|
+
while (match = this.nestingRegexp.exec(str)) {
|
|
1411
|
+
let formatters = [];
|
|
1412
|
+
clonedOptions = {
|
|
1413
|
+
...options
|
|
1414
|
+
};
|
|
1415
|
+
clonedOptions = clonedOptions.replace && !isString(clonedOptions.replace) ? clonedOptions.replace : clonedOptions;
|
|
1416
|
+
clonedOptions.applyPostProcessor = false;
|
|
1417
|
+
delete clonedOptions.defaultValue;
|
|
1418
|
+
let doReduce = false;
|
|
1419
|
+
if (match[0].indexOf(this.formatSeparator) !== -1 && !/{.*}/.test(match[1])) {
|
|
1420
|
+
const r = match[1].split(this.formatSeparator).map(elem => elem.trim());
|
|
1421
|
+
match[1] = r.shift();
|
|
1422
|
+
formatters = r;
|
|
1423
|
+
doReduce = true;
|
|
1424
|
+
}
|
|
1425
|
+
value = fc(handleHasOptions.call(this, match[1].trim(), clonedOptions), clonedOptions);
|
|
1426
|
+
if (value && match[0] === str && !isString(value)) return value;
|
|
1427
|
+
if (!isString(value)) value = makeString(value);
|
|
1428
|
+
if (!value) {
|
|
1429
|
+
this.logger.warn(`missed to resolve ${match[1]} for nesting ${str}`);
|
|
1430
|
+
value = '';
|
|
1431
|
+
}
|
|
1432
|
+
if (doReduce) {
|
|
1433
|
+
value = formatters.reduce((v, f) => this.format(v, f, options.lng, {
|
|
1434
|
+
...options,
|
|
1435
|
+
interpolationkey: match[1].trim()
|
|
1436
|
+
}), value.trim());
|
|
1437
|
+
}
|
|
1438
|
+
str = str.replace(match[0], value);
|
|
1439
|
+
this.regexp.lastIndex = 0;
|
|
1440
|
+
}
|
|
1441
|
+
return str;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
const parseFormatStr = formatStr => {
|
|
1446
|
+
let formatName = formatStr.toLowerCase().trim();
|
|
1447
|
+
const formatOptions = {};
|
|
1448
|
+
if (formatStr.indexOf('(') > -1) {
|
|
1449
|
+
const p = formatStr.split('(');
|
|
1450
|
+
formatName = p[0].toLowerCase().trim();
|
|
1451
|
+
const optStr = p[1].substring(0, p[1].length - 1);
|
|
1452
|
+
if (formatName === 'currency' && optStr.indexOf(':') < 0) {
|
|
1453
|
+
if (!formatOptions.currency) formatOptions.currency = optStr.trim();
|
|
1454
|
+
} else if (formatName === 'relativetime' && optStr.indexOf(':') < 0) {
|
|
1455
|
+
if (!formatOptions.range) formatOptions.range = optStr.trim();
|
|
1456
|
+
} else {
|
|
1457
|
+
const opts = optStr.split(';');
|
|
1458
|
+
opts.forEach(opt => {
|
|
1459
|
+
if (opt) {
|
|
1460
|
+
const [key, ...rest] = opt.split(':');
|
|
1461
|
+
const val = rest.join(':').trim().replace(/^'+|'+$/g, '');
|
|
1462
|
+
const trimmedKey = key.trim();
|
|
1463
|
+
if (!formatOptions[trimmedKey]) formatOptions[trimmedKey] = val;
|
|
1464
|
+
if (val === 'false') formatOptions[trimmedKey] = false;
|
|
1465
|
+
if (val === 'true') formatOptions[trimmedKey] = true;
|
|
1466
|
+
if (!isNaN(val)) formatOptions[trimmedKey] = parseInt(val, 10);
|
|
1467
|
+
}
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
return {
|
|
1472
|
+
formatName,
|
|
1473
|
+
formatOptions
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
const createCachedFormatter = fn => {
|
|
1477
|
+
const cache = {};
|
|
1478
|
+
return (val, lng, options) => {
|
|
1479
|
+
let optForCache = options;
|
|
1480
|
+
if (options && options.interpolationkey && options.formatParams && options.formatParams[options.interpolationkey] && options[options.interpolationkey]) {
|
|
1481
|
+
optForCache = {
|
|
1482
|
+
...optForCache,
|
|
1483
|
+
[options.interpolationkey]: undefined
|
|
1484
|
+
};
|
|
1485
|
+
}
|
|
1486
|
+
const key = lng + JSON.stringify(optForCache);
|
|
1487
|
+
let formatter = cache[key];
|
|
1488
|
+
if (!formatter) {
|
|
1489
|
+
formatter = fn(getCleanedCode(lng), options);
|
|
1490
|
+
cache[key] = formatter;
|
|
1491
|
+
}
|
|
1492
|
+
return formatter(val);
|
|
1493
|
+
};
|
|
1494
|
+
};
|
|
1495
|
+
class Formatter {
|
|
1496
|
+
constructor() {
|
|
1497
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1498
|
+
this.logger = baseLogger.create('formatter');
|
|
1499
|
+
this.options = options;
|
|
1500
|
+
this.formats = {
|
|
1501
|
+
number: createCachedFormatter((lng, opt) => {
|
|
1502
|
+
const formatter = new Intl.NumberFormat(lng, {
|
|
1503
|
+
...opt
|
|
1504
|
+
});
|
|
1505
|
+
return val => formatter.format(val);
|
|
1506
|
+
}),
|
|
1507
|
+
currency: createCachedFormatter((lng, opt) => {
|
|
1508
|
+
const formatter = new Intl.NumberFormat(lng, {
|
|
1509
|
+
...opt,
|
|
1510
|
+
style: 'currency'
|
|
1511
|
+
});
|
|
1512
|
+
return val => formatter.format(val);
|
|
1513
|
+
}),
|
|
1514
|
+
datetime: createCachedFormatter((lng, opt) => {
|
|
1515
|
+
const formatter = new Intl.DateTimeFormat(lng, {
|
|
1516
|
+
...opt
|
|
1517
|
+
});
|
|
1518
|
+
return val => formatter.format(val);
|
|
1519
|
+
}),
|
|
1520
|
+
relativetime: createCachedFormatter((lng, opt) => {
|
|
1521
|
+
const formatter = new Intl.RelativeTimeFormat(lng, {
|
|
1522
|
+
...opt
|
|
1523
|
+
});
|
|
1524
|
+
return val => formatter.format(val, opt.range || 'day');
|
|
1525
|
+
}),
|
|
1526
|
+
list: createCachedFormatter((lng, opt) => {
|
|
1527
|
+
const formatter = new Intl.ListFormat(lng, {
|
|
1528
|
+
...opt
|
|
1529
|
+
});
|
|
1530
|
+
return val => formatter.format(val);
|
|
1531
|
+
})
|
|
1532
|
+
};
|
|
1533
|
+
this.init(options);
|
|
1534
|
+
}
|
|
1535
|
+
init(services) {
|
|
1536
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
1537
|
+
interpolation: {}
|
|
1538
|
+
};
|
|
1539
|
+
this.formatSeparator = options.interpolation.formatSeparator || ',';
|
|
1540
|
+
}
|
|
1541
|
+
add(name, fc) {
|
|
1542
|
+
this.formats[name.toLowerCase().trim()] = fc;
|
|
1543
|
+
}
|
|
1544
|
+
addCached(name, fc) {
|
|
1545
|
+
this.formats[name.toLowerCase().trim()] = createCachedFormatter(fc);
|
|
1546
|
+
}
|
|
1547
|
+
format(value, format, lng) {
|
|
1548
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1549
|
+
const formats = format.split(this.formatSeparator);
|
|
1550
|
+
if (formats.length > 1 && formats[0].indexOf('(') > 1 && formats[0].indexOf(')') < 0 && formats.find(f => f.indexOf(')') > -1)) {
|
|
1551
|
+
const lastIndex = formats.findIndex(f => f.indexOf(')') > -1);
|
|
1552
|
+
formats[0] = [formats[0], ...formats.splice(1, lastIndex)].join(this.formatSeparator);
|
|
1553
|
+
}
|
|
1554
|
+
const result = formats.reduce((mem, f) => {
|
|
1555
|
+
const {
|
|
1556
|
+
formatName,
|
|
1557
|
+
formatOptions
|
|
1558
|
+
} = parseFormatStr(f);
|
|
1559
|
+
if (this.formats[formatName]) {
|
|
1560
|
+
let formatted = mem;
|
|
1561
|
+
try {
|
|
1562
|
+
const valOptions = options && options.formatParams && options.formatParams[options.interpolationkey] || {};
|
|
1563
|
+
const l = valOptions.locale || valOptions.lng || options.locale || options.lng || lng;
|
|
1564
|
+
formatted = this.formats[formatName](mem, l, {
|
|
1565
|
+
...formatOptions,
|
|
1566
|
+
...options,
|
|
1567
|
+
...valOptions
|
|
1568
|
+
});
|
|
1569
|
+
} catch (error) {
|
|
1570
|
+
this.logger.warn(error);
|
|
1571
|
+
}
|
|
1572
|
+
return formatted;
|
|
1573
|
+
} else {
|
|
1574
|
+
this.logger.warn(`there was no format function for ${formatName}`);
|
|
1575
|
+
}
|
|
1576
|
+
return mem;
|
|
1577
|
+
}, value);
|
|
1578
|
+
return result;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
const removePending = (q, name) => {
|
|
1583
|
+
if (q.pending[name] !== undefined) {
|
|
1584
|
+
delete q.pending[name];
|
|
1585
|
+
q.pendingCount--;
|
|
1586
|
+
}
|
|
1587
|
+
};
|
|
1588
|
+
class Connector extends EventEmitter {
|
|
1589
|
+
constructor(backend, store, services) {
|
|
1590
|
+
let options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
1591
|
+
super();
|
|
1592
|
+
this.backend = backend;
|
|
1593
|
+
this.store = store;
|
|
1594
|
+
this.services = services;
|
|
1595
|
+
this.languageUtils = services.languageUtils;
|
|
1596
|
+
this.options = options;
|
|
1597
|
+
this.logger = baseLogger.create('backendConnector');
|
|
1598
|
+
this.waitingReads = [];
|
|
1599
|
+
this.maxParallelReads = options.maxParallelReads || 10;
|
|
1600
|
+
this.readingCalls = 0;
|
|
1601
|
+
this.maxRetries = options.maxRetries >= 0 ? options.maxRetries : 5;
|
|
1602
|
+
this.retryTimeout = options.retryTimeout >= 1 ? options.retryTimeout : 350;
|
|
1603
|
+
this.state = {};
|
|
1604
|
+
this.queue = [];
|
|
1605
|
+
if (this.backend && this.backend.init) {
|
|
1606
|
+
this.backend.init(services, options.backend, options);
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
queueLoad(languages, namespaces, options, callback) {
|
|
1610
|
+
const toLoad = {};
|
|
1611
|
+
const pending = {};
|
|
1612
|
+
const toLoadLanguages = {};
|
|
1613
|
+
const toLoadNamespaces = {};
|
|
1614
|
+
languages.forEach(lng => {
|
|
1615
|
+
let hasAllNamespaces = true;
|
|
1616
|
+
namespaces.forEach(ns => {
|
|
1617
|
+
const name = `${lng}|${ns}`;
|
|
1618
|
+
if (!options.reload && this.store.hasResourceBundle(lng, ns)) {
|
|
1619
|
+
this.state[name] = 2;
|
|
1620
|
+
} else if (this.state[name] < 0) ; else if (this.state[name] === 1) {
|
|
1621
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1622
|
+
} else {
|
|
1623
|
+
this.state[name] = 1;
|
|
1624
|
+
hasAllNamespaces = false;
|
|
1625
|
+
if (pending[name] === undefined) pending[name] = true;
|
|
1626
|
+
if (toLoad[name] === undefined) toLoad[name] = true;
|
|
1627
|
+
if (toLoadNamespaces[ns] === undefined) toLoadNamespaces[ns] = true;
|
|
1628
|
+
}
|
|
1629
|
+
});
|
|
1630
|
+
if (!hasAllNamespaces) toLoadLanguages[lng] = true;
|
|
1631
|
+
});
|
|
1632
|
+
if (Object.keys(toLoad).length || Object.keys(pending).length) {
|
|
1633
|
+
this.queue.push({
|
|
1634
|
+
pending,
|
|
1635
|
+
pendingCount: Object.keys(pending).length,
|
|
1636
|
+
loaded: {},
|
|
1637
|
+
errors: [],
|
|
1638
|
+
callback
|
|
1639
|
+
});
|
|
1640
|
+
}
|
|
1641
|
+
return {
|
|
1642
|
+
toLoad: Object.keys(toLoad),
|
|
1643
|
+
pending: Object.keys(pending),
|
|
1644
|
+
toLoadLanguages: Object.keys(toLoadLanguages),
|
|
1645
|
+
toLoadNamespaces: Object.keys(toLoadNamespaces)
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
loaded(name, err, data) {
|
|
1649
|
+
const s = name.split('|');
|
|
1650
|
+
const lng = s[0];
|
|
1651
|
+
const ns = s[1];
|
|
1652
|
+
if (err) this.emit('failedLoading', lng, ns, err);
|
|
1653
|
+
if (!err && data) {
|
|
1654
|
+
this.store.addResourceBundle(lng, ns, data, undefined, undefined, {
|
|
1655
|
+
skipCopy: true
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
this.state[name] = err ? -1 : 2;
|
|
1659
|
+
if (err && data) this.state[name] = 0;
|
|
1660
|
+
const loaded = {};
|
|
1661
|
+
this.queue.forEach(q => {
|
|
1662
|
+
pushPath(q.loaded, [lng], ns);
|
|
1663
|
+
removePending(q, name);
|
|
1664
|
+
if (err) q.errors.push(err);
|
|
1665
|
+
if (q.pendingCount === 0 && !q.done) {
|
|
1666
|
+
Object.keys(q.loaded).forEach(l => {
|
|
1667
|
+
if (!loaded[l]) loaded[l] = {};
|
|
1668
|
+
const loadedKeys = q.loaded[l];
|
|
1669
|
+
if (loadedKeys.length) {
|
|
1670
|
+
loadedKeys.forEach(n => {
|
|
1671
|
+
if (loaded[l][n] === undefined) loaded[l][n] = true;
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
q.done = true;
|
|
1676
|
+
if (q.errors.length) {
|
|
1677
|
+
q.callback(q.errors);
|
|
1678
|
+
} else {
|
|
1679
|
+
q.callback();
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
});
|
|
1683
|
+
this.emit('loaded', loaded);
|
|
1684
|
+
this.queue = this.queue.filter(q => !q.done);
|
|
1685
|
+
}
|
|
1686
|
+
read(lng, ns, fcName) {
|
|
1687
|
+
let tried = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
1688
|
+
let wait = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : this.retryTimeout;
|
|
1689
|
+
let callback = arguments.length > 5 ? arguments[5] : undefined;
|
|
1690
|
+
if (!lng.length) return callback(null, {});
|
|
1691
|
+
if (this.readingCalls >= this.maxParallelReads) {
|
|
1692
|
+
this.waitingReads.push({
|
|
1693
|
+
lng,
|
|
1694
|
+
ns,
|
|
1695
|
+
fcName,
|
|
1696
|
+
tried,
|
|
1697
|
+
wait,
|
|
1698
|
+
callback
|
|
1699
|
+
});
|
|
1700
|
+
return;
|
|
1701
|
+
}
|
|
1702
|
+
this.readingCalls++;
|
|
1703
|
+
const resolver = (err, data) => {
|
|
1704
|
+
this.readingCalls--;
|
|
1705
|
+
if (this.waitingReads.length > 0) {
|
|
1706
|
+
const next = this.waitingReads.shift();
|
|
1707
|
+
this.read(next.lng, next.ns, next.fcName, next.tried, next.wait, next.callback);
|
|
1708
|
+
}
|
|
1709
|
+
if (err && data && tried < this.maxRetries) {
|
|
1710
|
+
setTimeout(() => {
|
|
1711
|
+
this.read.call(this, lng, ns, fcName, tried + 1, wait * 2, callback);
|
|
1712
|
+
}, wait);
|
|
1713
|
+
return;
|
|
1714
|
+
}
|
|
1715
|
+
callback(err, data);
|
|
1716
|
+
};
|
|
1717
|
+
const fc = this.backend[fcName].bind(this.backend);
|
|
1718
|
+
if (fc.length === 2) {
|
|
1719
|
+
try {
|
|
1720
|
+
const r = fc(lng, ns);
|
|
1721
|
+
if (r && typeof r.then === 'function') {
|
|
1722
|
+
r.then(data => resolver(null, data)).catch(resolver);
|
|
1723
|
+
} else {
|
|
1724
|
+
resolver(null, r);
|
|
1725
|
+
}
|
|
1726
|
+
} catch (err) {
|
|
1727
|
+
resolver(err);
|
|
1728
|
+
}
|
|
1729
|
+
return;
|
|
1730
|
+
}
|
|
1731
|
+
return fc(lng, ns, resolver);
|
|
1732
|
+
}
|
|
1733
|
+
prepareLoading(languages, namespaces) {
|
|
1734
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
1735
|
+
let callback = arguments.length > 3 ? arguments[3] : undefined;
|
|
1736
|
+
if (!this.backend) {
|
|
1737
|
+
this.logger.warn('No backend was added via i18next.use. Will not load resources.');
|
|
1738
|
+
return callback && callback();
|
|
1739
|
+
}
|
|
1740
|
+
if (isString(languages)) languages = this.languageUtils.toResolveHierarchy(languages);
|
|
1741
|
+
if (isString(namespaces)) namespaces = [namespaces];
|
|
1742
|
+
const toLoad = this.queueLoad(languages, namespaces, options, callback);
|
|
1743
|
+
if (!toLoad.toLoad.length) {
|
|
1744
|
+
if (!toLoad.pending.length) callback();
|
|
1745
|
+
return null;
|
|
1746
|
+
}
|
|
1747
|
+
toLoad.toLoad.forEach(name => {
|
|
1748
|
+
this.loadOne(name);
|
|
1749
|
+
});
|
|
1750
|
+
}
|
|
1751
|
+
load(languages, namespaces, callback) {
|
|
1752
|
+
this.prepareLoading(languages, namespaces, {}, callback);
|
|
1753
|
+
}
|
|
1754
|
+
reload(languages, namespaces, callback) {
|
|
1755
|
+
this.prepareLoading(languages, namespaces, {
|
|
1756
|
+
reload: true
|
|
1757
|
+
}, callback);
|
|
1758
|
+
}
|
|
1759
|
+
loadOne(name) {
|
|
1760
|
+
let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
1761
|
+
const s = name.split('|');
|
|
1762
|
+
const lng = s[0];
|
|
1763
|
+
const ns = s[1];
|
|
1764
|
+
this.read(lng, ns, 'read', undefined, undefined, (err, data) => {
|
|
1765
|
+
if (err) this.logger.warn(`${prefix}loading namespace ${ns} for language ${lng} failed`, err);
|
|
1766
|
+
if (!err && data) this.logger.log(`${prefix}loaded namespace ${ns} for language ${lng}`, data);
|
|
1767
|
+
this.loaded(name, err, data);
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
saveMissing(languages, namespace, key, fallbackValue, isUpdate) {
|
|
1771
|
+
let options = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
|
|
1772
|
+
let clb = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : () => {};
|
|
1773
|
+
if (this.services.utils && this.services.utils.hasLoadedNamespace && !this.services.utils.hasLoadedNamespace(namespace)) {
|
|
1774
|
+
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!!!');
|
|
1775
|
+
return;
|
|
1776
|
+
}
|
|
1777
|
+
if (key === undefined || key === null || key === '') return;
|
|
1778
|
+
if (this.backend && this.backend.create) {
|
|
1779
|
+
const opts = {
|
|
1780
|
+
...options,
|
|
1781
|
+
isUpdate
|
|
1782
|
+
};
|
|
1783
|
+
const fc = this.backend.create.bind(this.backend);
|
|
1784
|
+
if (fc.length < 6) {
|
|
1785
|
+
try {
|
|
1786
|
+
let r;
|
|
1787
|
+
if (fc.length === 5) {
|
|
1788
|
+
r = fc(languages, namespace, key, fallbackValue, opts);
|
|
1789
|
+
} else {
|
|
1790
|
+
r = fc(languages, namespace, key, fallbackValue);
|
|
1791
|
+
}
|
|
1792
|
+
if (r && typeof r.then === 'function') {
|
|
1793
|
+
r.then(data => clb(null, data)).catch(clb);
|
|
1794
|
+
} else {
|
|
1795
|
+
clb(null, r);
|
|
1796
|
+
}
|
|
1797
|
+
} catch (err) {
|
|
1798
|
+
clb(err);
|
|
1799
|
+
}
|
|
1800
|
+
} else {
|
|
1801
|
+
fc(languages, namespace, key, fallbackValue, clb, opts);
|
|
1802
|
+
}
|
|
1803
|
+
}
|
|
1804
|
+
if (!languages || !languages[0]) return;
|
|
1805
|
+
this.store.addResource(languages[0], namespace, key, fallbackValue);
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
const get = () => ({
|
|
1810
|
+
debug: false,
|
|
1811
|
+
initImmediate: true,
|
|
1812
|
+
ns: ['translation'],
|
|
1813
|
+
defaultNS: ['translation'],
|
|
1814
|
+
fallbackLng: ['dev'],
|
|
1815
|
+
fallbackNS: false,
|
|
1816
|
+
supportedLngs: false,
|
|
1817
|
+
nonExplicitSupportedLngs: false,
|
|
1818
|
+
load: 'all',
|
|
1819
|
+
preload: false,
|
|
1820
|
+
simplifyPluralSuffix: true,
|
|
1821
|
+
keySeparator: '.',
|
|
1822
|
+
nsSeparator: ':',
|
|
1823
|
+
pluralSeparator: '_',
|
|
1824
|
+
contextSeparator: '_',
|
|
1825
|
+
partialBundledLanguages: false,
|
|
1826
|
+
saveMissing: false,
|
|
1827
|
+
updateMissing: false,
|
|
1828
|
+
saveMissingTo: 'fallback',
|
|
1829
|
+
saveMissingPlurals: true,
|
|
1830
|
+
missingKeyHandler: false,
|
|
1831
|
+
missingInterpolationHandler: false,
|
|
1832
|
+
postProcess: false,
|
|
1833
|
+
postProcessPassResolved: false,
|
|
1834
|
+
returnNull: false,
|
|
1835
|
+
returnEmptyString: true,
|
|
1836
|
+
returnObjects: false,
|
|
1837
|
+
joinArrays: false,
|
|
1838
|
+
returnedObjectHandler: false,
|
|
1839
|
+
parseMissingKeyHandler: false,
|
|
1840
|
+
appendNamespaceToMissingKey: false,
|
|
1841
|
+
appendNamespaceToCIMode: false,
|
|
1842
|
+
overloadTranslationOptionHandler: args => {
|
|
1843
|
+
let ret = {};
|
|
1844
|
+
if (typeof args[1] === 'object') ret = args[1];
|
|
1845
|
+
if (isString(args[1])) ret.defaultValue = args[1];
|
|
1846
|
+
if (isString(args[2])) ret.tDescription = args[2];
|
|
1847
|
+
if (typeof args[2] === 'object' || typeof args[3] === 'object') {
|
|
1848
|
+
const options = args[3] || args[2];
|
|
1849
|
+
Object.keys(options).forEach(key => {
|
|
1850
|
+
ret[key] = options[key];
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
return ret;
|
|
1854
|
+
},
|
|
1855
|
+
interpolation: {
|
|
1856
|
+
escapeValue: true,
|
|
1857
|
+
format: value => value,
|
|
1858
|
+
prefix: '{{',
|
|
1859
|
+
suffix: '}}',
|
|
1860
|
+
formatSeparator: ',',
|
|
1861
|
+
unescapePrefix: '-',
|
|
1862
|
+
nestingPrefix: '$t(',
|
|
1863
|
+
nestingSuffix: ')',
|
|
1864
|
+
nestingOptionsSeparator: ',',
|
|
1865
|
+
maxReplaces: 1000,
|
|
1866
|
+
skipOnVariables: true
|
|
1867
|
+
}
|
|
1868
|
+
});
|
|
1869
|
+
const transformOptions = options => {
|
|
1870
|
+
if (isString(options.ns)) options.ns = [options.ns];
|
|
1871
|
+
if (isString(options.fallbackLng)) options.fallbackLng = [options.fallbackLng];
|
|
1872
|
+
if (isString(options.fallbackNS)) options.fallbackNS = [options.fallbackNS];
|
|
1873
|
+
if (options.supportedLngs && options.supportedLngs.indexOf('cimode') < 0) {
|
|
1874
|
+
options.supportedLngs = options.supportedLngs.concat(['cimode']);
|
|
1875
|
+
}
|
|
1876
|
+
return options;
|
|
1877
|
+
};
|
|
1878
|
+
|
|
1879
|
+
const noop = () => {};
|
|
1880
|
+
const bindMemberFunctions = inst => {
|
|
1881
|
+
const mems = Object.getOwnPropertyNames(Object.getPrototypeOf(inst));
|
|
1882
|
+
mems.forEach(mem => {
|
|
1883
|
+
if (typeof inst[mem] === 'function') {
|
|
1884
|
+
inst[mem] = inst[mem].bind(inst);
|
|
1885
|
+
}
|
|
1886
|
+
});
|
|
1887
|
+
};
|
|
1888
|
+
class I18n extends EventEmitter {
|
|
1889
|
+
constructor() {
|
|
1890
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1891
|
+
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
1892
|
+
super();
|
|
1893
|
+
this.options = transformOptions(options);
|
|
1894
|
+
this.services = {};
|
|
1895
|
+
this.logger = baseLogger;
|
|
1896
|
+
this.modules = {
|
|
1897
|
+
external: []
|
|
1898
|
+
};
|
|
1899
|
+
bindMemberFunctions(this);
|
|
1900
|
+
if (callback && !this.isInitialized && !options.isClone) {
|
|
1901
|
+
if (!this.options.initImmediate) {
|
|
1902
|
+
this.init(options, callback);
|
|
1903
|
+
return this;
|
|
1904
|
+
}
|
|
1905
|
+
setTimeout(() => {
|
|
1906
|
+
this.init(options, callback);
|
|
1907
|
+
}, 0);
|
|
1908
|
+
}
|
|
1909
|
+
}
|
|
1910
|
+
init() {
|
|
1911
|
+
var _this = this;
|
|
1912
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1913
|
+
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
1914
|
+
this.isInitializing = true;
|
|
1915
|
+
if (typeof options === 'function') {
|
|
1916
|
+
callback = options;
|
|
1917
|
+
options = {};
|
|
1918
|
+
}
|
|
1919
|
+
if (!options.defaultNS && options.defaultNS !== false && options.ns) {
|
|
1920
|
+
if (isString(options.ns)) {
|
|
1921
|
+
options.defaultNS = options.ns;
|
|
1922
|
+
} else if (options.ns.indexOf('translation') < 0) {
|
|
1923
|
+
options.defaultNS = options.ns[0];
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
const defOpts = get();
|
|
1927
|
+
this.options = {
|
|
1928
|
+
...defOpts,
|
|
1929
|
+
...this.options,
|
|
1930
|
+
...transformOptions(options)
|
|
1931
|
+
};
|
|
1932
|
+
if (this.options.compatibilityAPI !== 'v1') {
|
|
1933
|
+
this.options.interpolation = {
|
|
1934
|
+
...defOpts.interpolation,
|
|
1935
|
+
...this.options.interpolation
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
if (options.keySeparator !== undefined) {
|
|
1939
|
+
this.options.userDefinedKeySeparator = options.keySeparator;
|
|
1940
|
+
}
|
|
1941
|
+
if (options.nsSeparator !== undefined) {
|
|
1942
|
+
this.options.userDefinedNsSeparator = options.nsSeparator;
|
|
1943
|
+
}
|
|
1944
|
+
const createClassOnDemand = ClassOrObject => {
|
|
1945
|
+
if (!ClassOrObject) return null;
|
|
1946
|
+
if (typeof ClassOrObject === 'function') return new ClassOrObject();
|
|
1947
|
+
return ClassOrObject;
|
|
1948
|
+
};
|
|
1949
|
+
if (!this.options.isClone) {
|
|
1950
|
+
if (this.modules.logger) {
|
|
1951
|
+
baseLogger.init(createClassOnDemand(this.modules.logger), this.options);
|
|
1952
|
+
} else {
|
|
1953
|
+
baseLogger.init(null, this.options);
|
|
1954
|
+
}
|
|
1955
|
+
let formatter;
|
|
1956
|
+
if (this.modules.formatter) {
|
|
1957
|
+
formatter = this.modules.formatter;
|
|
1958
|
+
} else if (typeof Intl !== 'undefined') {
|
|
1959
|
+
formatter = Formatter;
|
|
1960
|
+
}
|
|
1961
|
+
const lu = new LanguageUtil(this.options);
|
|
1962
|
+
this.store = new ResourceStore(this.options.resources, this.options);
|
|
1963
|
+
const s = this.services;
|
|
1964
|
+
s.logger = baseLogger;
|
|
1965
|
+
s.resourceStore = this.store;
|
|
1966
|
+
s.languageUtils = lu;
|
|
1967
|
+
s.pluralResolver = new PluralResolver(lu, {
|
|
1968
|
+
prepend: this.options.pluralSeparator,
|
|
1969
|
+
compatibilityJSON: this.options.compatibilityJSON,
|
|
1970
|
+
simplifyPluralSuffix: this.options.simplifyPluralSuffix
|
|
1971
|
+
});
|
|
1972
|
+
if (formatter && (!this.options.interpolation.format || this.options.interpolation.format === defOpts.interpolation.format)) {
|
|
1973
|
+
s.formatter = createClassOnDemand(formatter);
|
|
1974
|
+
s.formatter.init(s, this.options);
|
|
1975
|
+
this.options.interpolation.format = s.formatter.format.bind(s.formatter);
|
|
1976
|
+
}
|
|
1977
|
+
s.interpolator = new Interpolator(this.options);
|
|
1978
|
+
s.utils = {
|
|
1979
|
+
hasLoadedNamespace: this.hasLoadedNamespace.bind(this)
|
|
1980
|
+
};
|
|
1981
|
+
s.backendConnector = new Connector(createClassOnDemand(this.modules.backend), s.resourceStore, s, this.options);
|
|
1982
|
+
s.backendConnector.on('*', function (event) {
|
|
1983
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
1984
|
+
args[_key - 1] = arguments[_key];
|
|
1985
|
+
}
|
|
1986
|
+
_this.emit(event, ...args);
|
|
1987
|
+
});
|
|
1988
|
+
if (this.modules.languageDetector) {
|
|
1989
|
+
s.languageDetector = createClassOnDemand(this.modules.languageDetector);
|
|
1990
|
+
if (s.languageDetector.init) s.languageDetector.init(s, this.options.detection, this.options);
|
|
1991
|
+
}
|
|
1992
|
+
if (this.modules.i18nFormat) {
|
|
1993
|
+
s.i18nFormat = createClassOnDemand(this.modules.i18nFormat);
|
|
1994
|
+
if (s.i18nFormat.init) s.i18nFormat.init(this);
|
|
1995
|
+
}
|
|
1996
|
+
this.translator = new Translator(this.services, this.options);
|
|
1997
|
+
this.translator.on('*', function (event) {
|
|
1998
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
1999
|
+
args[_key2 - 1] = arguments[_key2];
|
|
2000
|
+
}
|
|
2001
|
+
_this.emit(event, ...args);
|
|
2002
|
+
});
|
|
2003
|
+
this.modules.external.forEach(m => {
|
|
2004
|
+
if (m.init) m.init(this);
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
this.format = this.options.interpolation.format;
|
|
2008
|
+
if (!callback) callback = noop;
|
|
2009
|
+
if (this.options.fallbackLng && !this.services.languageDetector && !this.options.lng) {
|
|
2010
|
+
const codes = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2011
|
+
if (codes.length > 0 && codes[0] !== 'dev') this.options.lng = codes[0];
|
|
2012
|
+
}
|
|
2013
|
+
if (!this.services.languageDetector && !this.options.lng) {
|
|
2014
|
+
this.logger.warn('init: no languageDetector is used and no lng is defined');
|
|
2015
|
+
}
|
|
2016
|
+
const storeApi = ['getResource', 'hasResourceBundle', 'getResourceBundle', 'getDataByLanguage'];
|
|
2017
|
+
storeApi.forEach(fcName => {
|
|
2018
|
+
this[fcName] = function () {
|
|
2019
|
+
return _this.store[fcName](...arguments);
|
|
2020
|
+
};
|
|
2021
|
+
});
|
|
2022
|
+
const storeApiChained = ['addResource', 'addResources', 'addResourceBundle', 'removeResourceBundle'];
|
|
2023
|
+
storeApiChained.forEach(fcName => {
|
|
2024
|
+
this[fcName] = function () {
|
|
2025
|
+
_this.store[fcName](...arguments);
|
|
2026
|
+
return _this;
|
|
2027
|
+
};
|
|
2028
|
+
});
|
|
2029
|
+
const deferred = defer();
|
|
2030
|
+
const load = () => {
|
|
2031
|
+
const finish = (err, t) => {
|
|
2032
|
+
this.isInitializing = false;
|
|
2033
|
+
if (this.isInitialized && !this.initializedStoreOnce) this.logger.warn('init: i18next is already initialized. You should call init just once!');
|
|
2034
|
+
this.isInitialized = true;
|
|
2035
|
+
if (!this.options.isClone) this.logger.log('initialized', this.options);
|
|
2036
|
+
this.emit('initialized', this.options);
|
|
2037
|
+
deferred.resolve(t);
|
|
2038
|
+
callback(err, t);
|
|
2039
|
+
};
|
|
2040
|
+
if (this.languages && this.options.compatibilityAPI !== 'v1' && !this.isInitialized) return finish(null, this.t.bind(this));
|
|
2041
|
+
this.changeLanguage(this.options.lng, finish);
|
|
2042
|
+
};
|
|
2043
|
+
if (this.options.resources || !this.options.initImmediate) {
|
|
2044
|
+
load();
|
|
2045
|
+
} else {
|
|
2046
|
+
setTimeout(load, 0);
|
|
2047
|
+
}
|
|
2048
|
+
return deferred;
|
|
2049
|
+
}
|
|
2050
|
+
loadResources(language) {
|
|
2051
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2052
|
+
let usedCallback = callback;
|
|
2053
|
+
const usedLng = isString(language) ? language : this.language;
|
|
2054
|
+
if (typeof language === 'function') usedCallback = language;
|
|
2055
|
+
if (!this.options.resources || this.options.partialBundledLanguages) {
|
|
2056
|
+
if (usedLng && usedLng.toLowerCase() === 'cimode' && (!this.options.preload || this.options.preload.length === 0)) return usedCallback();
|
|
2057
|
+
const toLoad = [];
|
|
2058
|
+
const append = lng => {
|
|
2059
|
+
if (!lng) return;
|
|
2060
|
+
if (lng === 'cimode') return;
|
|
2061
|
+
const lngs = this.services.languageUtils.toResolveHierarchy(lng);
|
|
2062
|
+
lngs.forEach(l => {
|
|
2063
|
+
if (l === 'cimode') return;
|
|
2064
|
+
if (toLoad.indexOf(l) < 0) toLoad.push(l);
|
|
2065
|
+
});
|
|
2066
|
+
};
|
|
2067
|
+
if (!usedLng) {
|
|
2068
|
+
const fallbacks = this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);
|
|
2069
|
+
fallbacks.forEach(l => append(l));
|
|
2070
|
+
} else {
|
|
2071
|
+
append(usedLng);
|
|
2072
|
+
}
|
|
2073
|
+
if (this.options.preload) {
|
|
2074
|
+
this.options.preload.forEach(l => append(l));
|
|
2075
|
+
}
|
|
2076
|
+
this.services.backendConnector.load(toLoad, this.options.ns, e => {
|
|
2077
|
+
if (!e && !this.resolvedLanguage && this.language) this.setResolvedLanguage(this.language);
|
|
2078
|
+
usedCallback(e);
|
|
2079
|
+
});
|
|
2080
|
+
} else {
|
|
2081
|
+
usedCallback(null);
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
reloadResources(lngs, ns, callback) {
|
|
2085
|
+
const deferred = defer();
|
|
2086
|
+
if (typeof lngs === 'function') {
|
|
2087
|
+
callback = lngs;
|
|
2088
|
+
lngs = undefined;
|
|
2089
|
+
}
|
|
2090
|
+
if (typeof ns === 'function') {
|
|
2091
|
+
callback = ns;
|
|
2092
|
+
ns = undefined;
|
|
2093
|
+
}
|
|
2094
|
+
if (!lngs) lngs = this.languages;
|
|
2095
|
+
if (!ns) ns = this.options.ns;
|
|
2096
|
+
if (!callback) callback = noop;
|
|
2097
|
+
this.services.backendConnector.reload(lngs, ns, err => {
|
|
2098
|
+
deferred.resolve();
|
|
2099
|
+
callback(err);
|
|
2100
|
+
});
|
|
2101
|
+
return deferred;
|
|
2102
|
+
}
|
|
2103
|
+
use(module) {
|
|
2104
|
+
if (!module) throw new Error('You are passing an undefined module! Please check the object you are passing to i18next.use()');
|
|
2105
|
+
if (!module.type) throw new Error('You are passing a wrong module! Please check the object you are passing to i18next.use()');
|
|
2106
|
+
if (module.type === 'backend') {
|
|
2107
|
+
this.modules.backend = module;
|
|
2108
|
+
}
|
|
2109
|
+
if (module.type === 'logger' || module.log && module.warn && module.error) {
|
|
2110
|
+
this.modules.logger = module;
|
|
2111
|
+
}
|
|
2112
|
+
if (module.type === 'languageDetector') {
|
|
2113
|
+
this.modules.languageDetector = module;
|
|
2114
|
+
}
|
|
2115
|
+
if (module.type === 'i18nFormat') {
|
|
2116
|
+
this.modules.i18nFormat = module;
|
|
2117
|
+
}
|
|
2118
|
+
if (module.type === 'postProcessor') {
|
|
2119
|
+
postProcessor.addPostProcessor(module);
|
|
2120
|
+
}
|
|
2121
|
+
if (module.type === 'formatter') {
|
|
2122
|
+
this.modules.formatter = module;
|
|
2123
|
+
}
|
|
2124
|
+
if (module.type === '3rdParty') {
|
|
2125
|
+
this.modules.external.push(module);
|
|
2126
|
+
}
|
|
2127
|
+
return this;
|
|
2128
|
+
}
|
|
2129
|
+
setResolvedLanguage(l) {
|
|
2130
|
+
if (!l || !this.languages) return;
|
|
2131
|
+
if (['cimode', 'dev'].indexOf(l) > -1) return;
|
|
2132
|
+
for (let li = 0; li < this.languages.length; li++) {
|
|
2133
|
+
const lngInLngs = this.languages[li];
|
|
2134
|
+
if (['cimode', 'dev'].indexOf(lngInLngs) > -1) continue;
|
|
2135
|
+
if (this.store.hasLanguageSomeTranslations(lngInLngs)) {
|
|
2136
|
+
this.resolvedLanguage = lngInLngs;
|
|
2137
|
+
break;
|
|
2138
|
+
}
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
changeLanguage(lng, callback) {
|
|
2142
|
+
var _this2 = this;
|
|
2143
|
+
this.isLanguageChangingTo = lng;
|
|
2144
|
+
const deferred = defer();
|
|
2145
|
+
this.emit('languageChanging', lng);
|
|
2146
|
+
const setLngProps = l => {
|
|
2147
|
+
this.language = l;
|
|
2148
|
+
this.languages = this.services.languageUtils.toResolveHierarchy(l);
|
|
2149
|
+
this.resolvedLanguage = undefined;
|
|
2150
|
+
this.setResolvedLanguage(l);
|
|
2151
|
+
};
|
|
2152
|
+
const done = (err, l) => {
|
|
2153
|
+
if (l) {
|
|
2154
|
+
setLngProps(l);
|
|
2155
|
+
this.translator.changeLanguage(l);
|
|
2156
|
+
this.isLanguageChangingTo = undefined;
|
|
2157
|
+
this.emit('languageChanged', l);
|
|
2158
|
+
this.logger.log('languageChanged', l);
|
|
2159
|
+
} else {
|
|
2160
|
+
this.isLanguageChangingTo = undefined;
|
|
2161
|
+
}
|
|
2162
|
+
deferred.resolve(function () {
|
|
2163
|
+
return _this2.t(...arguments);
|
|
2164
|
+
});
|
|
2165
|
+
if (callback) callback(err, function () {
|
|
2166
|
+
return _this2.t(...arguments);
|
|
2167
|
+
});
|
|
2168
|
+
};
|
|
2169
|
+
const setLng = lngs => {
|
|
2170
|
+
if (!lng && !lngs && this.services.languageDetector) lngs = [];
|
|
2171
|
+
const l = isString(lngs) ? lngs : this.services.languageUtils.getBestMatchFromCodes(lngs);
|
|
2172
|
+
if (l) {
|
|
2173
|
+
if (!this.language) {
|
|
2174
|
+
setLngProps(l);
|
|
2175
|
+
}
|
|
2176
|
+
if (!this.translator.language) this.translator.changeLanguage(l);
|
|
2177
|
+
if (this.services.languageDetector && this.services.languageDetector.cacheUserLanguage) this.services.languageDetector.cacheUserLanguage(l);
|
|
2178
|
+
}
|
|
2179
|
+
this.loadResources(l, err => {
|
|
2180
|
+
done(err, l);
|
|
2181
|
+
});
|
|
2182
|
+
};
|
|
2183
|
+
if (!lng && this.services.languageDetector && !this.services.languageDetector.async) {
|
|
2184
|
+
setLng(this.services.languageDetector.detect());
|
|
2185
|
+
} else if (!lng && this.services.languageDetector && this.services.languageDetector.async) {
|
|
2186
|
+
if (this.services.languageDetector.detect.length === 0) {
|
|
2187
|
+
this.services.languageDetector.detect().then(setLng);
|
|
2188
|
+
} else {
|
|
2189
|
+
this.services.languageDetector.detect(setLng);
|
|
2190
|
+
}
|
|
2191
|
+
} else {
|
|
2192
|
+
setLng(lng);
|
|
2193
|
+
}
|
|
2194
|
+
return deferred;
|
|
2195
|
+
}
|
|
2196
|
+
getFixedT(lng, ns, keyPrefix) {
|
|
2197
|
+
var _this3 = this;
|
|
2198
|
+
const fixedT = function (key, opts) {
|
|
2199
|
+
let options;
|
|
2200
|
+
if (typeof opts !== 'object') {
|
|
2201
|
+
for (var _len3 = arguments.length, rest = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) {
|
|
2202
|
+
rest[_key3 - 2] = arguments[_key3];
|
|
2203
|
+
}
|
|
2204
|
+
options = _this3.options.overloadTranslationOptionHandler([key, opts].concat(rest));
|
|
2205
|
+
} else {
|
|
2206
|
+
options = {
|
|
2207
|
+
...opts
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
options.lng = options.lng || fixedT.lng;
|
|
2211
|
+
options.lngs = options.lngs || fixedT.lngs;
|
|
2212
|
+
options.ns = options.ns || fixedT.ns;
|
|
2213
|
+
if (options.keyPrefix !== '') options.keyPrefix = options.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
2214
|
+
const keySeparator = _this3.options.keySeparator || '.';
|
|
2215
|
+
let resultKey;
|
|
2216
|
+
if (options.keyPrefix && Array.isArray(key)) {
|
|
2217
|
+
resultKey = key.map(k => `${options.keyPrefix}${keySeparator}${k}`);
|
|
2218
|
+
} else {
|
|
2219
|
+
resultKey = options.keyPrefix ? `${options.keyPrefix}${keySeparator}${key}` : key;
|
|
2220
|
+
}
|
|
2221
|
+
return _this3.t(resultKey, options);
|
|
2222
|
+
};
|
|
2223
|
+
if (isString(lng)) {
|
|
2224
|
+
fixedT.lng = lng;
|
|
2225
|
+
} else {
|
|
2226
|
+
fixedT.lngs = lng;
|
|
2227
|
+
}
|
|
2228
|
+
fixedT.ns = ns;
|
|
2229
|
+
fixedT.keyPrefix = keyPrefix;
|
|
2230
|
+
return fixedT;
|
|
2231
|
+
}
|
|
2232
|
+
t() {
|
|
2233
|
+
return this.translator && this.translator.translate(...arguments);
|
|
2234
|
+
}
|
|
2235
|
+
exists() {
|
|
2236
|
+
return this.translator && this.translator.exists(...arguments);
|
|
2237
|
+
}
|
|
2238
|
+
setDefaultNamespace(ns) {
|
|
2239
|
+
this.options.defaultNS = ns;
|
|
2240
|
+
}
|
|
2241
|
+
hasLoadedNamespace(ns) {
|
|
2242
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2243
|
+
if (!this.isInitialized) {
|
|
2244
|
+
this.logger.warn('hasLoadedNamespace: i18next was not initialized', this.languages);
|
|
2245
|
+
return false;
|
|
2246
|
+
}
|
|
2247
|
+
if (!this.languages || !this.languages.length) {
|
|
2248
|
+
this.logger.warn('hasLoadedNamespace: i18n.languages were undefined or empty', this.languages);
|
|
2249
|
+
return false;
|
|
2250
|
+
}
|
|
2251
|
+
const lng = options.lng || this.resolvedLanguage || this.languages[0];
|
|
2252
|
+
const fallbackLng = this.options ? this.options.fallbackLng : false;
|
|
2253
|
+
const lastLng = this.languages[this.languages.length - 1];
|
|
2254
|
+
if (lng.toLowerCase() === 'cimode') return true;
|
|
2255
|
+
const loadNotPending = (l, n) => {
|
|
2256
|
+
const loadState = this.services.backendConnector.state[`${l}|${n}`];
|
|
2257
|
+
return loadState === -1 || loadState === 0 || loadState === 2;
|
|
2258
|
+
};
|
|
2259
|
+
if (options.precheck) {
|
|
2260
|
+
const preResult = options.precheck(this, loadNotPending);
|
|
2261
|
+
if (preResult !== undefined) return preResult;
|
|
2262
|
+
}
|
|
2263
|
+
if (this.hasResourceBundle(lng, ns)) return true;
|
|
2264
|
+
if (!this.services.backendConnector.backend || this.options.resources && !this.options.partialBundledLanguages) return true;
|
|
2265
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns))) return true;
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
loadNamespaces(ns, callback) {
|
|
2269
|
+
const deferred = defer();
|
|
2270
|
+
if (!this.options.ns) {
|
|
2271
|
+
if (callback) callback();
|
|
2272
|
+
return Promise.resolve();
|
|
2273
|
+
}
|
|
2274
|
+
if (isString(ns)) ns = [ns];
|
|
2275
|
+
ns.forEach(n => {
|
|
2276
|
+
if (this.options.ns.indexOf(n) < 0) this.options.ns.push(n);
|
|
2277
|
+
});
|
|
2278
|
+
this.loadResources(err => {
|
|
2279
|
+
deferred.resolve();
|
|
2280
|
+
if (callback) callback(err);
|
|
2281
|
+
});
|
|
2282
|
+
return deferred;
|
|
2283
|
+
}
|
|
2284
|
+
loadLanguages(lngs, callback) {
|
|
2285
|
+
const deferred = defer();
|
|
2286
|
+
if (isString(lngs)) lngs = [lngs];
|
|
2287
|
+
const preloaded = this.options.preload || [];
|
|
2288
|
+
const newLngs = lngs.filter(lng => preloaded.indexOf(lng) < 0 && this.services.languageUtils.isSupportedCode(lng));
|
|
2289
|
+
if (!newLngs.length) {
|
|
2290
|
+
if (callback) callback();
|
|
2291
|
+
return Promise.resolve();
|
|
2292
|
+
}
|
|
2293
|
+
this.options.preload = preloaded.concat(newLngs);
|
|
2294
|
+
this.loadResources(err => {
|
|
2295
|
+
deferred.resolve();
|
|
2296
|
+
if (callback) callback(err);
|
|
2297
|
+
});
|
|
2298
|
+
return deferred;
|
|
2299
|
+
}
|
|
2300
|
+
dir(lng) {
|
|
2301
|
+
if (!lng) lng = this.resolvedLanguage || (this.languages && this.languages.length > 0 ? this.languages[0] : this.language);
|
|
2302
|
+
if (!lng) return 'rtl';
|
|
2303
|
+
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'];
|
|
2304
|
+
const languageUtils = this.services && this.services.languageUtils || new LanguageUtil(get());
|
|
2305
|
+
return rtlLngs.indexOf(languageUtils.getLanguagePartFromCode(lng)) > -1 || lng.toLowerCase().indexOf('-arab') > 1 ? 'rtl' : 'ltr';
|
|
2306
|
+
}
|
|
2307
|
+
static createInstance() {
|
|
2308
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2309
|
+
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
2310
|
+
return new I18n(options, callback);
|
|
2311
|
+
}
|
|
2312
|
+
cloneInstance() {
|
|
2313
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2314
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
2315
|
+
const forkResourceStore = options.forkResourceStore;
|
|
2316
|
+
if (forkResourceStore) delete options.forkResourceStore;
|
|
2317
|
+
const mergedOptions = {
|
|
2318
|
+
...this.options,
|
|
2319
|
+
...options,
|
|
2320
|
+
...{
|
|
2321
|
+
isClone: true
|
|
2322
|
+
}
|
|
2323
|
+
};
|
|
2324
|
+
const clone = new I18n(mergedOptions);
|
|
2325
|
+
if (options.debug !== undefined || options.prefix !== undefined) {
|
|
2326
|
+
clone.logger = clone.logger.clone(options);
|
|
2327
|
+
}
|
|
2328
|
+
const membersToCopy = ['store', 'services', 'language'];
|
|
2329
|
+
membersToCopy.forEach(m => {
|
|
2330
|
+
clone[m] = this[m];
|
|
2331
|
+
});
|
|
2332
|
+
clone.services = {
|
|
2333
|
+
...this.services
|
|
2334
|
+
};
|
|
2335
|
+
clone.services.utils = {
|
|
2336
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2337
|
+
};
|
|
2338
|
+
if (forkResourceStore) {
|
|
2339
|
+
clone.store = new ResourceStore(this.store.data, mergedOptions);
|
|
2340
|
+
clone.services.resourceStore = clone.store;
|
|
2341
|
+
}
|
|
2342
|
+
clone.translator = new Translator(clone.services, mergedOptions);
|
|
2343
|
+
clone.translator.on('*', function (event) {
|
|
2344
|
+
for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
2345
|
+
args[_key4 - 1] = arguments[_key4];
|
|
2346
|
+
}
|
|
2347
|
+
clone.emit(event, ...args);
|
|
2348
|
+
});
|
|
2349
|
+
clone.init(mergedOptions, callback);
|
|
2350
|
+
clone.translator.options = mergedOptions;
|
|
2351
|
+
clone.translator.backendConnector.services.utils = {
|
|
2352
|
+
hasLoadedNamespace: clone.hasLoadedNamespace.bind(clone)
|
|
2353
|
+
};
|
|
2354
|
+
return clone;
|
|
2355
|
+
}
|
|
2356
|
+
toJSON() {
|
|
2357
|
+
return {
|
|
2358
|
+
options: this.options,
|
|
2359
|
+
store: this.store,
|
|
2360
|
+
language: this.language,
|
|
2361
|
+
languages: this.languages,
|
|
2362
|
+
resolvedLanguage: this.resolvedLanguage
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
}
|
|
2366
|
+
const instance = I18n.createInstance();
|
|
2367
|
+
instance.createInstance = I18n.createInstance;
|
|
2368
|
+
|
|
2369
|
+
function _classCallCheck(instance, Constructor) {
|
|
2370
|
+
if (!(instance instanceof Constructor)) {
|
|
2371
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2372
|
+
}
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
function _typeof(o) {
|
|
2376
|
+
"@babel/helpers - typeof";
|
|
2377
|
+
|
|
2378
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
2379
|
+
return typeof o;
|
|
2380
|
+
} : function (o) {
|
|
2381
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
2382
|
+
}, _typeof(o);
|
|
2383
|
+
}
|
|
2384
|
+
|
|
2385
|
+
function toPrimitive(t, r) {
|
|
2386
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
2387
|
+
var e = t[Symbol.toPrimitive];
|
|
2388
|
+
if (void 0 !== e) {
|
|
2389
|
+
var i = e.call(t, r || "default");
|
|
2390
|
+
if ("object" != _typeof(i)) return i;
|
|
2391
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
2392
|
+
}
|
|
2393
|
+
return ("string" === r ? String : Number)(t);
|
|
2394
|
+
}
|
|
2395
|
+
|
|
2396
|
+
function toPropertyKey(t) {
|
|
2397
|
+
var i = toPrimitive(t, "string");
|
|
2398
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
function _defineProperties(target, props) {
|
|
2402
|
+
for (var i = 0; i < props.length; i++) {
|
|
2403
|
+
var descriptor = props[i];
|
|
2404
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2405
|
+
descriptor.configurable = true;
|
|
2406
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2407
|
+
Object.defineProperty(target, toPropertyKey(descriptor.key), descriptor);
|
|
2408
|
+
}
|
|
2409
|
+
}
|
|
2410
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
2411
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
2412
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
2413
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
2414
|
+
writable: false
|
|
2415
|
+
});
|
|
2416
|
+
return Constructor;
|
|
2417
|
+
}
|
|
2418
|
+
|
|
2419
|
+
var arr = [];
|
|
2420
|
+
var each = arr.forEach;
|
|
2421
|
+
var slice = arr.slice;
|
|
2422
|
+
function defaults(obj) {
|
|
2423
|
+
each.call(slice.call(arguments, 1), function (source) {
|
|
2424
|
+
if (source) {
|
|
2425
|
+
for (var prop in source) {
|
|
2426
|
+
if (obj[prop] === undefined) obj[prop] = source[prop];
|
|
2427
|
+
}
|
|
2428
|
+
}
|
|
2429
|
+
});
|
|
2430
|
+
return obj;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
// eslint-disable-next-line no-control-regex
|
|
2434
|
+
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
|
|
2435
|
+
var serializeCookie = function serializeCookie(name, val, options) {
|
|
2436
|
+
var opt = options || {};
|
|
2437
|
+
opt.path = opt.path || '/';
|
|
2438
|
+
var value = encodeURIComponent(val);
|
|
2439
|
+
var str = "".concat(name, "=").concat(value);
|
|
2440
|
+
if (opt.maxAge > 0) {
|
|
2441
|
+
var maxAge = opt.maxAge - 0;
|
|
2442
|
+
if (Number.isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
|
2443
|
+
str += "; Max-Age=".concat(Math.floor(maxAge));
|
|
2444
|
+
}
|
|
2445
|
+
if (opt.domain) {
|
|
2446
|
+
if (!fieldContentRegExp.test(opt.domain)) {
|
|
2447
|
+
throw new TypeError('option domain is invalid');
|
|
2448
|
+
}
|
|
2449
|
+
str += "; Domain=".concat(opt.domain);
|
|
2450
|
+
}
|
|
2451
|
+
if (opt.path) {
|
|
2452
|
+
if (!fieldContentRegExp.test(opt.path)) {
|
|
2453
|
+
throw new TypeError('option path is invalid');
|
|
2454
|
+
}
|
|
2455
|
+
str += "; Path=".concat(opt.path);
|
|
2456
|
+
}
|
|
2457
|
+
if (opt.expires) {
|
|
2458
|
+
if (typeof opt.expires.toUTCString !== 'function') {
|
|
2459
|
+
throw new TypeError('option expires is invalid');
|
|
2460
|
+
}
|
|
2461
|
+
str += "; Expires=".concat(opt.expires.toUTCString());
|
|
2462
|
+
}
|
|
2463
|
+
if (opt.httpOnly) str += '; HttpOnly';
|
|
2464
|
+
if (opt.secure) str += '; Secure';
|
|
2465
|
+
if (opt.sameSite) {
|
|
2466
|
+
var sameSite = typeof opt.sameSite === 'string' ? opt.sameSite.toLowerCase() : opt.sameSite;
|
|
2467
|
+
switch (sameSite) {
|
|
2468
|
+
case true:
|
|
2469
|
+
str += '; SameSite=Strict';
|
|
2470
|
+
break;
|
|
2471
|
+
case 'lax':
|
|
2472
|
+
str += '; SameSite=Lax';
|
|
2473
|
+
break;
|
|
2474
|
+
case 'strict':
|
|
2475
|
+
str += '; SameSite=Strict';
|
|
2476
|
+
break;
|
|
2477
|
+
case 'none':
|
|
2478
|
+
str += '; SameSite=None';
|
|
2479
|
+
break;
|
|
2480
|
+
default:
|
|
2481
|
+
throw new TypeError('option sameSite is invalid');
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
return str;
|
|
2485
|
+
};
|
|
2486
|
+
var cookie = {
|
|
2487
|
+
create: function create(name, value, minutes, domain) {
|
|
2488
|
+
var cookieOptions = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
2489
|
+
path: '/',
|
|
2490
|
+
sameSite: 'strict'
|
|
2491
|
+
};
|
|
2492
|
+
if (minutes) {
|
|
2493
|
+
cookieOptions.expires = new Date();
|
|
2494
|
+
cookieOptions.expires.setTime(cookieOptions.expires.getTime() + minutes * 60 * 1000);
|
|
2495
|
+
}
|
|
2496
|
+
if (domain) cookieOptions.domain = domain;
|
|
2497
|
+
document.cookie = serializeCookie(name, encodeURIComponent(value), cookieOptions);
|
|
2498
|
+
},
|
|
2499
|
+
read: function read(name) {
|
|
2500
|
+
var nameEQ = "".concat(name, "=");
|
|
2501
|
+
var ca = document.cookie.split(';');
|
|
2502
|
+
for (var i = 0; i < ca.length; i++) {
|
|
2503
|
+
var c = ca[i];
|
|
2504
|
+
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
2505
|
+
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
2506
|
+
}
|
|
2507
|
+
return null;
|
|
2508
|
+
},
|
|
2509
|
+
remove: function remove(name) {
|
|
2510
|
+
this.create(name, '', -1);
|
|
2511
|
+
}
|
|
2512
|
+
};
|
|
2513
|
+
var cookie$1 = {
|
|
2514
|
+
name: 'cookie',
|
|
2515
|
+
lookup: function lookup(options) {
|
|
2516
|
+
var found;
|
|
2517
|
+
if (options.lookupCookie && typeof document !== 'undefined') {
|
|
2518
|
+
var c = cookie.read(options.lookupCookie);
|
|
2519
|
+
if (c) found = c;
|
|
2520
|
+
}
|
|
2521
|
+
return found;
|
|
2522
|
+
},
|
|
2523
|
+
cacheUserLanguage: function cacheUserLanguage(lng, options) {
|
|
2524
|
+
if (options.lookupCookie && typeof document !== 'undefined') {
|
|
2525
|
+
cookie.create(options.lookupCookie, lng, options.cookieMinutes, options.cookieDomain, options.cookieOptions);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
var querystring = {
|
|
2531
|
+
name: 'querystring',
|
|
2532
|
+
lookup: function lookup(options) {
|
|
2533
|
+
var found;
|
|
2534
|
+
if (typeof window !== 'undefined') {
|
|
2535
|
+
var search = window.location.search;
|
|
2536
|
+
if (!window.location.search && window.location.hash && window.location.hash.indexOf('?') > -1) {
|
|
2537
|
+
search = window.location.hash.substring(window.location.hash.indexOf('?'));
|
|
2538
|
+
}
|
|
2539
|
+
var query = search.substring(1);
|
|
2540
|
+
var params = query.split('&');
|
|
2541
|
+
for (var i = 0; i < params.length; i++) {
|
|
2542
|
+
var pos = params[i].indexOf('=');
|
|
2543
|
+
if (pos > 0) {
|
|
2544
|
+
var key = params[i].substring(0, pos);
|
|
2545
|
+
if (key === options.lookupQuerystring) {
|
|
2546
|
+
found = params[i].substring(pos + 1);
|
|
2547
|
+
}
|
|
2548
|
+
}
|
|
2549
|
+
}
|
|
2550
|
+
}
|
|
2551
|
+
return found;
|
|
2552
|
+
}
|
|
2553
|
+
};
|
|
2554
|
+
|
|
2555
|
+
var hasLocalStorageSupport = null;
|
|
2556
|
+
var localStorageAvailable = function localStorageAvailable() {
|
|
2557
|
+
if (hasLocalStorageSupport !== null) return hasLocalStorageSupport;
|
|
2558
|
+
try {
|
|
2559
|
+
hasLocalStorageSupport = window !== 'undefined' && window.localStorage !== null;
|
|
2560
|
+
var testKey = 'i18next.translate.boo';
|
|
2561
|
+
window.localStorage.setItem(testKey, 'foo');
|
|
2562
|
+
window.localStorage.removeItem(testKey);
|
|
2563
|
+
} catch (e) {
|
|
2564
|
+
hasLocalStorageSupport = false;
|
|
2565
|
+
}
|
|
2566
|
+
return hasLocalStorageSupport;
|
|
2567
|
+
};
|
|
2568
|
+
var localStorage = {
|
|
2569
|
+
name: 'localStorage',
|
|
2570
|
+
lookup: function lookup(options) {
|
|
2571
|
+
var found;
|
|
2572
|
+
if (options.lookupLocalStorage && localStorageAvailable()) {
|
|
2573
|
+
var lng = window.localStorage.getItem(options.lookupLocalStorage);
|
|
2574
|
+
if (lng) found = lng;
|
|
2575
|
+
}
|
|
2576
|
+
return found;
|
|
2577
|
+
},
|
|
2578
|
+
cacheUserLanguage: function cacheUserLanguage(lng, options) {
|
|
2579
|
+
if (options.lookupLocalStorage && localStorageAvailable()) {
|
|
2580
|
+
window.localStorage.setItem(options.lookupLocalStorage, lng);
|
|
2581
|
+
}
|
|
2582
|
+
}
|
|
2583
|
+
};
|
|
2584
|
+
|
|
2585
|
+
var hasSessionStorageSupport = null;
|
|
2586
|
+
var sessionStorageAvailable = function sessionStorageAvailable() {
|
|
2587
|
+
if (hasSessionStorageSupport !== null) return hasSessionStorageSupport;
|
|
2588
|
+
try {
|
|
2589
|
+
hasSessionStorageSupport = window !== 'undefined' && window.sessionStorage !== null;
|
|
2590
|
+
var testKey = 'i18next.translate.boo';
|
|
2591
|
+
window.sessionStorage.setItem(testKey, 'foo');
|
|
2592
|
+
window.sessionStorage.removeItem(testKey);
|
|
2593
|
+
} catch (e) {
|
|
2594
|
+
hasSessionStorageSupport = false;
|
|
2595
|
+
}
|
|
2596
|
+
return hasSessionStorageSupport;
|
|
2597
|
+
};
|
|
2598
|
+
var sessionStorage = {
|
|
2599
|
+
name: 'sessionStorage',
|
|
2600
|
+
lookup: function lookup(options) {
|
|
2601
|
+
var found;
|
|
2602
|
+
if (options.lookupSessionStorage && sessionStorageAvailable()) {
|
|
2603
|
+
var lng = window.sessionStorage.getItem(options.lookupSessionStorage);
|
|
2604
|
+
if (lng) found = lng;
|
|
2605
|
+
}
|
|
2606
|
+
return found;
|
|
2607
|
+
},
|
|
2608
|
+
cacheUserLanguage: function cacheUserLanguage(lng, options) {
|
|
2609
|
+
if (options.lookupSessionStorage && sessionStorageAvailable()) {
|
|
2610
|
+
window.sessionStorage.setItem(options.lookupSessionStorage, lng);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
};
|
|
2614
|
+
|
|
2615
|
+
var navigator$1 = {
|
|
2616
|
+
name: 'navigator',
|
|
2617
|
+
lookup: function lookup(options) {
|
|
2618
|
+
var found = [];
|
|
2619
|
+
if (typeof navigator !== 'undefined') {
|
|
2620
|
+
if (navigator.languages) {
|
|
2621
|
+
// chrome only; not an array, so can't use .push.apply instead of iterating
|
|
2622
|
+
for (var i = 0; i < navigator.languages.length; i++) {
|
|
2623
|
+
found.push(navigator.languages[i]);
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
if (navigator.userLanguage) {
|
|
2627
|
+
found.push(navigator.userLanguage);
|
|
2628
|
+
}
|
|
2629
|
+
if (navigator.language) {
|
|
2630
|
+
found.push(navigator.language);
|
|
2631
|
+
}
|
|
2632
|
+
}
|
|
2633
|
+
return found.length > 0 ? found : undefined;
|
|
2634
|
+
}
|
|
2635
|
+
};
|
|
2636
|
+
|
|
2637
|
+
var htmlTag = {
|
|
2638
|
+
name: 'htmlTag',
|
|
2639
|
+
lookup: function lookup(options) {
|
|
2640
|
+
var found;
|
|
2641
|
+
var htmlTag = options.htmlTag || (typeof document !== 'undefined' ? document.documentElement : null);
|
|
2642
|
+
if (htmlTag && typeof htmlTag.getAttribute === 'function') {
|
|
2643
|
+
found = htmlTag.getAttribute('lang');
|
|
2644
|
+
}
|
|
2645
|
+
return found;
|
|
2646
|
+
}
|
|
2647
|
+
};
|
|
2648
|
+
|
|
2649
|
+
var path = {
|
|
2650
|
+
name: 'path',
|
|
2651
|
+
lookup: function lookup(options) {
|
|
2652
|
+
var found;
|
|
2653
|
+
if (typeof window !== 'undefined') {
|
|
2654
|
+
var language = window.location.pathname.match(/\/([a-zA-Z-]*)/g);
|
|
2655
|
+
if (language instanceof Array) {
|
|
2656
|
+
if (typeof options.lookupFromPathIndex === 'number') {
|
|
2657
|
+
if (typeof language[options.lookupFromPathIndex] !== 'string') {
|
|
2658
|
+
return undefined;
|
|
2659
|
+
}
|
|
2660
|
+
found = language[options.lookupFromPathIndex].replace('/', '');
|
|
2661
|
+
} else {
|
|
2662
|
+
found = language[0].replace('/', '');
|
|
2663
|
+
}
|
|
2664
|
+
}
|
|
2665
|
+
}
|
|
2666
|
+
return found;
|
|
2667
|
+
}
|
|
2668
|
+
};
|
|
2669
|
+
|
|
2670
|
+
var subdomain = {
|
|
2671
|
+
name: 'subdomain',
|
|
2672
|
+
lookup: function lookup(options) {
|
|
2673
|
+
// If given get the subdomain index else 1
|
|
2674
|
+
var lookupFromSubdomainIndex = typeof options.lookupFromSubdomainIndex === 'number' ? options.lookupFromSubdomainIndex + 1 : 1;
|
|
2675
|
+
// get all matches if window.location. is existing
|
|
2676
|
+
// first item of match is the match itself and the second is the first group macht which sould be the first subdomain match
|
|
2677
|
+
// is the hostname no public domain get the or option of localhost
|
|
2678
|
+
var language = typeof window !== 'undefined' && window.location && window.location.hostname && window.location.hostname.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);
|
|
2679
|
+
|
|
2680
|
+
// if there is no match (null) return undefined
|
|
2681
|
+
if (!language) return undefined;
|
|
2682
|
+
// return the given group match
|
|
2683
|
+
return language[lookupFromSubdomainIndex];
|
|
2684
|
+
}
|
|
2685
|
+
};
|
|
2686
|
+
|
|
2687
|
+
// some environments, throws when accessing document.cookie
|
|
2688
|
+
var canCookies = false;
|
|
2689
|
+
try {
|
|
2690
|
+
canCookies = true;
|
|
2691
|
+
// eslint-disable-next-line no-empty
|
|
2692
|
+
} catch (e) {}
|
|
2693
|
+
var order = ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'htmlTag'];
|
|
2694
|
+
if (!canCookies) order.splice(1, 1);
|
|
2695
|
+
function getDefaults() {
|
|
2696
|
+
return {
|
|
2697
|
+
order: order,
|
|
2698
|
+
lookupQuerystring: 'lng',
|
|
2699
|
+
lookupCookie: 'i18next',
|
|
2700
|
+
lookupLocalStorage: 'i18nextLng',
|
|
2701
|
+
lookupSessionStorage: 'i18nextLng',
|
|
2702
|
+
// cache user language
|
|
2703
|
+
caches: ['localStorage'],
|
|
2704
|
+
excludeCacheFor: ['cimode'],
|
|
2705
|
+
// cookieMinutes: 10,
|
|
2706
|
+
// cookieDomain: 'myDomain'
|
|
2707
|
+
|
|
2708
|
+
convertDetectedLanguage: function convertDetectedLanguage(l) {
|
|
2709
|
+
return l;
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
}
|
|
2713
|
+
var Browser = /*#__PURE__*/function () {
|
|
2714
|
+
function Browser(services) {
|
|
2715
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2716
|
+
_classCallCheck(this, Browser);
|
|
2717
|
+
this.type = 'languageDetector';
|
|
2718
|
+
this.detectors = {};
|
|
2719
|
+
this.init(services, options);
|
|
2720
|
+
}
|
|
2721
|
+
return _createClass(Browser, [{
|
|
2722
|
+
key: "init",
|
|
2723
|
+
value: function init(services) {
|
|
2724
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
2725
|
+
var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
2726
|
+
this.services = services || {
|
|
2727
|
+
languageUtils: {}
|
|
2728
|
+
}; // this way the language detector can be used without i18next
|
|
2729
|
+
this.options = defaults(options, this.options || {}, getDefaults());
|
|
2730
|
+
if (typeof this.options.convertDetectedLanguage === 'string' && this.options.convertDetectedLanguage.indexOf('15897') > -1) {
|
|
2731
|
+
this.options.convertDetectedLanguage = function (l) {
|
|
2732
|
+
return l.replace('-', '_');
|
|
2733
|
+
};
|
|
2734
|
+
}
|
|
2735
|
+
|
|
2736
|
+
// backwards compatibility
|
|
2737
|
+
if (this.options.lookupFromUrlIndex) this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex;
|
|
2738
|
+
this.i18nOptions = i18nOptions;
|
|
2739
|
+
this.addDetector(cookie$1);
|
|
2740
|
+
this.addDetector(querystring);
|
|
2741
|
+
this.addDetector(localStorage);
|
|
2742
|
+
this.addDetector(sessionStorage);
|
|
2743
|
+
this.addDetector(navigator$1);
|
|
2744
|
+
this.addDetector(htmlTag);
|
|
2745
|
+
this.addDetector(path);
|
|
2746
|
+
this.addDetector(subdomain);
|
|
2747
|
+
}
|
|
2748
|
+
}, {
|
|
2749
|
+
key: "addDetector",
|
|
2750
|
+
value: function addDetector(detector) {
|
|
2751
|
+
this.detectors[detector.name] = detector;
|
|
2752
|
+
return this;
|
|
2753
|
+
}
|
|
2754
|
+
}, {
|
|
2755
|
+
key: "detect",
|
|
2756
|
+
value: function detect(detectionOrder) {
|
|
2757
|
+
var _this = this;
|
|
2758
|
+
if (!detectionOrder) detectionOrder = this.options.order;
|
|
2759
|
+
var detected = [];
|
|
2760
|
+
detectionOrder.forEach(function (detectorName) {
|
|
2761
|
+
if (_this.detectors[detectorName]) {
|
|
2762
|
+
var lookup = _this.detectors[detectorName].lookup(_this.options);
|
|
2763
|
+
if (lookup && typeof lookup === 'string') lookup = [lookup];
|
|
2764
|
+
if (lookup) detected = detected.concat(lookup);
|
|
2765
|
+
}
|
|
2766
|
+
});
|
|
2767
|
+
detected = detected.map(function (d) {
|
|
2768
|
+
return _this.options.convertDetectedLanguage(d);
|
|
2769
|
+
});
|
|
2770
|
+
if (this.services.languageUtils.getBestMatchFromCodes) return detected; // new i18next v19.5.0
|
|
2771
|
+
return detected.length > 0 ? detected[0] : null; // a little backward compatibility
|
|
2772
|
+
}
|
|
2773
|
+
}, {
|
|
2774
|
+
key: "cacheUserLanguage",
|
|
2775
|
+
value: function cacheUserLanguage(lng, caches) {
|
|
2776
|
+
var _this2 = this;
|
|
2777
|
+
if (!caches) caches = this.options.caches;
|
|
2778
|
+
if (!caches) return;
|
|
2779
|
+
if (this.options.excludeCacheFor && this.options.excludeCacheFor.indexOf(lng) > -1) return;
|
|
2780
|
+
caches.forEach(function (cacheName) {
|
|
2781
|
+
if (_this2.detectors[cacheName]) _this2.detectors[cacheName].cacheUserLanguage(lng, _this2.options);
|
|
2782
|
+
});
|
|
2783
|
+
}
|
|
2784
|
+
}]);
|
|
2785
|
+
}();
|
|
2786
|
+
Browser.type = 'languageDetector';
|
|
2787
|
+
|
|
2788
|
+
const ptBrTranslations = {
|
|
2789
|
+
translation: {
|
|
2790
|
+
app: {
|
|
2791
|
+
collapse: "Resumir",
|
|
2792
|
+
expand: "Expandir",
|
|
2793
|
+
close: "Fechar",
|
|
2794
|
+
profile: "Perfil",
|
|
2795
|
+
warning: "Aviso",
|
|
2796
|
+
edit: "Editar",
|
|
2797
|
+
remove: "Remover",
|
|
2798
|
+
yes: "Sim",
|
|
2799
|
+
no: "Não",
|
|
2800
|
+
loading: "Carregando",
|
|
2801
|
+
apply: "Aplicar",
|
|
2802
|
+
cancel: "Cancelar",
|
|
2803
|
+
ok: "OK",
|
|
2804
|
+
alerts: "Avisos",
|
|
2805
|
+
requiredInfo: " (obrigatório) *",
|
|
2806
|
+
},
|
|
2807
|
+
"ez-upload": {
|
|
2808
|
+
enable: "Arraste e solte ou clique para adicionar arquivos",
|
|
2809
|
+
disable: "Somente leitura",
|
|
2810
|
+
replaceFileTitle: "Substituir arquivo",
|
|
2811
|
+
replaceFileMessage: "Já existe um arquivo chamado \"{{fileName}}\". Deseja substituí-lo?",
|
|
2812
|
+
maxFilesError: "A quantidade máxima de arquivos é {{maxFiles}}.",
|
|
2813
|
+
emptyFileError: "Erro de permissão: O arquivo \"{{fileName}}\" não pode ser enviado.",
|
|
2814
|
+
missingUploadUrlError: "Endereço de upload não informado.",
|
|
2815
|
+
maxFileSizeError: "O tamanho máximo dos arquivos é de {{maxSize}}.",
|
|
2816
|
+
uploadErrorTitle: "Enviando arquivo",
|
|
2817
|
+
uploadingMessage: "Há arquivos sendo enviados. Por favor aguarde a conclusão ou cancele o envio.",
|
|
2818
|
+
},
|
|
2819
|
+
"ez-calendar": {
|
|
2820
|
+
month: {
|
|
2821
|
+
0: "Janeiro",
|
|
2822
|
+
1: "Fevereiro",
|
|
2823
|
+
2: "Março",
|
|
2824
|
+
3: "Abril",
|
|
2825
|
+
4: "Maio",
|
|
2826
|
+
5: "Junho",
|
|
2827
|
+
6: "Julho",
|
|
2828
|
+
7: "Agosto",
|
|
2829
|
+
8: "Setembro",
|
|
2830
|
+
9: "Outubro",
|
|
2831
|
+
10: "Novembro",
|
|
2832
|
+
11: "Dezembro"
|
|
2833
|
+
},
|
|
2834
|
+
weekDay: {
|
|
2835
|
+
0: "D",
|
|
2836
|
+
1: "S",
|
|
2837
|
+
2: "T",
|
|
2838
|
+
3: "Q",
|
|
2839
|
+
4: "Q",
|
|
2840
|
+
5: "S",
|
|
2841
|
+
6: "S"
|
|
2842
|
+
},
|
|
2843
|
+
today: "Hoje"
|
|
2844
|
+
},
|
|
2845
|
+
"ez-collapsible-box": {
|
|
2846
|
+
confirmRemove: "Deseja realmente remover o grupo <b>{{label}}</b>?",
|
|
2847
|
+
},
|
|
2848
|
+
"ez-combo-box": {
|
|
2849
|
+
placeholder: "Selecione um item",
|
|
2850
|
+
noResults: "Nenhum resultado encontrado",
|
|
2851
|
+
},
|
|
2852
|
+
"ez-date-time-input": {
|
|
2853
|
+
invalidDate: "O valor digitado não é uma data e hora válida"
|
|
2854
|
+
},
|
|
2855
|
+
"ez-date-input": {
|
|
2856
|
+
invalidDate: "O valor digitado não é uma data válida"
|
|
2857
|
+
},
|
|
2858
|
+
"ez-dialog": {
|
|
2859
|
+
confirmButton: "Botão de confirmação ou OK",
|
|
2860
|
+
closeButton: "Botão de fechar ou X"
|
|
2861
|
+
},
|
|
2862
|
+
"ez-double-list": {
|
|
2863
|
+
noItemsAvailable: "Nenhum {{entity}} disponível",
|
|
2864
|
+
noItemsSelected: "Nenhum {{entity}} selecionado",
|
|
2865
|
+
moveAllTo: "Mover todos para {{list}}",
|
|
2866
|
+
moveTo: "Mover para {{list}}",
|
|
2867
|
+
moveToFirstPosition: "Mover para a primeira posição",
|
|
2868
|
+
moveUp: "Mover para cima",
|
|
2869
|
+
moveDown: "Mover para baixo",
|
|
2870
|
+
moveToLastPosition: "Mover para a última posição"
|
|
2871
|
+
},
|
|
2872
|
+
"ez-file-item": {
|
|
2873
|
+
invalidProgress: "O progresso de upload deve ser um número entre 0 e 100."
|
|
2874
|
+
},
|
|
2875
|
+
"ez-grid": {
|
|
2876
|
+
filterAppliedSuccess: "Filtro de coluna aplicado com sucesso!",
|
|
2877
|
+
cancelPagination: "Cancelar paginação",
|
|
2878
|
+
pageLabel: "Página {{currentPage}}",
|
|
2879
|
+
previousPage: "Página anterior",
|
|
2880
|
+
nextPage: "Próxima página",
|
|
2881
|
+
returnToPreviousPage: "Retorna à página anterior.",
|
|
2882
|
+
goToNextPage: "Avança para a próxima página.",
|
|
2883
|
+
remainingPageLabel: " de {{count}} ou mais",
|
|
2884
|
+
remainingTotalLabel: " de {{total}}",
|
|
2885
|
+
nextRecord: "Avança para o próximo registro.",
|
|
2886
|
+
previousRecord: "Retorna ao registro anterior.",
|
|
2887
|
+
searchColumn: "Busca por coluna.",
|
|
2888
|
+
sortAscending: "Ordenar Ascendente",
|
|
2889
|
+
sortDescending: "Ordenar Descendente",
|
|
2890
|
+
pinColumn: "Fixar coluna",
|
|
2891
|
+
unpinColumn: "Desafixar coluna",
|
|
2892
|
+
filter: "Filtrar",
|
|
2893
|
+
columnCantBeOrder: "Coluna não pode ser ordenada",
|
|
2894
|
+
filterColumnHeader: "Filtro da coluna {{columnLabel}}",
|
|
2895
|
+
clearSelection: "Limpar Seleção",
|
|
2896
|
+
page: "Página",
|
|
2897
|
+
more: "mais",
|
|
2898
|
+
to: "para",
|
|
2899
|
+
of: "de",
|
|
2900
|
+
next: "Próximo",
|
|
2901
|
+
last: "Último",
|
|
2902
|
+
first: "Primeiro",
|
|
2903
|
+
previous: "Anterior",
|
|
2904
|
+
loadingOoo: "Carregar",
|
|
2905
|
+
selectAll: "Selecionar tudo",
|
|
2906
|
+
searchOoo: "Procurar",
|
|
2907
|
+
blanks: "Vazio",
|
|
2908
|
+
filterOoo: "Filtrar",
|
|
2909
|
+
applyFilter: "Aplicar filtro",
|
|
2910
|
+
equals: "Igual",
|
|
2911
|
+
lessThan: "Menor que",
|
|
2912
|
+
greaterThan: "Maior que",
|
|
2913
|
+
contains: "Contém",
|
|
2914
|
+
startsWith: "Começa com",
|
|
2915
|
+
endsWith: "Termina com",
|
|
2916
|
+
group: "Grupo",
|
|
2917
|
+
columns: "Colunas",
|
|
2918
|
+
rowGroupColumns: "Colunas do grupo de linhas",
|
|
2919
|
+
rowGroupColumnsEmptyMessage: "Colunas do grupo de linhas vazias",
|
|
2920
|
+
valueColumns: "Valores das colunas",
|
|
2921
|
+
pivotMode: "Modo pivô",
|
|
2922
|
+
groups: "Grupos",
|
|
2923
|
+
values: "Valores",
|
|
2924
|
+
pivots: "Pivôs",
|
|
2925
|
+
valueColumnsEmptyMessage: "Valores de colunas vazias",
|
|
2926
|
+
pivotColumnsEmptyMessage: "Pivôs de colunas vazias",
|
|
2927
|
+
toolPanelButton: "Botão de painel de ferramentas",
|
|
2928
|
+
noRowsToShow: "Não há registros para mostrar.",
|
|
2929
|
+
valueAggregation: "Agregar valor",
|
|
2930
|
+
autosizeThiscolumn: "Redimensionar esta coluna",
|
|
2931
|
+
autosizeAllColumns: "Redimensionar todas colunas",
|
|
2932
|
+
groupBy: "Agrupar por",
|
|
2933
|
+
ungroupBy: "Desagrupar por",
|
|
2934
|
+
resetColumns: "Resetar colunas",
|
|
2935
|
+
expandAll: "Expandir tudo",
|
|
2936
|
+
collapseAll: "Contrair tudo",
|
|
2937
|
+
toolPanel: "Painel de ferramentas",
|
|
2938
|
+
export: "Exportar",
|
|
2939
|
+
csvExport: "Exportar para CSV",
|
|
2940
|
+
excelExport: "Exportar para Excel",
|
|
2941
|
+
pinLeft: "Fixar coluna",
|
|
2942
|
+
pinRight: "Fixar a direita",
|
|
2943
|
+
noPin: "Desfixar coluna",
|
|
2944
|
+
sum: "Soma",
|
|
2945
|
+
min: "Mínimo",
|
|
2946
|
+
max: "Máximo",
|
|
2947
|
+
none: "Nenhum",
|
|
2948
|
+
count: "Contagem",
|
|
2949
|
+
average: "Média",
|
|
2950
|
+
copy: "Copiar",
|
|
2951
|
+
copyWithHeaders: "Copiar com cabeçalho",
|
|
2952
|
+
ctrlC: "Ctrl+C",
|
|
2953
|
+
paste: "Colar",
|
|
2954
|
+
ctrlV: "Ctrl+V"
|
|
2955
|
+
},
|
|
2956
|
+
"ez-guide-navigator": {
|
|
2957
|
+
searchGuide: "Buscar guia",
|
|
2958
|
+
hideMenu: "Ocultar menu",
|
|
2959
|
+
},
|
|
2960
|
+
"ez-list": {
|
|
2961
|
+
moveToGroup: "Mover para {{groupName}}",
|
|
2962
|
+
},
|
|
2963
|
+
"ez-modal": {
|
|
2964
|
+
close: "Fechar modal",
|
|
2965
|
+
},
|
|
2966
|
+
"ez-multi-selection-list": {
|
|
2967
|
+
selectAll: "Selecionar todos",
|
|
2968
|
+
search: "Buscar...",
|
|
2969
|
+
empty: "(Vazio)",
|
|
2970
|
+
initMessage: "Selecione os valores a serem filtrados através do campo de busca.",
|
|
2971
|
+
emptyResults: "Nenhum resultado encontrado.",
|
|
2972
|
+
},
|
|
2973
|
+
"ez-number-input": {
|
|
2974
|
+
invalidNumber: "O valor digitado não é um número válido",
|
|
2975
|
+
},
|
|
2976
|
+
"ez-rich-text": {
|
|
2977
|
+
listShortcut: "Aplica estilo de lista ao texto selecionado.",
|
|
2978
|
+
linkShortcut: "Abre popup de link.",
|
|
2979
|
+
imageShortcut: "Abre popup de imagem.",
|
|
2980
|
+
boldShortcut: "Aplica estilo negrito ao texto selecionado.",
|
|
2981
|
+
italicShortcut: "Aplica estilo itálico ao texto selecionado.",
|
|
2982
|
+
underlineShortcut: "Aplica estilo sublinhado ao texto selecionado.",
|
|
2983
|
+
breakLineShortcut: "Aplica quebra de linha.",
|
|
2984
|
+
undoShortcut: "Desfaz a última alteração de texto.",
|
|
2985
|
+
redoShortcut: "Refaz a última alteração de texto.",
|
|
2986
|
+
edit: "Editar",
|
|
2987
|
+
preview: "Pré-visualizar",
|
|
2988
|
+
title: {
|
|
2989
|
+
preview: 'Ctrl + P',
|
|
2990
|
+
edit: 'Ir para modo edição',
|
|
2991
|
+
undo: 'Desfazer (Ctrl + Z)',
|
|
2992
|
+
redo: 'Refazer (Ctrl + X)',
|
|
2993
|
+
link: 'Inserir link (Ctrl + K)',
|
|
2994
|
+
image: 'Inserir imagem (Ctrl + O)',
|
|
2995
|
+
list: 'Lista (Ctrl + L)',
|
|
2996
|
+
underline: 'Sublinhado (Ctrl + U)',
|
|
2997
|
+
italic: 'Itálico (Ctrl + I)',
|
|
2998
|
+
bold: 'Negrito (Ctrl + B)',
|
|
2999
|
+
}
|
|
3000
|
+
},
|
|
3001
|
+
"ez-link-builder": {
|
|
3002
|
+
addLinkTitle: "Adicionar link",
|
|
3003
|
+
addLinkSubtitle: "Insira um link no texto para abrir novas páginas.",
|
|
3004
|
+
submit: "Enviar",
|
|
3005
|
+
urlInputLabel: "Insira a URL destino",
|
|
3006
|
+
textInputLabel: "Insira o texto a ser exibido",
|
|
3007
|
+
openInNewPage: "Abrir em uma nova página.",
|
|
3008
|
+
},
|
|
3009
|
+
"ez-simple-image-uploader": {
|
|
3010
|
+
uploadTitle: "Upload de imagens",
|
|
3011
|
+
uploadSubtitle: "Envie seus arquivos preenchendo apenas 1 campo por vez.",
|
|
3012
|
+
submit: "Enviar",
|
|
3013
|
+
tooltipMessage: "O arquivo selecionado abaixo será priorizado!",
|
|
3014
|
+
urlInputLabel: "Insira a URL da imagem",
|
|
3015
|
+
orText: "OU",
|
|
3016
|
+
removeFile: "Remover arquivo",
|
|
3017
|
+
dragDropText: "Arraste e solte ou clique para adicionar arquivos",
|
|
3018
|
+
imageAlt: "Imagem",
|
|
3019
|
+
imageTooLarge: "A imagem deve ter menos de {{maxSize}}.",
|
|
3020
|
+
},
|
|
3021
|
+
"ez-search": {
|
|
3022
|
+
emptyList: "Nenhum resultado encontrado",
|
|
3023
|
+
emptySearch: "Nenhum resultado de {{field}} encontrado",
|
|
3024
|
+
},
|
|
3025
|
+
"ez-search-plus": {
|
|
3026
|
+
emptyList: "Nenhum resultado encontrado",
|
|
3027
|
+
optionLoaderNotDefined: "optionLoader não definido",
|
|
3028
|
+
defaultCodeLabel: "Cód.",
|
|
3029
|
+
},
|
|
3030
|
+
"ez-sortable-list": {
|
|
3031
|
+
emptyMessage: "Nenhum item na lista",
|
|
3032
|
+
entityLabel: "item",
|
|
3033
|
+
entityLabelPlural: "itens",
|
|
3034
|
+
total: "Total de",
|
|
3035
|
+
search: "Buscar",
|
|
3036
|
+
},
|
|
3037
|
+
"ez-split-button": {
|
|
3038
|
+
moreOptions: "Mais opções",
|
|
3039
|
+
},
|
|
3040
|
+
"ez-text-edit": {
|
|
3041
|
+
emptyFieldWarning: "Não é possível salvar um campo em branco.",
|
|
3042
|
+
},
|
|
3043
|
+
"ez-time-input": {
|
|
3044
|
+
invalidTime: "Favor inserir um horário válido.",
|
|
3045
|
+
},
|
|
3046
|
+
"ez-sidebar": {
|
|
3047
|
+
unPinMenu: "Desafixar menu",
|
|
3048
|
+
pushPinMenu: "Fixar menu",
|
|
3049
|
+
hideMenu: "Recolher menu",
|
|
3050
|
+
},
|
|
3051
|
+
"utils": {
|
|
3052
|
+
requiredFieldMessage: "Há pelo menos um campo obrigatório não preenchido.",
|
|
3053
|
+
requiredField: "Essa informação é obrigatória.",
|
|
3054
|
+
selectAllPage: "Selecionar apenas a página atual",
|
|
3055
|
+
loadingAllRecords: "Carregando todos os {{count}} registros",
|
|
3056
|
+
selectAllRecords: "Selecionar todos os {{total}} registros",
|
|
3057
|
+
waitForLoad: "Aguarde o carregamento para selecionar o registro de todas as páginas",
|
|
3058
|
+
allRecordsSelected: "Todos os <strong>{{selectionCount}} registros</strong> da grade estão selecionados.",
|
|
3059
|
+
selectedRecords: "Há <strong>{{selectionCount}} registro{{plural}}</strong> selecionado{{plural}} na grade.",
|
|
3060
|
+
}
|
|
3061
|
+
}
|
|
3062
|
+
};
|
|
3063
|
+
|
|
3064
|
+
const enUsTranslations = {
|
|
3065
|
+
translation: {
|
|
3066
|
+
app: {
|
|
3067
|
+
collapse: "Collapse",
|
|
3068
|
+
expand: "Expand",
|
|
3069
|
+
close: "Close",
|
|
3070
|
+
profile: "Profile",
|
|
3071
|
+
warning: "Warning",
|
|
3072
|
+
edit: "Edit",
|
|
3073
|
+
remove: "Remove",
|
|
3074
|
+
yes: "Yes",
|
|
3075
|
+
no: "No",
|
|
3076
|
+
loading: "Loading",
|
|
3077
|
+
apply: "Apply",
|
|
3078
|
+
cancel: "Cancel",
|
|
3079
|
+
ok: "OK",
|
|
3080
|
+
alerts: "Alerts",
|
|
3081
|
+
requiredInfo: " (required) *",
|
|
3082
|
+
},
|
|
3083
|
+
"ez-upload": {
|
|
3084
|
+
enable: "Drag and drop or click to add files",
|
|
3085
|
+
disable: "Read only",
|
|
3086
|
+
replaceFileTitle: "Replace file",
|
|
3087
|
+
replaceFileMessage: "A file named \"{{fileName}}\" already exists. Do you want to replace it?",
|
|
3088
|
+
maxFilesError: "The maximum number of files is {{maxFiles}}.",
|
|
3089
|
+
emptyFileError: "Permission error: The file \"{{fileName}}\" cannot be uploaded.",
|
|
3090
|
+
missingUploadUrlError: "Upload URL not provided.",
|
|
3091
|
+
maxFileSizeError: "The maximum file size is {{maxSize}}.",
|
|
3092
|
+
uploadErrorTitle: "Uploading file",
|
|
3093
|
+
uploadingMessage: "Files are being uploaded. Please wait for completion or cancel the upload."
|
|
3094
|
+
},
|
|
3095
|
+
"ez-calendar": {
|
|
3096
|
+
month: {
|
|
3097
|
+
0: "January",
|
|
3098
|
+
1: "February",
|
|
3099
|
+
2: "March",
|
|
3100
|
+
3: "April",
|
|
3101
|
+
4: "May",
|
|
3102
|
+
5: "June",
|
|
3103
|
+
6: "July",
|
|
3104
|
+
7: "August",
|
|
3105
|
+
8: "September",
|
|
3106
|
+
9: "October",
|
|
3107
|
+
10: "November",
|
|
3108
|
+
11: "December"
|
|
3109
|
+
},
|
|
3110
|
+
weekDay: {
|
|
3111
|
+
0: "S",
|
|
3112
|
+
1: "M",
|
|
3113
|
+
2: "T",
|
|
3114
|
+
3: "W",
|
|
3115
|
+
4: "T",
|
|
3116
|
+
5: "F",
|
|
3117
|
+
6: "S"
|
|
3118
|
+
},
|
|
3119
|
+
today: "Today"
|
|
3120
|
+
},
|
|
3121
|
+
"ez-collapsible-box": {
|
|
3122
|
+
confirmRemove: "Do you really want to remove the group <b>{{label}}</b>?",
|
|
3123
|
+
},
|
|
3124
|
+
"ez-combo-box": {
|
|
3125
|
+
placeholder: "Select an item",
|
|
3126
|
+
noResults: "No results found",
|
|
3127
|
+
},
|
|
3128
|
+
"ez-date-time-input": {
|
|
3129
|
+
invalidDate: "The entered value is not a valid date and time"
|
|
3130
|
+
},
|
|
3131
|
+
"ez-date-input": {
|
|
3132
|
+
invalidDate: "The entered value is not a valid date"
|
|
3133
|
+
},
|
|
3134
|
+
"ez-dialog": {
|
|
3135
|
+
confirmButton: "Confirm or OK button",
|
|
3136
|
+
closeButton: "Close or X button"
|
|
3137
|
+
},
|
|
3138
|
+
"ez-double-list": {
|
|
3139
|
+
noItemsAvailable: "No {{entity}} available",
|
|
3140
|
+
noItemsSelected: "No {{entity}} selected",
|
|
3141
|
+
moveAllTo: "Move all to {{list}}",
|
|
3142
|
+
moveTo: "Move to {{list}}",
|
|
3143
|
+
moveToFirstPosition: "Move to the first position",
|
|
3144
|
+
moveUp: "Move up",
|
|
3145
|
+
moveDown: "Move down",
|
|
3146
|
+
moveToLastPosition: "Move to the last position"
|
|
3147
|
+
},
|
|
3148
|
+
"ez-file-item": {
|
|
3149
|
+
invalidProgress: "The upload progress must be a number between 0 and 100."
|
|
3150
|
+
},
|
|
3151
|
+
"ez-grid": {
|
|
3152
|
+
filterAppliedSuccess: "Column filter applied successfully!",
|
|
3153
|
+
cancelPagination: "Cancel pagination",
|
|
3154
|
+
pageLabel: "Page {{currentPage}}",
|
|
3155
|
+
previousPage: "Previous page",
|
|
3156
|
+
nextPage: "Next page",
|
|
3157
|
+
returnToPreviousPage: "Return to the previous page.",
|
|
3158
|
+
goToNextPage: "Move to the next page.",
|
|
3159
|
+
remainingPageLabel: " from {{count}} or more",
|
|
3160
|
+
remainingTotalLabel: " from {{total}}",
|
|
3161
|
+
nextRecord: "Move to the next record.",
|
|
3162
|
+
previousRecord: "Return to the previous record.",
|
|
3163
|
+
searchColumn: "Search by column.",
|
|
3164
|
+
sortAscending: "Sort Ascending",
|
|
3165
|
+
sortDescending: "Sort Descending",
|
|
3166
|
+
pinColumn: "Pin column",
|
|
3167
|
+
unpinColumn: "Unpin column",
|
|
3168
|
+
filter: "Filter",
|
|
3169
|
+
columnCantBeOrder: "Column cannot be sorted",
|
|
3170
|
+
filterColumnHeader: "Filter for column {{columnLabel}}",
|
|
3171
|
+
clearSelection: "Clear Selection",
|
|
3172
|
+
page: "Page",
|
|
3173
|
+
more: "more",
|
|
3174
|
+
to: "to",
|
|
3175
|
+
of: "of",
|
|
3176
|
+
next: "Next",
|
|
3177
|
+
last: "Last",
|
|
3178
|
+
first: "First",
|
|
3179
|
+
previous: "Previous",
|
|
3180
|
+
loadingOoo: "Loading",
|
|
3181
|
+
selectAll: "Select all",
|
|
3182
|
+
searchOoo: "Search",
|
|
3183
|
+
blanks: "Blanks",
|
|
3184
|
+
filterOoo: "Filter",
|
|
3185
|
+
applyFilter: "Apply filter",
|
|
3186
|
+
equals: "Equals",
|
|
3187
|
+
lessThan: "Less than",
|
|
3188
|
+
greaterThan: "Greater than",
|
|
3189
|
+
contains: "Contains",
|
|
3190
|
+
startsWith: "Starts with",
|
|
3191
|
+
endsWith: "Ends with",
|
|
3192
|
+
group: "Group",
|
|
3193
|
+
columns: "Columns",
|
|
3194
|
+
rowGroupColumns: "Row group columns",
|
|
3195
|
+
rowGroupColumnsEmptyMessage: "Row group columns empty",
|
|
3196
|
+
valueColumns: "Value columns",
|
|
3197
|
+
pivotMode: "Pivot mode",
|
|
3198
|
+
groups: "Groups",
|
|
3199
|
+
values: "Values",
|
|
3200
|
+
pivots: "Pivots",
|
|
3201
|
+
valueColumnsEmptyMessage: "Value columns empty",
|
|
3202
|
+
pivotColumnsEmptyMessage: "Pivot columns empty",
|
|
3203
|
+
toolPanelButton: "Tool panel button",
|
|
3204
|
+
noRowsToShow: "No rows to show.",
|
|
3205
|
+
valueAggregation: "Aggregate value",
|
|
3206
|
+
autosizeThiscolumn: "Autosize this column",
|
|
3207
|
+
autosizeAllColumns: "Autosize all columns",
|
|
3208
|
+
groupBy: "Group by",
|
|
3209
|
+
ungroupBy: "Ungroup by",
|
|
3210
|
+
resetColumns: "Reset columns",
|
|
3211
|
+
expandAll: "Expand all",
|
|
3212
|
+
collapseAll: "Collapse all",
|
|
3213
|
+
toolPanel: "Tool panel",
|
|
3214
|
+
export: "Export",
|
|
3215
|
+
csvExport: "Export to CSV",
|
|
3216
|
+
excelExport: "Export to Excel",
|
|
3217
|
+
pinLeft: "Pin left",
|
|
3218
|
+
pinRight: "Pin right",
|
|
3219
|
+
noPin: "Unpin column",
|
|
3220
|
+
sum: "Sum",
|
|
3221
|
+
min: "Min",
|
|
3222
|
+
max: "Max",
|
|
3223
|
+
none: "None",
|
|
3224
|
+
count: "Count",
|
|
3225
|
+
average: "Average",
|
|
3226
|
+
copy: "Copy",
|
|
3227
|
+
copyWithHeaders: "Copy with headers",
|
|
3228
|
+
ctrlC: "Ctrl+C",
|
|
3229
|
+
paste: "Paste",
|
|
3230
|
+
ctrlV: "Ctrl+V"
|
|
3231
|
+
},
|
|
3232
|
+
"ez-guide-navigator": {
|
|
3233
|
+
searchGuide: "Search guide",
|
|
3234
|
+
hideMenu: "Hide menu",
|
|
3235
|
+
},
|
|
3236
|
+
"ez-list": {
|
|
3237
|
+
moveToGroup: "Move to {{groupName}}",
|
|
3238
|
+
},
|
|
3239
|
+
"ez-modal": {
|
|
3240
|
+
close: "Close modal",
|
|
3241
|
+
},
|
|
3242
|
+
"ez-multi-selection-list": {
|
|
3243
|
+
selectAll: "Select all",
|
|
3244
|
+
search: "Search...",
|
|
3245
|
+
empty: "(Empty)",
|
|
3246
|
+
initMessage: "Select the values to be filtered through the search field.",
|
|
3247
|
+
emptyResults: "No results found.",
|
|
3248
|
+
},
|
|
3249
|
+
"ez-number-input": {
|
|
3250
|
+
invalidNumber: "The entered value is not a valid number",
|
|
3251
|
+
},
|
|
3252
|
+
"ez-rich-text": {
|
|
3253
|
+
listShortcut: "Applies list style to the selected text.",
|
|
3254
|
+
linkShortcut: "Opens link popup.",
|
|
3255
|
+
imageShortcut: "Opens image popup.",
|
|
3256
|
+
boldShortcut: "Applies bold style to the selected text.",
|
|
3257
|
+
italicShortcut: "Applies italic style to the selected text.",
|
|
3258
|
+
underlineShortcut: "Applies underline style to the selected text.",
|
|
3259
|
+
breakLineShortcut: "Applies line break.",
|
|
3260
|
+
undoShortcut: "Undoes the last text change.",
|
|
3261
|
+
redoShortcut: "Redoes the last text change.",
|
|
3262
|
+
edit: "Edit",
|
|
3263
|
+
preview: "Preview",
|
|
3264
|
+
title: {
|
|
3265
|
+
preview: "Ctrl + P",
|
|
3266
|
+
edit: "Switch to edit mode",
|
|
3267
|
+
undo: "Undo (Ctrl + Z)",
|
|
3268
|
+
redo: "Redo (Ctrl + X)",
|
|
3269
|
+
link: "Insert link (Ctrl + K)",
|
|
3270
|
+
image: "Insert image (Ctrl + O)",
|
|
3271
|
+
list: "List (Ctrl + L)",
|
|
3272
|
+
underline: "Underline (Ctrl + U)",
|
|
3273
|
+
italic: "Italic (Ctrl + I)",
|
|
3274
|
+
bold: "Bold (Ctrl + B)",
|
|
3275
|
+
}
|
|
3276
|
+
},
|
|
3277
|
+
"ez-link-builder": {
|
|
3278
|
+
addLinkTitle: "Add link",
|
|
3279
|
+
addLinkSubtitle: "Insert a link into the text to open new pages.",
|
|
3280
|
+
submit: "Submit",
|
|
3281
|
+
urlInputLabel: "Enter the destination URL",
|
|
3282
|
+
textInputLabel: "Enter the text to display",
|
|
3283
|
+
openInNewPage: "Open in a new page.",
|
|
3284
|
+
},
|
|
3285
|
+
"ez-simple-image-uploader": {
|
|
3286
|
+
uploadTitle: "Image Upload",
|
|
3287
|
+
uploadSubtitle: "Upload your files by filling only 1 field at a time.",
|
|
3288
|
+
submit: "Submit",
|
|
3289
|
+
tooltipMessage: "The selected file below will be prioritized!",
|
|
3290
|
+
urlInputLabel: "Enter the image URL",
|
|
3291
|
+
orText: "OR",
|
|
3292
|
+
removeFile: "Remove file",
|
|
3293
|
+
dragDropText: "Drag and drop or click to add files",
|
|
3294
|
+
imageAlt: "Image",
|
|
3295
|
+
imageTooLarge: "The image must be smaller than {{maxSize}}.",
|
|
3296
|
+
},
|
|
3297
|
+
"ez-search": {
|
|
3298
|
+
emptyList: "No results found",
|
|
3299
|
+
emptySearch: "No results for {{field}} found",
|
|
3300
|
+
},
|
|
3301
|
+
"ez-search-plus": {
|
|
3302
|
+
emptyList: "No results found",
|
|
3303
|
+
optionLoaderNotDefined: "optionLoader not defined",
|
|
3304
|
+
defaultCodeLabel: "Code",
|
|
3305
|
+
},
|
|
3306
|
+
"ez-sortable-list": {
|
|
3307
|
+
emptyMessage: "No items in the list",
|
|
3308
|
+
entityLabel: "item",
|
|
3309
|
+
entityLabelPlural: "items",
|
|
3310
|
+
total: "Total of",
|
|
3311
|
+
search: "Search",
|
|
3312
|
+
},
|
|
3313
|
+
"ez-split-button": {
|
|
3314
|
+
moreOptions: "More options",
|
|
3315
|
+
},
|
|
3316
|
+
"ez-text-edit": {
|
|
3317
|
+
emptyFieldWarning: "It is not possible to save an empty field.",
|
|
3318
|
+
},
|
|
3319
|
+
"ez-time-input": {
|
|
3320
|
+
invalidTime: "Please enter a valid time.",
|
|
3321
|
+
},
|
|
3322
|
+
"ez-sidebar": {
|
|
3323
|
+
unPinMenu: "Unpin menu",
|
|
3324
|
+
pushPinMenu: "Pin menu",
|
|
3325
|
+
hideMenu: "Hide menu",
|
|
3326
|
+
},
|
|
3327
|
+
"utils": {
|
|
3328
|
+
requiredFieldMessage: "There is at least one required field not filled.",
|
|
3329
|
+
requiredField: "This information is required.",
|
|
3330
|
+
selectAllPage: "Select only the current page",
|
|
3331
|
+
loadingAllRecords: "Loading all {{count}} records",
|
|
3332
|
+
selectAllRecords: "Select all {{total}} records",
|
|
3333
|
+
waitForLoad: "Wait for loading to select records from all pages",
|
|
3334
|
+
allRecordsSelected: "All <strong>{{selectionCount}} records</strong> in the grid are selected.",
|
|
3335
|
+
selectedRecords: "There <strong>{{selectionCount}} record{{plural}}</strong> selected in the grid.",
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
};
|
|
3339
|
+
|
|
3340
|
+
const esEsTranslations = {
|
|
3341
|
+
translation: {
|
|
3342
|
+
app: {
|
|
3343
|
+
collapse: "Colapsar",
|
|
3344
|
+
expand: "Expandir",
|
|
3345
|
+
close: "Cerrar",
|
|
3346
|
+
profile: "Perfil",
|
|
3347
|
+
warning: "Aviso",
|
|
3348
|
+
edit: "Editar",
|
|
3349
|
+
remove: "Eliminar",
|
|
3350
|
+
yes: "Sí",
|
|
3351
|
+
no: "No",
|
|
3352
|
+
loading: "Cargando",
|
|
3353
|
+
apply: "Aplicar",
|
|
3354
|
+
cancel: "Cancelar",
|
|
3355
|
+
ok: "OK",
|
|
3356
|
+
alerts: "Avisos",
|
|
3357
|
+
requiredInfo: " (obligatorio) *",
|
|
3358
|
+
},
|
|
3359
|
+
"ez-upload": {
|
|
3360
|
+
enable: "Arrastra y suelta o haz clic para subir archivos",
|
|
3361
|
+
disable: "Solo lectura",
|
|
3362
|
+
replaceFileTitle: "Reemplazar archivo",
|
|
3363
|
+
replaceFileMessage: "Ya existe un archivo llamado \"{{fileName}}\". ¿Desea reemplazarlo?",
|
|
3364
|
+
maxFilesError: "La cantidad máxima de archivos es {{maxFiles}}.",
|
|
3365
|
+
emptyFileError: "Error de permiso: El archivo \"{{fileName}}\" no puede ser enviado.",
|
|
3366
|
+
missingUploadUrlError: "Dirección de carga no informada.",
|
|
3367
|
+
maxFileSizeError: "El tamaño máximo de los archivos es de {{maxSize}}.",
|
|
3368
|
+
uploadErrorTitle: "Subiendo archivo",
|
|
3369
|
+
uploadingMessage: "Se están subiendo archivos. Por favor, espere a que se complete o cancele la subida.",
|
|
3370
|
+
},
|
|
3371
|
+
"ez-calendar": {
|
|
3372
|
+
month: {
|
|
3373
|
+
0: "Enero",
|
|
3374
|
+
1: "Febrero",
|
|
3375
|
+
2: "Marzo",
|
|
3376
|
+
3: "Abril",
|
|
3377
|
+
4: "Mayo",
|
|
3378
|
+
5: "Junio",
|
|
3379
|
+
6: "Julio",
|
|
3380
|
+
7: "Agosto",
|
|
3381
|
+
8: "Septiembre",
|
|
3382
|
+
9: "Octubre",
|
|
3383
|
+
10: "Noviembre",
|
|
3384
|
+
11: "Diciembre"
|
|
3385
|
+
},
|
|
3386
|
+
weekDay: {
|
|
3387
|
+
0: "D",
|
|
3388
|
+
1: "L",
|
|
3389
|
+
2: "M",
|
|
3390
|
+
3: "M",
|
|
3391
|
+
4: "J",
|
|
3392
|
+
5: "V",
|
|
3393
|
+
6: "S"
|
|
3394
|
+
},
|
|
3395
|
+
today: "Hoy"
|
|
3396
|
+
},
|
|
3397
|
+
"ez-collapsible-box": {
|
|
3398
|
+
confirmRemove: "¿Realmente desea eliminar el grupo <b>{{label}}</b>?",
|
|
3399
|
+
},
|
|
3400
|
+
"ez-combo-box": {
|
|
3401
|
+
placeholder: "Seleccione un elemento",
|
|
3402
|
+
noResults: "No se encontraron resultados",
|
|
3403
|
+
},
|
|
3404
|
+
"ez-date-time-input": {
|
|
3405
|
+
invalidDate: "El valor ingresado no es una fecha y hora válida"
|
|
3406
|
+
},
|
|
3407
|
+
"ez-date-input": {
|
|
3408
|
+
invalidDate: "El valor ingresado no es una fecha válida"
|
|
3409
|
+
},
|
|
3410
|
+
"ez-dialog": {
|
|
3411
|
+
confirmButton: "Botón de confirmación o OK",
|
|
3412
|
+
closeButton: "Botón de cerrar o X"
|
|
3413
|
+
},
|
|
3414
|
+
"ez-double-list": {
|
|
3415
|
+
noItemsAvailable: "No hay {{entity}} disponible",
|
|
3416
|
+
noItemsSelected: "No hay {{entity}} seleccionado",
|
|
3417
|
+
moveAllTo: "Mover todos a {{list}}",
|
|
3418
|
+
moveTo: "Mover a {{list}}",
|
|
3419
|
+
moveToFirstPosition: "Mover a la primera posición",
|
|
3420
|
+
moveUp: "Mover hacia arriba",
|
|
3421
|
+
moveDown: "Mover hacia abajo",
|
|
3422
|
+
moveToLastPosition: "Mover a la última posición"
|
|
3423
|
+
},
|
|
3424
|
+
"ez-file-item": {
|
|
3425
|
+
invalidProgress: "El progreso de carga debe ser un número entre 0 y 100."
|
|
3426
|
+
},
|
|
3427
|
+
"ez-grid": {
|
|
3428
|
+
filterAppliedSuccess: "¡Filtro de columna aplicado con éxito!",
|
|
3429
|
+
cancelPagination: "Cancelar paginación",
|
|
3430
|
+
pageLabel: "Página {{currentPage}}",
|
|
3431
|
+
previousPage: "Página anterior",
|
|
3432
|
+
nextPage: "Página siguiente",
|
|
3433
|
+
returnToPreviousPage: "Volver a la página anterior.",
|
|
3434
|
+
goToNextPage: "Avanzar a la página siguiente.",
|
|
3435
|
+
remainingPageLabel: " de {{count}} o más",
|
|
3436
|
+
remainingTotalLabel: " de {{total}}",
|
|
3437
|
+
nextRecord: "Avanzar al siguiente registro.",
|
|
3438
|
+
previousRecord: "Volver al registro anterior.",
|
|
3439
|
+
searchColumn: "Buscar por columna.",
|
|
3440
|
+
sortAscending: "Ordenar Ascendente",
|
|
3441
|
+
sortDescending: "Ordenar Descendente",
|
|
3442
|
+
pinColumn: "Fijar columna",
|
|
3443
|
+
unpinColumn: "Desafijar columna",
|
|
3444
|
+
filter: "Filtrar",
|
|
3445
|
+
columnCantBeOrder: "La columna no se puede ordenar",
|
|
3446
|
+
filterColumnHeader: "Filtro de la columna {{columnLabel}}",
|
|
3447
|
+
clearSelection: "Limpiar Selección",
|
|
3448
|
+
page: "Página",
|
|
3449
|
+
more: "más",
|
|
3450
|
+
to: "a",
|
|
3451
|
+
of: "de",
|
|
3452
|
+
next: "Siguiente",
|
|
3453
|
+
last: "Último",
|
|
3454
|
+
first: "Primero",
|
|
3455
|
+
previous: "Anterior",
|
|
3456
|
+
loadingOoo: "Cargando",
|
|
3457
|
+
selectAll: "Seleccionar todo",
|
|
3458
|
+
searchOoo: "Buscar",
|
|
3459
|
+
blanks: "Vacío",
|
|
3460
|
+
filterOoo: "Filtrar",
|
|
3461
|
+
applyFilter: "Aplicar filtro",
|
|
3462
|
+
equals: "Igual",
|
|
3463
|
+
lessThan: "Menor que",
|
|
3464
|
+
greaterThan: "Mayor que",
|
|
3465
|
+
contains: "Contiene",
|
|
3466
|
+
startsWith: "Empieza con",
|
|
3467
|
+
endsWith: "Termina con",
|
|
3468
|
+
group: "Grupo",
|
|
3469
|
+
columns: "Columnas",
|
|
3470
|
+
rowGroupColumns: "Columnas del grupo de filas",
|
|
3471
|
+
rowGroupColumnsEmptyMessage: "Columnas del grupo de filas vacías",
|
|
3472
|
+
valueColumns: "Valores de las columnas",
|
|
3473
|
+
pivotMode: "Modo pivote",
|
|
3474
|
+
groups: "Grupos",
|
|
3475
|
+
values: "Valores",
|
|
3476
|
+
pivots: "Pivotes",
|
|
3477
|
+
valueColumnsEmptyMessage: "Valores de columnas vacías",
|
|
3478
|
+
pivotColumnsEmptyMessage: "Pivotes de columnas vacías",
|
|
3479
|
+
toolPanelButton: "Botón del panel de herramientas",
|
|
3480
|
+
noRowsToShow: "No hay registros para mostrar.",
|
|
3481
|
+
valueAggregation: "Agregar valor",
|
|
3482
|
+
autosizeThiscolumn: "Redimensionar esta columna",
|
|
3483
|
+
autosizeAllColumns: "Redimensionar todas las columnas",
|
|
3484
|
+
groupBy: "Agrupar por",
|
|
3485
|
+
ungroupBy: "Desagrupar por",
|
|
3486
|
+
resetColumns: "Restablecer columnas",
|
|
3487
|
+
expandAll: "Expandir todo",
|
|
3488
|
+
collapseAll: "Contraer todo",
|
|
3489
|
+
toolPanel: "Panel de herramientas",
|
|
3490
|
+
export: "Exportar",
|
|
3491
|
+
csvExport: "Exportar a CSV",
|
|
3492
|
+
excelExport: "Exportar a Excel",
|
|
3493
|
+
pinLeft: "Fijar a la izquierda",
|
|
3494
|
+
pinRight: "Fijar a la derecha",
|
|
3495
|
+
noPin: "Desfijar columna",
|
|
3496
|
+
sum: "Suma",
|
|
3497
|
+
min: "Mínimo",
|
|
3498
|
+
max: "Máximo",
|
|
3499
|
+
none: "Ninguno",
|
|
3500
|
+
count: "Conteo",
|
|
3501
|
+
average: "Promedio",
|
|
3502
|
+
copy: "Copiar",
|
|
3503
|
+
copyWithHeaders: "Copiar con encabezados",
|
|
3504
|
+
ctrlC: "Ctrl+C",
|
|
3505
|
+
paste: "Pegar",
|
|
3506
|
+
ctrlV: "Ctrl+V"
|
|
3507
|
+
},
|
|
3508
|
+
"ez-guide-navigator": {
|
|
3509
|
+
searchGuide: "Buscar guía",
|
|
3510
|
+
hideMenu: "Ocultar menú",
|
|
3511
|
+
},
|
|
3512
|
+
"ez-list": {
|
|
3513
|
+
moveToGroup: "Mover a {{groupName}}",
|
|
3514
|
+
},
|
|
3515
|
+
"ez-modal": {
|
|
3516
|
+
close: "Cerrar modal",
|
|
3517
|
+
},
|
|
3518
|
+
"ez-multi-selection-list": {
|
|
3519
|
+
selectAll: "Seleccionar todos",
|
|
3520
|
+
search: "Buscar...",
|
|
3521
|
+
empty: "(Vacío)",
|
|
3522
|
+
initMessage: "Seleccione los valores a filtrar a través del campo de búsqueda.",
|
|
3523
|
+
emptyResults: "No se encontraron resultados.",
|
|
3524
|
+
},
|
|
3525
|
+
"ez-number-input": {
|
|
3526
|
+
invalidNumber: "El valor ingresado no es un número válido",
|
|
3527
|
+
},
|
|
3528
|
+
"ez-rich-text": {
|
|
3529
|
+
listShortcut: "Aplica estilo de lista al texto seleccionado.",
|
|
3530
|
+
linkShortcut: "Abre popup de enlace.",
|
|
3531
|
+
imageShortcut: "Abre popup de imagen.",
|
|
3532
|
+
boldShortcut: "Aplica estilo negrita al texto seleccionado.",
|
|
3533
|
+
italicShortcut: "Aplica estilo cursiva al texto seleccionado.",
|
|
3534
|
+
underlineShortcut: "Aplica estilo subrayado al texto seleccionado.",
|
|
3535
|
+
breakLineShortcut: "Aplica salto de línea.",
|
|
3536
|
+
undoShortcut: "Deshace el último cambio de texto.",
|
|
3537
|
+
redoShortcut: "Rehace el último cambio de texto.",
|
|
3538
|
+
edit: "Editar",
|
|
3539
|
+
preview: "Previsualizar",
|
|
3540
|
+
title: {
|
|
3541
|
+
preview: "Ctrl + P",
|
|
3542
|
+
edit: "Ir al modo de edición",
|
|
3543
|
+
undo: "Deshacer (Ctrl + Z)",
|
|
3544
|
+
redo: "Rehacer (Ctrl + X)",
|
|
3545
|
+
link: "Insertar enlace (Ctrl + K)",
|
|
3546
|
+
image: "Insertar imagen (Ctrl + O)",
|
|
3547
|
+
list: "Lista (Ctrl + L)",
|
|
3548
|
+
underline: "Subrayado (Ctrl + U)",
|
|
3549
|
+
italic: "Cursiva (Ctrl + I)",
|
|
3550
|
+
bold: "Negrita (Ctrl + B)",
|
|
3551
|
+
}
|
|
3552
|
+
},
|
|
3553
|
+
"ez-link-builder": {
|
|
3554
|
+
addLinkTitle: "Agregar enlace",
|
|
3555
|
+
addLinkSubtitle: "Inserte un enlace en el texto para abrir nuevas páginas.",
|
|
3556
|
+
submit: "Enviar",
|
|
3557
|
+
urlInputLabel: "Ingrese la URL de destino",
|
|
3558
|
+
textInputLabel: "Ingrese el texto a mostrar",
|
|
3559
|
+
openInNewPage: "Abrir en una nueva página.",
|
|
3560
|
+
},
|
|
3561
|
+
"ez-simple-image-uploader": {
|
|
3562
|
+
uploadTitle: "Subida de imágenes",
|
|
3563
|
+
uploadSubtitle: "Sube tus archivos llenando solo 1 campo a la vez.",
|
|
3564
|
+
submit: "Enviar",
|
|
3565
|
+
tooltipMessage: "¡El archivo seleccionado a continuación será priorizado!",
|
|
3566
|
+
urlInputLabel: "Ingrese la URL de la imagen",
|
|
3567
|
+
orText: "O",
|
|
3568
|
+
removeFile: "Eliminar archivo",
|
|
3569
|
+
dragDropText: "Arrastra y suelta o haz clic para agregar archivos",
|
|
3570
|
+
imageAlt: "Imagen",
|
|
3571
|
+
imageTooLarge: "La imagen debe tener menos de {{maxSize}}.",
|
|
3572
|
+
},
|
|
3573
|
+
"ez-search": {
|
|
3574
|
+
emptyList: "No se encontraron resultados",
|
|
3575
|
+
emptySearch: "No se encontraron resultados de {{field}}",
|
|
3576
|
+
},
|
|
3577
|
+
"ez-search-plus": {
|
|
3578
|
+
emptyList: "No se encontraron resultados",
|
|
3579
|
+
optionLoaderNotDefined: "optionLoader no definido",
|
|
3580
|
+
defaultCodeLabel: "Cód.",
|
|
3581
|
+
},
|
|
3582
|
+
"ez-sortable-list": {
|
|
3583
|
+
emptyMessage: "No hay elementos en la lista",
|
|
3584
|
+
entityLabel: "elemento",
|
|
3585
|
+
entityLabelPlural: "elementos",
|
|
3586
|
+
total: "Total de",
|
|
3587
|
+
search: "Buscar",
|
|
3588
|
+
},
|
|
3589
|
+
"ez-split-button": {
|
|
3590
|
+
moreOptions: "Más opciones",
|
|
3591
|
+
},
|
|
3592
|
+
"ez-text-edit": {
|
|
3593
|
+
emptyFieldWarning: "No es posible guardar un campo vacío.",
|
|
3594
|
+
},
|
|
3595
|
+
"ez-time-input": {
|
|
3596
|
+
invalidTime: "Por favor, ingrese una hora válida.",
|
|
3597
|
+
},
|
|
3598
|
+
"ez-sidebar": {
|
|
3599
|
+
unPinMenu: "Desanclar menú",
|
|
3600
|
+
pushPinMenu: "Anclar menú",
|
|
3601
|
+
hideMenu: "Ocultar menú",
|
|
3602
|
+
},
|
|
3603
|
+
"utils": {
|
|
3604
|
+
requiredFieldMessage: "Hay al menos un campo obligatorio sin completar.",
|
|
3605
|
+
requiredField: "Esta información es obligatoria.",
|
|
3606
|
+
selectAllPage: "Seleccionar solo la página actual",
|
|
3607
|
+
loadingAllRecords: "Cargando todos los {{count}} registros",
|
|
3608
|
+
selectAllRecords: "Seleccionar todos los {{total}} registros",
|
|
3609
|
+
waitForLoad: "Espere a que se carguen para seleccionar los registros de todas las páginas",
|
|
3610
|
+
allRecordsSelected: "Todos los <strong>{{selectionCount}} registros</strong> en la cuadrícula están seleccionados.",
|
|
3611
|
+
selectedRecords: "Hay <strong>{{selectionCount}} registro{{plural}}</strong> seleccionado{{plural}} en la cuadrícula.",
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
var ELanguages;
|
|
3617
|
+
(function (ELanguages) {
|
|
3618
|
+
ELanguages["PT_BR"] = "pt_BR";
|
|
3619
|
+
ELanguages["EN_US"] = "en_US";
|
|
3620
|
+
ELanguages["ES_ES"] = "es_ES";
|
|
3621
|
+
})(ELanguages || (ELanguages = {}));
|
|
3622
|
+
|
|
3623
|
+
const translations = {
|
|
3624
|
+
[ELanguages.PT_BR]: ptBrTranslations,
|
|
3625
|
+
[ELanguages.EN_US]: enUsTranslations,
|
|
3626
|
+
[ELanguages.ES_ES]: esEsTranslations,
|
|
3627
|
+
};
|
|
3628
|
+
|
|
3629
|
+
function getDocumentLang() {
|
|
3630
|
+
const lang = document.documentElement.lang || navigator.language || "pt-BR";
|
|
3631
|
+
switch (lang.toLocaleLowerCase()) {
|
|
3632
|
+
case "en":
|
|
3633
|
+
case "en_us":
|
|
3634
|
+
case "en-us":
|
|
3635
|
+
return ELanguages.EN_US;
|
|
3636
|
+
case "es":
|
|
3637
|
+
case "es_es":
|
|
3638
|
+
case "es-es":
|
|
3639
|
+
return ELanguages.ES_ES;
|
|
3640
|
+
default:
|
|
3641
|
+
return ELanguages.PT_BR;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
const KEY_I18N = "__EZ_UI_I18N_INSTANCE__";
|
|
3646
|
+
function getI18n() {
|
|
3647
|
+
let i18nInstance = ApplicationContext.getContextValue(KEY_I18N);
|
|
3648
|
+
return i18nInstance;
|
|
3649
|
+
}
|
|
3650
|
+
const initI18n = async (forceLang) => {
|
|
3651
|
+
let i18nTFunction = getI18n();
|
|
3652
|
+
if (!i18nTFunction) {
|
|
3653
|
+
const i18nInstance = instance.createInstance();
|
|
3654
|
+
const i18nextOptions = {
|
|
3655
|
+
resources: translations,
|
|
3656
|
+
fallbackLng: ELanguages.PT_BR
|
|
3657
|
+
};
|
|
3658
|
+
await i18nInstance
|
|
3659
|
+
.use(Browser)
|
|
3660
|
+
.init(i18nextOptions);
|
|
3661
|
+
const lang = forceLang !== null && forceLang !== void 0 ? forceLang : getDocumentLang();
|
|
3662
|
+
await i18nInstance.changeLanguage(lang);
|
|
3663
|
+
ApplicationContext.setContextValue(KEY_I18N, i18nInstance.t);
|
|
3664
|
+
i18nTFunction = i18nInstance.t;
|
|
3665
|
+
}
|
|
3666
|
+
return i18nTFunction;
|
|
3667
|
+
};
|
|
3668
|
+
|
|
3669
|
+
export { getI18n as g, initI18n as i };
|