@formio/js 5.1.0-dev.6159.811e953 → 5.1.0-dev.6162.d0510e0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/formio.form.js +19 -41
  2. package/dist/formio.form.min.js +1 -1
  3. package/dist/formio.full.js +21 -43
  4. package/dist/formio.full.min.js +1 -1
  5. package/dist/formio.js +7 -7
  6. package/dist/formio.min.js +1 -1
  7. package/dist/formio.utils.js +7 -7
  8. package/dist/formio.utils.min.js +1 -1
  9. package/lib/cjs/Element.d.ts +2 -1
  10. package/lib/cjs/Element.js +6 -4
  11. package/lib/cjs/PDFBuilder.d.ts +1 -0
  12. package/lib/cjs/PDFBuilder.js +8 -8
  13. package/lib/cjs/Webform.d.ts +2 -2
  14. package/lib/cjs/Webform.js +4 -3
  15. package/lib/cjs/WebformBuilder.d.ts +1 -1
  16. package/lib/cjs/WebformBuilder.js +20 -8
  17. package/lib/cjs/components/Components.js +1 -1
  18. package/lib/cjs/components/_classes/component/Component.js +10 -5
  19. package/lib/cjs/components/_classes/input/Input.d.ts +1 -1
  20. package/lib/cjs/components/_classes/input/Input.js +2 -2
  21. package/lib/cjs/components/_classes/nested/NestedComponent.js +1 -1
  22. package/lib/cjs/components/datamap/DataMap.js +7 -2
  23. package/lib/cjs/components/select/Select.js +1 -1
  24. package/lib/cjs/components/textarea/TextArea.js +6 -1
  25. package/lib/cjs/components/textfield/TextField.js +6 -1
  26. package/lib/cjs/formio.form.js +2 -2
  27. package/lib/cjs/translations/en.d.ts +1 -233
  28. package/lib/cjs/translations/en.js +4 -2
  29. package/lib/cjs/utils/formUtils.d.ts +2 -2
  30. package/lib/cjs/utils/index.d.ts +2 -2
  31. package/lib/mjs/Element.d.ts +2 -1
  32. package/lib/mjs/Element.js +6 -4
  33. package/lib/mjs/PDFBuilder.d.ts +1 -0
  34. package/lib/mjs/PDFBuilder.js +8 -8
  35. package/lib/mjs/Webform.d.ts +2 -2
  36. package/lib/mjs/Webform.js +4 -3
  37. package/lib/mjs/WebformBuilder.d.ts +1 -1
  38. package/lib/mjs/WebformBuilder.js +19 -8
  39. package/lib/mjs/components/Components.js +1 -1
  40. package/lib/mjs/components/_classes/component/Component.js +10 -5
  41. package/lib/mjs/components/_classes/input/Input.d.ts +1 -1
  42. package/lib/mjs/components/_classes/input/Input.js +2 -2
  43. package/lib/mjs/components/_classes/nested/NestedComponent.js +1 -1
  44. package/lib/mjs/components/datamap/DataMap.js +7 -2
  45. package/lib/mjs/components/select/Select.js +1 -1
  46. package/lib/mjs/components/textarea/TextArea.js +6 -1
  47. package/lib/mjs/components/textfield/TextField.js +6 -1
  48. package/lib/mjs/formio.form.js +1 -1
  49. package/lib/mjs/translations/en.d.ts +1 -233
  50. package/lib/mjs/translations/en.js +7 -47
  51. package/lib/mjs/utils/formUtils.d.ts +2 -2
  52. package/lib/mjs/utils/index.d.ts +2 -2
  53. package/package.json +2 -2
  54. package/lib/cjs/i18n.d.ts +0 -13
  55. package/lib/cjs/i18n.js +0 -19
  56. package/lib/cjs/utils/i18n.d.ts +0 -19
  57. package/lib/cjs/utils/i18n.js +0 -120
  58. package/lib/mjs/i18n.d.ts +0 -13
  59. package/lib/mjs/i18n.js +0 -14
  60. package/lib/mjs/utils/i18n.d.ts +0 -19
  61. package/lib/mjs/utils/i18n.js +0 -112
@@ -1,234 +1,2 @@
1
- declare const _default: {
2
- unsavedRowsError: string;
3
- invalidRowsError: string;
4
- invalidRowError: string;
5
- invalidOption: string;
6
- invalidDay: string;
7
- complete: string;
8
- error: string;
9
- errorListHotkey: string;
10
- errorsListNavigationMessage: string;
11
- submitError: string;
12
- required: string;
13
- unique: string;
14
- array: string;
15
- array_nonempty: string;
16
- nonarray: string;
17
- select: string;
18
- pattern: string;
19
- minLength: string;
20
- maxLength: string;
21
- minWords: string;
22
- maxWords: string;
23
- min: string;
24
- max: string;
25
- maxDate: string;
26
- minDate: string;
27
- maxYear: string;
28
- minYear: string;
29
- minSelectedCount: string;
30
- maxSelectedCount: string;
31
- invalid_email: string;
32
- invalid_url: string;
33
- invalid_regex: string;
34
- invalid_date: string;
35
- invalid_day: string;
36
- invalidValueProperty: string;
37
- mask: string;
38
- valueIsNotAvailable: string;
39
- stripe: string;
40
- month: string;
41
- day: string;
42
- year: string;
43
- january: string;
44
- february: string;
45
- march: string;
46
- april: string;
47
- may: string;
48
- june: string;
49
- july: string;
50
- august: string;
51
- september: string;
52
- october: string;
53
- november: string;
54
- december: string;
55
- next: string;
56
- previous: string;
57
- cancel: string;
58
- submit: string;
59
- confirmCancel: string;
60
- saveDraftInstanceError: string;
61
- saveDraftAuthError: string;
62
- restoreDraftInstanceError: string;
63
- saveDraftError: string;
64
- restoreDraftError: string;
65
- time: string;
66
- cancelButtonAriaLabel: string;
67
- previousButtonAriaLabel: string;
68
- nextButtonAriaLabel: string;
69
- submitButtonAriaLabel: string;
70
- reCaptchaTokenValidationError: string;
71
- reCaptchaTokenNotSpecifiedError: string;
72
- apiKey: string;
73
- apiKeyNotValid: string;
74
- typeRemaining: string;
75
- typeCount: string;
76
- requiredDayField: string;
77
- requiredDayEmpty: string;
78
- requiredMonthField: string;
79
- requiredYearField: string;
80
- formNotReady: string;
81
- noFormElement: string;
82
- notUniqueKey: string;
83
- newFormSchema: string;
84
- missingUrl: string;
85
- urlNotAttachedToBtn: string;
86
- loadingProjectSettingsError: string;
87
- sessionStorageSupportError: string;
88
- builderUniqueError: string;
89
- pageNotFound: string;
90
- noDragInfoError: string;
91
- addonSupportTypeError: string;
92
- setPathError: string;
93
- calculatedPathDeprecation: string;
94
- unknownTemplate: string;
95
- unknownComponent: string;
96
- renderTemplateFunctionDeprecation: string;
97
- whenReadyDeprecation: string;
98
- loadResourcesError: string;
99
- noSelectDataConfiguration: string;
100
- indexedDBSupportError: string;
101
- caretPositionSavingError: string;
102
- iteratableRowsError: string;
103
- checkRowDeprecation: string;
104
- noOAuthBtn: string;
105
- noOAuthConfiguration: string;
106
- oAuthErrorsTitle: string;
107
- noOAuthFormUrl: string;
108
- oAuthStateError: string;
109
- componentInvalidRowValidation: string;
110
- videoPlayerNotFound: string;
111
- synchronizationFailed: string;
112
- fileWithDuplicatedNameInProgress: string;
113
- fileWithDuplicatedNameLoaded: string;
114
- nestedForm: string;
115
- noDataProvided: string;
116
- subformSubmissionLoadingError: string;
117
- noDelimiterSet: string;
118
- noSiteKey: string;
119
- failedToNormalize: string;
120
- failedToCompareItems: string;
121
- editorFocusError: string;
122
- quillImageUploadFailed: string;
123
- noFilesSelected: string;
124
- needConfigurationForQuill: string;
125
- waitPdfConverting: string;
126
- uploading: string;
127
- pasteBelow: string;
128
- copy: string;
129
- move: string;
130
- edit: string;
131
- editJson: string;
132
- remove: string;
133
- clickToSetValue: string;
134
- words: string;
135
- characters: string;
136
- addAnother: string;
137
- yes: string;
138
- no: string;
139
- wantToClearData: string;
140
- yesDelete: string;
141
- waitFileProcessing: string;
142
- wrongFileType: string;
143
- fileTooSmall: string;
144
- fileTooBig: string;
145
- noFileService: string;
146
- fileProcessingFailed: string;
147
- readyForUpload: string;
148
- readyForRemovingFromStorage: string;
149
- preparingFileToRemove: string;
150
- succefullyRemoved: string;
151
- succefullyUploaded: string;
152
- maxSelectItems: string;
153
- minSelectItems: string;
154
- clickToSign: string;
155
- surveyQuestion: string;
156
- surveyQuestionValue: string;
157
- success: string;
158
- noResultsFound: string;
159
- noChoices: string;
160
- typeToSearch: string;
161
- loading: string;
162
- help: string;
163
- component: string;
164
- save: string;
165
- preview: string;
166
- dragAndDropComponent: string;
167
- searchFields: string;
168
- noMatchesFound: string;
169
- fileName: string;
170
- size: string;
171
- type: string;
172
- gallery: string;
173
- camera: string;
174
- dropFilesToAttach: string;
175
- useCamera: string;
176
- browse: string;
177
- takePicture: string;
178
- switchToFileUpload: string;
179
- completeStatus: string;
180
- noStorageSet: string;
181
- noFileApiSupport: string;
182
- noFormDataSupport: string;
183
- noProgressSupport: string;
184
- close: string;
185
- addResource: string;
186
- autocomplete: string;
187
- showPreview: string;
188
- hidePreview: string;
189
- createPage: string;
190
- page: string;
191
- closeBtnDescription: string;
192
- cancelBtnDescription: string;
193
- saveBtnDescription: string;
194
- addOrRemove: string;
195
- anyFileTypesAllowed: string;
196
- allowedFileTypes: string;
197
- syncing: string;
198
- syncNow: string;
199
- pressToOpen: string;
200
- browseToAttachFileFor: string;
201
- or: string;
202
- numericOnly: string;
203
- uploadPdfFile: string;
204
- dropToStart: string;
205
- expand: string;
206
- collapse: string;
207
- add: string;
208
- delete: string;
209
- revert: string;
210
- removeBtnPressToRemove: string;
211
- file: string;
212
- captureVideo: string;
213
- captureAudio: string;
214
- captureImage: string;
215
- browseFiles: string;
216
- noComponentsSetInGrid: string;
217
- sortAscending: string;
218
- sortDescending: string;
219
- filter: string;
220
- clear: string;
221
- showItemsWithValue: string;
222
- gridItemsPerPage: string;
223
- gridAllItems: string;
224
- recordsSelectedOnPage: string;
225
- recordsSelectedInTable: string;
226
- gridSelectAll: string;
227
- itemsInTable: string;
228
- clearSelection: string;
229
- editGridRow: string;
230
- deleteGridRow: string;
231
- selected: string;
232
- actions: string;
233
- };
1
+ declare const _default: any;
234
2
  export default _default;
@@ -1,59 +1,26 @@
1
1
  import bootstrap from '@formio/bootstrap';
2
+ import { coreEnTranslation } from '@formio/core';
3
+ import _ from 'lodash';
2
4
  export default {
3
5
  ...(bootstrap?.translations?.en || {}),
6
+ // these keys contain a '-' to strip whitespace in core
7
+ // which is not handled correctly in the renderer, so we redefine them
8
+ ..._.omit(coreEnTranslation, ['maxDate', 'minDate']),
4
9
  unsavedRowsError: 'Please save all rows before proceeding.',
5
10
  invalidRowsError: 'Please correct invalid rows before proceeding.',
6
11
  invalidRowError: 'Invalid row. Please correct it or delete.',
7
12
  invalidOption: '{{field}} is an invalid value.',
8
13
  invalidDay: '{{field}} is not a valid day.',
14
+ alertMessageWithLabel: '{{label}}: {{message}}',
15
+ alertMessage: '{{message}}',
9
16
  complete: 'Submission Complete',
10
17
  error: 'Please fix the following errors before submitting.',
11
18
  errorListHotkey: 'Press Ctrl + Alt + X to go back to the error list.',
12
19
  errorsListNavigationMessage: 'Click to navigate to the field with following error.',
13
20
  submitError: 'Please check the form and correct all errors before submitting.',
14
- required: '{{field}} is required',
15
- unique: '{{field}} must be unique',
16
- array: '{{field}} must be an array',
17
- array_nonempty: '{{field}} must be a non-empty array', // eslint-disable-line camelcase
18
- nonarray: '{{field}} must not be an array',
19
- select: '{{field}} contains an invalid selection',
20
- pattern: '{{field}} does not match the pattern {{pattern}}',
21
- minLength: '{{field}} must have at least {{length}} characters.',
22
- maxLength: '{{field}} must have no more than {{length}} characters.',
23
- minWords: '{{field}} must have at least {{length}} words.',
24
- maxWords: '{{field}} must have no more than {{length}} words.',
25
- min: '{{field}} cannot be less than {{min}}.',
26
- max: '{{field}} cannot be greater than {{max}}.',
27
21
  maxDate: '{{field}} should not contain date after {{maxDate}}',
28
22
  minDate: '{{field}} should not contain date before {{minDate}}',
29
- maxYear: '{{field}} should not contain year greater than {{maxYear}}',
30
- minYear: '{{field}} should not contain year less than {{minYear}}',
31
- minSelectedCount: 'You must select at least {{minCount}} items',
32
- maxSelectedCount: 'You may only select up to {{maxCount}} items',
33
- invalid_email: '{{field}} must be a valid email.', // eslint-disable-line camelcase
34
- invalid_url: '{{field}} must be a valid url.', // eslint-disable-line camelcase
35
- invalid_regex: '{{field}} does not match the pattern {{regex}}.', // eslint-disable-line camelcase
36
- invalid_date: '{{field}} is not a valid date.', // eslint-disable-line camelcase
37
- invalid_day: '{{field}} is not a valid day.', // eslint-disable-line camelcase
38
- invalidValueProperty: 'Invalid Value Property',
39
- mask: '{{field}} does not match the mask.',
40
- valueIsNotAvailable: '{{ field }} is an invalid value.',
41
23
  stripe: '{{stripe}}',
42
- month: 'Month',
43
- day: 'Day',
44
- year: 'Year',
45
- january: 'January',
46
- february: 'February',
47
- march: 'March',
48
- april: 'April',
49
- may: 'May',
50
- june: 'June',
51
- july: 'July',
52
- august: 'August',
53
- september: 'September',
54
- october: 'October',
55
- november: 'November',
56
- december: 'December',
57
24
  next: 'Next',
58
25
  previous: 'Previous',
59
26
  cancel: 'Cancel',
@@ -75,10 +42,7 @@ export default {
75
42
  apiKeyNotValid: 'API Key is not valid: {{key}}',
76
43
  typeRemaining: '{{ remaining }} {{ type }} remaining.',
77
44
  typeCount: '{{ count }} {{ type }}',
78
- requiredDayField: '{{ field }} is required',
79
45
  requiredDayEmpty: '{{ field }} is required',
80
- requiredMonthField: '{{ field }} is required',
81
- requiredYearField: '{{ field }} is required',
82
46
  formNotReady: 'Form not ready. Use form.ready promise',
83
47
  noFormElement: 'No DOM element for form.',
84
48
  notUniqueKey: 'API Key is not unique',
@@ -138,8 +102,6 @@ export default {
138
102
  words: 'words',
139
103
  characters: 'characters',
140
104
  addAnother: 'Add Another',
141
- yes: 'Yes',
142
- no: 'No',
143
105
  wantToClearData: 'Do you want to clear data?',
144
106
  yesDelete: 'Yes, delete it',
145
107
  waitFileProcessing: 'Processing file. Please wait...',
@@ -156,8 +118,6 @@ export default {
156
118
  maxSelectItems: 'You may only select up to {{maxCount}} items',
157
119
  minSelectItems: 'You must select at least {{minCount}} items',
158
120
  clickToSign: 'Click to Sign',
159
- surveyQuestion: 'Question',
160
- surveyQuestionValue: 'Value',
161
121
  success: 'Success',
162
122
  noResultsFound: 'No results found',
163
123
  noChoices: 'No choices to choose from',
@@ -26,8 +26,8 @@ export const getBestMatch: typeof Utils.getBestMatch;
26
26
  export const getComponentFromPath: typeof Utils.getComponentFromPath;
27
27
  export const getComponentValue: typeof Utils.getComponentValue;
28
28
  export const findComponents: typeof Utils.findComponents;
29
- export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
30
- export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
29
+ export const eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
30
+ export const eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
31
31
  export const getComponentKey: typeof Utils.getComponentKey;
32
32
  export const getContextualRowPath: typeof Utils.getContextualRowPath;
33
33
  export const getContextualRowData: typeof Utils.getContextualRowData;
@@ -37,8 +37,8 @@ declare const FormioUtils: {
37
37
  getComponentFromPath: typeof import("@formio/core/lib/utils/formUtil").getComponentFromPath;
38
38
  getComponentValue: typeof import("@formio/core/lib/utils/formUtil").getComponentValue;
39
39
  findComponents: typeof import("@formio/core/lib/utils/formUtil").findComponents;
40
- eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => Promise<void>;
41
- eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined) => void;
40
+ eachComponentDataAsync: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataAsyncCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => Promise<void>;
41
+ eachComponentData: (components: import("@formio/core").Component[], data: import("@formio/core").DataObject, fn: import("@formio/core").EachComponentDataCallback, includeAll?: boolean | undefined, local?: boolean | undefined, parent?: import("@formio/core").Component | undefined, parentPaths?: import("@formio/core").ComponentPaths | undefined, noScopeReset?: boolean | undefined) => void;
42
42
  getComponentKey: typeof import("@formio/core/lib/utils/formUtil").getComponentKey;
43
43
  getContextualRowPath: typeof import("@formio/core/lib/utils/formUtil").getContextualRowPath;
44
44
  getContextualRowData: typeof import("@formio/core/lib/utils/formUtil").getContextualRowData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formio/js",
3
- "version": "5.1.0-dev.6159.811e953",
3
+ "version": "5.1.0-dev.6162.d0510e0",
4
4
  "description": "JavaScript powered Forms with JSON Form Builder",
5
5
  "main": "lib/cjs/index.js",
6
6
  "exports": {
@@ -81,7 +81,7 @@
81
81
  "homepage": "https://github.com/formio/formio.js#readme",
82
82
  "dependencies": {
83
83
  "@formio/bootstrap": "v3.0.0-dev.121.085d187",
84
- "@formio/core": "v2.4.0-dev.255.7fab6ff",
84
+ "@formio/core": "2.4.0-dev.267.2866472",
85
85
  "@formio/text-mask-addons": "3.8.0-formio.4",
86
86
  "@formio/vanilla-text-mask": "^5.1.1-formio.1",
87
87
  "abortcontroller-polyfill": "^1.7.5",
package/lib/cjs/i18n.d.ts DELETED
@@ -1,13 +0,0 @@
1
- declare namespace _default {
2
- let lng: string;
3
- let nsSeparator: string;
4
- let keySeparator: string;
5
- let pluralSeparator: string;
6
- let contextSeparator: string;
7
- namespace resources {
8
- namespace en {
9
- let translation: any;
10
- }
11
- }
12
- }
13
- export default _default;
package/lib/cjs/i18n.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const en_1 = __importDefault(require("./translations/en"));
7
- const utils_1 = require("./utils");
8
- exports.default = {
9
- lng: 'en',
10
- nsSeparator: '::',
11
- keySeparator: '.|.',
12
- pluralSeparator: '._.',
13
- contextSeparator: '._.',
14
- resources: {
15
- en: {
16
- translation: (0, utils_1.fastCloneDeep)(en_1.default)
17
- }
18
- }
19
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * This file is used to mimic the i18n library interface.
3
- */
4
- export class I18n {
5
- static languages: {};
6
- static setDefaultTranslations(languages: any): void;
7
- static init(languages?: {}): I18n;
8
- static createInstance(): I18n;
9
- constructor(languages?: {});
10
- languages: any;
11
- defaultKeys: any;
12
- language: string;
13
- currentLanguage: any;
14
- setLanguages(languages: any, noDefaultOverride: any): void;
15
- dir(lang?: string): "rtl" | "ltr";
16
- changeLanguage(language: any, ready?: null): void;
17
- addResourceBundle(language: any, type: any, strings: any): void;
18
- t(text: any, ...args: any[]): any;
19
- }
@@ -1,120 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.I18n = void 0;
7
- const Evaluator_1 = require("./Evaluator");
8
- const i18n_1 = __importDefault(require("../i18n"));
9
- const lodash_1 = require("lodash");
10
- const core_1 = require("@formio/core");
11
- const i18Defaults = {};
12
- for (const lang in i18n_1.default.resources) {
13
- if (i18n_1.default.resources.hasOwnProperty(lang)) {
14
- i18Defaults[lang] = i18n_1.default.resources[lang].translation;
15
- }
16
- }
17
- /**
18
- * This file is used to mimic the i18n library interface.
19
- */
20
- class I18n {
21
- constructor(languages = {}) {
22
- var _a;
23
- this.languages = (0, core_1.fastCloneDeep)(I18n.languages || {});
24
- this.defaultKeys = ((_a = I18n.languages) === null || _a === void 0 ? void 0 : _a.en) || {};
25
- this.language = 'en';
26
- this.currentLanguage = i18Defaults.en;
27
- this.setLanguages(languages);
28
- this.changeLanguage(this.language);
29
- }
30
- static setDefaultTranslations(languages) {
31
- if ((0, lodash_1.isEmpty)(languages)) {
32
- return;
33
- }
34
- for (const lang in languages) {
35
- if (lang !== 'language' && languages.hasOwnProperty(lang)) {
36
- if (!this.languages[lang]) {
37
- this.languages[lang] = {};
38
- }
39
- this.languages[lang] = Object.assign(Object.assign({}, languages[lang]), this.languages[lang]);
40
- }
41
- }
42
- }
43
- setLanguages(languages, noDefaultOverride) {
44
- if (languages.resources) {
45
- for (const lang in languages.resources) {
46
- if (languages.resources.hasOwnProperty(lang)) {
47
- languages[lang] = languages.resources[lang].translation;
48
- }
49
- }
50
- delete languages.resources;
51
- }
52
- if (languages.lng) {
53
- languages.language = languages.lng;
54
- delete languages.lng;
55
- }
56
- // Do not use these configurations.
57
- delete languages.nsSeparator;
58
- delete languages.keySeparator;
59
- delete languages.pluralSeparator;
60
- delete languages.contextSeparator;
61
- // Now establish the languages default.
62
- if (languages.language) {
63
- this.language = languages.language;
64
- }
65
- for (const lang in languages) {
66
- if (lang !== 'language' && languages.hasOwnProperty(lang)) {
67
- if (!this.languages[lang]) {
68
- this.languages[lang] = {};
69
- }
70
- this.languages[lang] = noDefaultOverride
71
- ? Object.assign(Object.assign({}, languages[lang]), this.languages[lang]) : Object.assign(Object.assign({}, this.languages[lang]), languages[lang]);
72
- }
73
- }
74
- }
75
- static init(languages = {}) {
76
- return new I18n(languages);
77
- }
78
- dir(lang = '') {
79
- lang = lang || this.language;
80
- const rtls = ['ar', 'he', 'fa', 'ps', 'ur'];
81
- return rtls.includes(lang) ? 'rtl' : 'ltr';
82
- }
83
- static createInstance() {
84
- return new I18n();
85
- }
86
- changeLanguage(language, ready = null) {
87
- if (!this.languages[language]) {
88
- language = 'en';
89
- }
90
- this.language = language;
91
- this.currentLanguage = this.languages[language] ? this.languages[language] : {};
92
- if (ready) {
93
- ready();
94
- }
95
- }
96
- addResourceBundle(language, type, strings) {
97
- this.languages[language] = strings;
98
- }
99
- t(text, ...args) {
100
- var _a;
101
- let currentTranslation = this.currentLanguage[text];
102
- // provide compatibility with cases where the entire phrase is used as a key
103
- // get the phrase that is possibly being used as a key
104
- const defaultKey = this.defaultKeys[text];
105
- if (defaultKey && this.currentLanguage[defaultKey]) {
106
- // get translation using the phrase as a key
107
- currentTranslation = this.currentLanguage[defaultKey];
108
- }
109
- if (currentTranslation) {
110
- const customTranslationFieldName = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.field;
111
- if (customTranslationFieldName && this.currentLanguage[customTranslationFieldName]) {
112
- args[0].field = this.currentLanguage[customTranslationFieldName];
113
- }
114
- return Evaluator_1.Evaluator.interpolateString(currentTranslation, ...args);
115
- }
116
- return Evaluator_1.Evaluator.interpolateString(text, ...args);
117
- }
118
- }
119
- exports.I18n = I18n;
120
- I18n.languages = i18Defaults;
package/lib/mjs/i18n.d.ts DELETED
@@ -1,13 +0,0 @@
1
- declare namespace _default {
2
- let lng: string;
3
- let nsSeparator: string;
4
- let keySeparator: string;
5
- let pluralSeparator: string;
6
- let contextSeparator: string;
7
- namespace resources {
8
- namespace en {
9
- let translation: any;
10
- }
11
- }
12
- }
13
- export default _default;
package/lib/mjs/i18n.js DELETED
@@ -1,14 +0,0 @@
1
- import enTranslation from './translations/en';
2
- import { fastCloneDeep } from './utils';
3
- export default {
4
- lng: 'en',
5
- nsSeparator: '::',
6
- keySeparator: '.|.',
7
- pluralSeparator: '._.',
8
- contextSeparator: '._.',
9
- resources: {
10
- en: {
11
- translation: fastCloneDeep(enTranslation)
12
- }
13
- }
14
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * This file is used to mimic the i18n library interface.
3
- */
4
- export class I18n {
5
- static languages: {};
6
- static setDefaultTranslations(languages: any): void;
7
- static init(languages?: {}): I18n;
8
- static createInstance(): I18n;
9
- constructor(languages?: {});
10
- languages: any;
11
- defaultKeys: any;
12
- language: string;
13
- currentLanguage: any;
14
- setLanguages(languages: any, noDefaultOverride: any): void;
15
- dir(lang?: string): "rtl" | "ltr";
16
- changeLanguage(language: any, ready?: null): void;
17
- addResourceBundle(language: any, type: any, strings: any): void;
18
- t(text: any, ...args: any[]): any;
19
- }