workflow-editor 0.9.84-dw-tmp1 → 0.9.84-dw-tmp3

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 (169) hide show
  1. package/lib/workflow-editor.css +1 -0
  2. package/lib/workflow-editor.umd.min.js +39 -1
  3. package/package.json +2 -2
  4. package/packages/index.js +34 -0
  5. package/packages/plugins/formValidatorUtil.js +528 -0
  6. package/packages/plugins/index.js +8 -0
  7. package/packages/workflow-editor/index.js +14 -0
  8. package/packages/workflow-editor/src/api.js +7 -0
  9. package/{lib/workflow-editor.umd.min.workflow-editor.umd.min~e2e93592.js → packages/workflow-editor/src/assets/wf-editor-icons.js} +2 -1
  10. package/packages/workflow-editor/src/constant.js +8 -0
  11. package/packages/workflow-editor/src/json-object-templates/copy-task.js +67 -0
  12. package/packages/workflow-editor/src/json-object-templates/decision.js +11 -0
  13. package/packages/workflow-editor/src/json-object-templates/end.js +14 -0
  14. package/packages/workflow-editor/src/json-object-templates/fork.js +10 -0
  15. package/packages/workflow-editor/src/json-object-templates/human-decision.js +9 -0
  16. package/packages/workflow-editor/src/json-object-templates/human-task.js +199 -0
  17. package/packages/workflow-editor/src/json-object-templates/join.js +10 -0
  18. package/packages/workflow-editor/src/json-object-templates/process.js +98 -0
  19. package/packages/workflow-editor/src/json-object-templates/start.js +13 -0
  20. package/packages/workflow-editor/src/json-object-templates/subprocess.js +30 -0
  21. package/packages/workflow-editor/src/json-object-templates/transition.js +26 -0
  22. package/packages/workflow-editor/src/main/admin-save-dialog.vue +66 -0
  23. package/packages/workflow-editor/src/main/canvas.vue +479 -0
  24. package/packages/workflow-editor/src/main/context-menu.vue +132 -0
  25. package/packages/workflow-editor/src/main/icon-svg.vue +32 -0
  26. package/packages/workflow-editor/src/main/selection-region.vue +66 -0
  27. package/packages/workflow-editor/src/main/tache-history-tooltip.vue +38 -0
  28. package/packages/workflow-editor/src/main/tache-name-input.vue +19 -0
  29. package/packages/workflow-editor/src/main/tache-subprocess-history-dialog.vue +35 -0
  30. package/packages/workflow-editor/src/main/toolbox.vue +60 -0
  31. package/packages/workflow-editor/src/main/wf-history-canvas.vue +302 -0
  32. package/packages/workflow-editor/src/process-json.js +622 -0
  33. package/packages/workflow-editor/src/process-service.js +31 -0
  34. package/packages/workflow-editor/src/properties-editors/common/additional-condition-utils.js +522 -0
  35. package/packages/workflow-editor/src/properties-editors/common/additional-condition.vue +276 -0
  36. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields-utils.js +34 -0
  37. package/packages/workflow-editor/src/properties-editors/common/auto-filled-fields.vue +239 -0
  38. package/packages/workflow-editor/src/properties-editors/common/common-notice-tool.vue +47 -0
  39. package/packages/workflow-editor/src/properties-editors/common/common-user-condition.vue +241 -0
  40. package/packages/workflow-editor/src/properties-editors/common/form-fields-utils.js +23 -0
  41. package/packages/workflow-editor/src/properties-editors/common/form-fields.vue +116 -0
  42. package/packages/workflow-editor/src/properties-editors/common/i18n-input.vue +75 -0
  43. package/packages/workflow-editor/src/properties-editors/common/i18n-set-dialog.vue +125 -0
  44. package/packages/workflow-editor/src/properties-editors/common/notice.vue +98 -0
  45. package/packages/workflow-editor/src/properties-editors/common/reminder.vue +179 -0
  46. package/packages/workflow-editor/src/properties-editors/common/select-mail-template.vue +83 -0
  47. package/packages/workflow-editor/src/properties-editors/common/standard-fields.vue +65 -0
  48. package/packages/workflow-editor/src/properties-editors/common/system-role-tree-inline.vue +355 -0
  49. package/packages/workflow-editor/src/properties-editors/common/system-role-tree.vue +63 -0
  50. package/packages/workflow-editor/src/properties-editors/common/task-title.vue +148 -0
  51. package/packages/workflow-editor/src/properties-editors/common/transactor-settings.vue +220 -0
  52. package/packages/workflow-editor/src/properties-editors/common/user-selection.vue +386 -0
  53. package/packages/workflow-editor/src/properties-editors/common/value-selection-dialog.vue +209 -0
  54. package/packages/workflow-editor/src/properties-editors/common/variables.vue +135 -0
  55. package/packages/workflow-editor/src/properties-editors/copy-task/basic-properties.vue +90 -0
  56. package/packages/workflow-editor/src/properties-editors/copy-task/permission-settings.vue +155 -0
  57. package/packages/workflow-editor/src/properties-editors/copy-task.vue +80 -0
  58. package/packages/workflow-editor/src/properties-editors/decision.vue +90 -0
  59. package/packages/workflow-editor/src/properties-editors/fork.vue +72 -0
  60. package/packages/workflow-editor/src/properties-editors/human-decision.vue +44 -0
  61. package/packages/workflow-editor/src/properties-editors/human-task/additional-condition-dialog.vue +60 -0
  62. package/packages/workflow-editor/src/properties-editors/human-task/basic-properties.vue +156 -0
  63. package/packages/workflow-editor/src/properties-editors/human-task/componentsConfigUtil.js +291 -0
  64. package/packages/workflow-editor/src/properties-editors/human-task/custom-actions.vue +249 -0
  65. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-field-setting.vue +392 -0
  66. package/packages/workflow-editor/src/properties-editors/human-task/editable-child-fields.vue +241 -0
  67. package/packages/workflow-editor/src/properties-editors/human-task/editable-field-selection.vue +220 -0
  68. package/packages/workflow-editor/src/properties-editors/human-task/editable-fields.vue +204 -0
  69. package/packages/workflow-editor/src/properties-editors/human-task/events.vue +59 -0
  70. package/packages/workflow-editor/src/properties-editors/human-task/permission-settings.vue +207 -0
  71. package/packages/workflow-editor/src/properties-editors/human-task/selection-conditions.vue +390 -0
  72. package/packages/workflow-editor/src/properties-editors/human-task.vue +103 -0
  73. package/packages/workflow-editor/src/properties-editors/join.vue +44 -0
  74. package/packages/workflow-editor/src/properties-editors/process/basic-properties.vue +273 -0
  75. package/packages/workflow-editor/src/properties-editors/process/events.vue +76 -0
  76. package/packages/workflow-editor/src/properties-editors/process/notice-settings.vue +60 -0
  77. package/packages/workflow-editor/src/properties-editors/process/parameter-settings.vue +95 -0
  78. package/packages/workflow-editor/src/properties-editors/process/permission-settings.vue +28 -0
  79. package/packages/workflow-editor/src/properties-editors/process/selectPage.vue +81 -0
  80. package/packages/workflow-editor/src/properties-editors/process.vue +109 -0
  81. package/packages/workflow-editor/src/properties-editors/subprocess/basic-properties.vue +176 -0
  82. package/packages/workflow-editor/src/properties-editors/subprocess/events.vue +26 -0
  83. package/packages/workflow-editor/src/properties-editors/subprocess/field-mappings.vue +206 -0
  84. package/packages/workflow-editor/src/properties-editors/subprocess/transactor-settings.vue +64 -0
  85. package/packages/workflow-editor/src/properties-editors/subprocess.vue +79 -0
  86. package/packages/workflow-editor/src/properties-editors/transition/basic-properties.vue +53 -0
  87. package/packages/workflow-editor/src/properties-editors/transition.vue +74 -0
  88. package/packages/workflow-editor/src/properties-editors/user-condition.js +177 -0
  89. package/packages/workflow-editor/src/store/getters.js +27 -0
  90. package/packages/workflow-editor/src/store/workflow-editor.js +125 -0
  91. package/packages/workflow-editor/src/taches/common-methods.js +21 -0
  92. package/packages/workflow-editor/src/taches/copy-task.vue +99 -0
  93. package/packages/workflow-editor/src/taches/custom-task.vue +88 -0
  94. package/packages/workflow-editor/src/taches/decision.vue +102 -0
  95. package/packages/workflow-editor/src/taches/end.vue +76 -0
  96. package/packages/workflow-editor/src/taches/fork.vue +102 -0
  97. package/packages/workflow-editor/src/taches/human-decision.vue +102 -0
  98. package/packages/workflow-editor/src/taches/human-task.vue +113 -0
  99. package/packages/workflow-editor/src/taches/join.vue +91 -0
  100. package/packages/workflow-editor/src/taches/joint.vue +177 -0
  101. package/packages/workflow-editor/src/taches/start.vue +76 -0
  102. package/packages/workflow-editor/src/taches/subprocess.vue +99 -0
  103. package/packages/workflow-editor/src/taches/tache-resizer.vue +80 -0
  104. package/packages/workflow-editor/src/transitions/broken-line.vue +91 -0
  105. package/packages/workflow-editor/src/transitions/curve-line.vue +91 -0
  106. package/packages/workflow-editor/src/transitions/straight-line.vue +26 -0
  107. package/packages/workflow-editor/src/transitions/transition.vue +212 -0
  108. package/packages/workflow-editor/src/transitions/virtual-transition.vue +43 -0
  109. package/packages/workflow-editor/src/util.js +493 -0
  110. package/packages/workflow-editor/src/workflow-editor.vue +605 -0
  111. package/packages/workflow-editor/src/workflow-history.vue +153 -0
  112. package/src/index.js +28 -0
  113. package/lib/css/workflow-editor.common~247b300f.28fbd3a3.css +0 -1
  114. package/lib/css/workflow-editor.common~62bcfb54.c1b3ecc5.css +0 -1
  115. package/lib/css/workflow-editor.common~95b80cda.16e04122.css +0 -1
  116. package/lib/css/workflow-editor.common~e19cd708.68e04fb4.css +0 -1
  117. package/lib/css/workflow-editor.umd.min~247b300f.28fbd3a3.css +0 -1
  118. package/lib/css/workflow-editor.umd.min~62bcfb54.c1b3ecc5.css +0 -1
  119. package/lib/css/workflow-editor.umd.min~95b80cda.16e04122.css +0 -1
  120. package/lib/css/workflow-editor.umd.min~e19cd708.68e04fb4.css +0 -1
  121. package/lib/css/workflow-editor.umd~247b300f.28fbd3a3.css +0 -1
  122. package/lib/css/workflow-editor.umd~62bcfb54.c1b3ecc5.css +0 -1
  123. package/lib/css/workflow-editor.umd~95b80cda.16e04122.css +0 -1
  124. package/lib/css/workflow-editor.umd~e19cd708.68e04fb4.css +0 -1
  125. package/lib/css/yarn.prismjs~0bd0e877.9093a967.css +0 -1
  126. package/lib/workflow-editor.common.vendors~workflow-editor.common~253ae210.js +0 -4136
  127. package/lib/workflow-editor.common.workflow-editor.common~0b5ad61a.js +0 -1022
  128. package/lib/workflow-editor.common.workflow-editor.common~247b300f.js +0 -1948
  129. package/lib/workflow-editor.common.workflow-editor.common~62bcfb54.js +0 -14764
  130. package/lib/workflow-editor.common.workflow-editor.common~95b80cda.js +0 -3300
  131. package/lib/workflow-editor.common.workflow-editor.common~e19cd708.js +0 -1585
  132. package/lib/workflow-editor.common.workflow-editor.common~e2e93592.js +0 -1293
  133. package/lib/workflow-editor.common.yarn.async-validator~7864cd12.js +0 -1223
  134. package/lib/workflow-editor.common.yarn.buffer~7e5e8261.js +0 -1801
  135. package/lib/workflow-editor.common.yarn.core-js~2b13b260.js +0 -5078
  136. package/lib/workflow-editor.common.yarn.imatrix-ui~f5767151.js +0 -2256
  137. package/lib/workflow-editor.common.yarn.prismjs~0bd0e877.js +0 -2028
  138. package/lib/workflow-editor.common.yarn.readable-stream~2b6d3a99.js +0 -2435
  139. package/lib/workflow-editor.common.yarn.sax~95191fae.js +0 -1576
  140. package/lib/workflow-editor.common.yarn.vue-i18n~02576867.js +0 -2259
  141. package/lib/workflow-editor.umd.min.vendors~workflow-editor.umd.min~253ae210.js +0 -12
  142. package/lib/workflow-editor.umd.min.workflow-editor.umd.min~0b5ad61a.js +0 -1
  143. package/lib/workflow-editor.umd.min.workflow-editor.umd.min~247b300f.js +0 -1
  144. package/lib/workflow-editor.umd.min.workflow-editor.umd.min~62bcfb54.js +0 -1
  145. package/lib/workflow-editor.umd.min.workflow-editor.umd.min~95b80cda.js +0 -1
  146. package/lib/workflow-editor.umd.min.workflow-editor.umd.min~e19cd708.js +0 -1
  147. package/lib/workflow-editor.umd.min.yarn.async-validator~7864cd12.js +0 -1
  148. package/lib/workflow-editor.umd.min.yarn.buffer~7e5e8261.js +0 -8
  149. package/lib/workflow-editor.umd.min.yarn.core-js~2b13b260.js +0 -1
  150. package/lib/workflow-editor.umd.min.yarn.imatrix-ui~f5767151.js +0 -1
  151. package/lib/workflow-editor.umd.min.yarn.prismjs~0bd0e877.js +0 -9
  152. package/lib/workflow-editor.umd.min.yarn.readable-stream~2b6d3a99.js +0 -1
  153. package/lib/workflow-editor.umd.min.yarn.sax~95191fae.js +0 -2
  154. package/lib/workflow-editor.umd.min.yarn.vue-i18n~02576867.js +0 -6
  155. package/lib/workflow-editor.umd.vendors~workflow-editor.umd~253ae210.js +0 -4136
  156. package/lib/workflow-editor.umd.workflow-editor.umd~0b5ad61a.js +0 -1032
  157. package/lib/workflow-editor.umd.workflow-editor.umd~247b300f.js +0 -1948
  158. package/lib/workflow-editor.umd.workflow-editor.umd~62bcfb54.js +0 -14764
  159. package/lib/workflow-editor.umd.workflow-editor.umd~95b80cda.js +0 -3300
  160. package/lib/workflow-editor.umd.workflow-editor.umd~e19cd708.js +0 -1585
  161. package/lib/workflow-editor.umd.workflow-editor.umd~e2e93592.js +0 -1293
  162. package/lib/workflow-editor.umd.yarn.async-validator~7864cd12.js +0 -1223
  163. package/lib/workflow-editor.umd.yarn.buffer~7e5e8261.js +0 -1801
  164. package/lib/workflow-editor.umd.yarn.core-js~2b13b260.js +0 -5078
  165. package/lib/workflow-editor.umd.yarn.imatrix-ui~f5767151.js +0 -2256
  166. package/lib/workflow-editor.umd.yarn.prismjs~0bd0e877.js +0 -2028
  167. package/lib/workflow-editor.umd.yarn.readable-stream~2b6d3a99.js +0 -2435
  168. package/lib/workflow-editor.umd.yarn.sax~95191fae.js +0 -1576
  169. package/lib/workflow-editor.umd.yarn.vue-i18n~02576867.js +0 -2259
@@ -1,2259 +0,0 @@
1
- ((typeof self !== 'undefined' ? self : this)["webpackJsonpworkflow_editor"] = (typeof self !== 'undefined' ? self : this)["webpackJsonpworkflow_editor"] || []).push([[15],{
2
-
3
- /***/ "a925":
4
- /***/ (function(module, __webpack_exports__, __webpack_require__) {
5
-
6
- "use strict";
7
- /*!
8
- * vue-i18n v8.28.2
9
- * (c) 2022 kazuya kawaguchi
10
- * Released under the MIT License.
11
- */
12
- /* */
13
-
14
- /**
15
- * constants
16
- */
17
-
18
- var numberFormatKeys = [
19
- 'compactDisplay',
20
- 'currency',
21
- 'currencyDisplay',
22
- 'currencySign',
23
- 'localeMatcher',
24
- 'notation',
25
- 'numberingSystem',
26
- 'signDisplay',
27
- 'style',
28
- 'unit',
29
- 'unitDisplay',
30
- 'useGrouping',
31
- 'minimumIntegerDigits',
32
- 'minimumFractionDigits',
33
- 'maximumFractionDigits',
34
- 'minimumSignificantDigits',
35
- 'maximumSignificantDigits'
36
- ];
37
-
38
- var dateTimeFormatKeys = [
39
- 'dateStyle',
40
- 'timeStyle',
41
- 'calendar',
42
- 'localeMatcher',
43
- "hour12",
44
- "hourCycle",
45
- "timeZone",
46
- "formatMatcher",
47
- 'weekday',
48
- 'era',
49
- 'year',
50
- 'month',
51
- 'day',
52
- 'hour',
53
- 'minute',
54
- 'second',
55
- 'timeZoneName' ];
56
-
57
- /**
58
- * utilities
59
- */
60
-
61
- function warn (msg, err) {
62
- if (typeof console !== 'undefined') {
63
- console.warn('[vue-i18n] ' + msg);
64
- /* istanbul ignore if */
65
- if (err) {
66
- console.warn(err.stack);
67
- }
68
- }
69
- }
70
-
71
- function error (msg, err) {
72
- if (typeof console !== 'undefined') {
73
- console.error('[vue-i18n] ' + msg);
74
- /* istanbul ignore if */
75
- if (err) {
76
- console.error(err.stack);
77
- }
78
- }
79
- }
80
-
81
- var isArray = Array.isArray;
82
-
83
- function isObject (obj) {
84
- return obj !== null && typeof obj === 'object'
85
- }
86
-
87
- function isBoolean (val) {
88
- return typeof val === 'boolean'
89
- }
90
-
91
- function isString (val) {
92
- return typeof val === 'string'
93
- }
94
-
95
- var toString = Object.prototype.toString;
96
- var OBJECT_STRING = '[object Object]';
97
- function isPlainObject (obj) {
98
- return toString.call(obj) === OBJECT_STRING
99
- }
100
-
101
- function isNull (val) {
102
- return val === null || val === undefined
103
- }
104
-
105
- function isFunction (val) {
106
- return typeof val === 'function'
107
- }
108
-
109
- function parseArgs () {
110
- var args = [], len = arguments.length;
111
- while ( len-- ) args[ len ] = arguments[ len ];
112
-
113
- var locale = null;
114
- var params = null;
115
- if (args.length === 1) {
116
- if (isObject(args[0]) || isArray(args[0])) {
117
- params = args[0];
118
- } else if (typeof args[0] === 'string') {
119
- locale = args[0];
120
- }
121
- } else if (args.length === 2) {
122
- if (typeof args[0] === 'string') {
123
- locale = args[0];
124
- }
125
- /* istanbul ignore if */
126
- if (isObject(args[1]) || isArray(args[1])) {
127
- params = args[1];
128
- }
129
- }
130
-
131
- return { locale: locale, params: params }
132
- }
133
-
134
- function looseClone (obj) {
135
- return JSON.parse(JSON.stringify(obj))
136
- }
137
-
138
- function remove (arr, item) {
139
- if (arr.delete(item)) {
140
- return arr
141
- }
142
- }
143
-
144
- function arrayFrom (arr) {
145
- var ret = [];
146
- arr.forEach(function (a) { return ret.push(a); });
147
- return ret
148
- }
149
-
150
- function includes (arr, item) {
151
- return !!~arr.indexOf(item)
152
- }
153
-
154
- var hasOwnProperty = Object.prototype.hasOwnProperty;
155
- function hasOwn (obj, key) {
156
- return hasOwnProperty.call(obj, key)
157
- }
158
-
159
- function merge (target) {
160
- var arguments$1 = arguments;
161
-
162
- var output = Object(target);
163
- for (var i = 1; i < arguments.length; i++) {
164
- var source = arguments$1[i];
165
- if (source !== undefined && source !== null) {
166
- var key = (void 0);
167
- for (key in source) {
168
- if (hasOwn(source, key)) {
169
- if (isObject(source[key])) {
170
- output[key] = merge(output[key], source[key]);
171
- } else {
172
- output[key] = source[key];
173
- }
174
- }
175
- }
176
- }
177
- }
178
- return output
179
- }
180
-
181
- function looseEqual (a, b) {
182
- if (a === b) { return true }
183
- var isObjectA = isObject(a);
184
- var isObjectB = isObject(b);
185
- if (isObjectA && isObjectB) {
186
- try {
187
- var isArrayA = isArray(a);
188
- var isArrayB = isArray(b);
189
- if (isArrayA && isArrayB) {
190
- return a.length === b.length && a.every(function (e, i) {
191
- return looseEqual(e, b[i])
192
- })
193
- } else if (!isArrayA && !isArrayB) {
194
- var keysA = Object.keys(a);
195
- var keysB = Object.keys(b);
196
- return keysA.length === keysB.length && keysA.every(function (key) {
197
- return looseEqual(a[key], b[key])
198
- })
199
- } else {
200
- /* istanbul ignore next */
201
- return false
202
- }
203
- } catch (e) {
204
- /* istanbul ignore next */
205
- return false
206
- }
207
- } else if (!isObjectA && !isObjectB) {
208
- return String(a) === String(b)
209
- } else {
210
- return false
211
- }
212
- }
213
-
214
- /**
215
- * Sanitizes html special characters from input strings. For mitigating risk of XSS attacks.
216
- * @param rawText The raw input from the user that should be escaped.
217
- */
218
- function escapeHtml(rawText) {
219
- return rawText
220
- .replace(/</g, '&lt;')
221
- .replace(/>/g, '&gt;')
222
- .replace(/"/g, '&quot;')
223
- .replace(/'/g, '&apos;')
224
- }
225
-
226
- /**
227
- * Escapes html tags and special symbols from all provided params which were returned from parseArgs().params.
228
- * This method performs an in-place operation on the params object.
229
- *
230
- * @param {any} params Parameters as provided from `parseArgs().params`.
231
- * May be either an array of strings or a string->any map.
232
- *
233
- * @returns The manipulated `params` object.
234
- */
235
- function escapeParams(params) {
236
- if(params != null) {
237
- Object.keys(params).forEach(function (key) {
238
- if(typeof(params[key]) == 'string') {
239
- params[key] = escapeHtml(params[key]);
240
- }
241
- });
242
- }
243
- return params
244
- }
245
-
246
- /* */
247
-
248
- function extend (Vue) {
249
- if (!Vue.prototype.hasOwnProperty('$i18n')) {
250
- // $FlowFixMe
251
- Object.defineProperty(Vue.prototype, '$i18n', {
252
- get: function get () { return this._i18n }
253
- });
254
- }
255
-
256
- Vue.prototype.$t = function (key) {
257
- var values = [], len = arguments.length - 1;
258
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
259
-
260
- var i18n = this.$i18n;
261
- return i18n._t.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this ].concat( values ))
262
- };
263
-
264
- Vue.prototype.$tc = function (key, choice) {
265
- var values = [], len = arguments.length - 2;
266
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
267
-
268
- var i18n = this.$i18n;
269
- return i18n._tc.apply(i18n, [ key, i18n.locale, i18n._getMessages(), this, choice ].concat( values ))
270
- };
271
-
272
- Vue.prototype.$te = function (key, locale) {
273
- var i18n = this.$i18n;
274
- return i18n._te(key, i18n.locale, i18n._getMessages(), locale)
275
- };
276
-
277
- Vue.prototype.$d = function (value) {
278
- var ref;
279
-
280
- var args = [], len = arguments.length - 1;
281
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
282
- return (ref = this.$i18n).d.apply(ref, [ value ].concat( args ))
283
- };
284
-
285
- Vue.prototype.$n = function (value) {
286
- var ref;
287
-
288
- var args = [], len = arguments.length - 1;
289
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
290
- return (ref = this.$i18n).n.apply(ref, [ value ].concat( args ))
291
- };
292
- }
293
-
294
- /* */
295
-
296
- /**
297
- * Mixin
298
- *
299
- * If `bridge` mode, empty mixin is returned,
300
- * else regulary mixin implementation is returned.
301
- */
302
- function defineMixin (bridge) {
303
- if ( bridge === void 0 ) bridge = false;
304
-
305
- function mounted () {
306
- if (this !== this.$root && this.$options.__INTLIFY_META__ && this.$el) {
307
- this.$el.setAttribute('data-intlify', this.$options.__INTLIFY_META__);
308
- }
309
- }
310
-
311
- return bridge
312
- ? { mounted: mounted } // delegate `vue-i18n-bridge` mixin implementation
313
- : { // regulary
314
- beforeCreate: function beforeCreate () {
315
- var options = this.$options;
316
- options.i18n = options.i18n || ((options.__i18nBridge || options.__i18n) ? {} : null);
317
-
318
- if (options.i18n) {
319
- if (options.i18n instanceof VueI18n) {
320
- // init locale messages via custom blocks
321
- if ((options.__i18nBridge || options.__i18n)) {
322
- try {
323
- var localeMessages = options.i18n && options.i18n.messages ? options.i18n.messages : {};
324
- var _i18n = options.__i18nBridge || options.__i18n;
325
- _i18n.forEach(function (resource) {
326
- localeMessages = merge(localeMessages, JSON.parse(resource));
327
- });
328
- Object.keys(localeMessages).forEach(function (locale) {
329
- options.i18n.mergeLocaleMessage(locale, localeMessages[locale]);
330
- });
331
- } catch (e) {
332
- if (false) {}
333
- }
334
- }
335
- this._i18n = options.i18n;
336
- this._i18nWatcher = this._i18n.watchI18nData();
337
- } else if (isPlainObject(options.i18n)) {
338
- var rootI18n = this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n
339
- ? this.$root.$i18n
340
- : null;
341
- // component local i18n
342
- if (rootI18n) {
343
- options.i18n.root = this.$root;
344
- options.i18n.formatter = rootI18n.formatter;
345
- options.i18n.fallbackLocale = rootI18n.fallbackLocale;
346
- options.i18n.formatFallbackMessages = rootI18n.formatFallbackMessages;
347
- options.i18n.silentTranslationWarn = rootI18n.silentTranslationWarn;
348
- options.i18n.silentFallbackWarn = rootI18n.silentFallbackWarn;
349
- options.i18n.pluralizationRules = rootI18n.pluralizationRules;
350
- options.i18n.preserveDirectiveContent = rootI18n.preserveDirectiveContent;
351
- }
352
-
353
- // init locale messages via custom blocks
354
- if ((options.__i18nBridge || options.__i18n)) {
355
- try {
356
- var localeMessages$1 = options.i18n && options.i18n.messages ? options.i18n.messages : {};
357
- var _i18n$1 = options.__i18nBridge || options.__i18n;
358
- _i18n$1.forEach(function (resource) {
359
- localeMessages$1 = merge(localeMessages$1, JSON.parse(resource));
360
- });
361
- options.i18n.messages = localeMessages$1;
362
- } catch (e) {
363
- if (false) {}
364
- }
365
- }
366
-
367
- var ref = options.i18n;
368
- var sharedMessages = ref.sharedMessages;
369
- if (sharedMessages && isPlainObject(sharedMessages)) {
370
- options.i18n.messages = merge(options.i18n.messages, sharedMessages);
371
- }
372
-
373
- this._i18n = new VueI18n(options.i18n);
374
- this._i18nWatcher = this._i18n.watchI18nData();
375
-
376
- if (options.i18n.sync === undefined || !!options.i18n.sync) {
377
- this._localeWatcher = this.$i18n.watchLocale();
378
- }
379
-
380
- if (rootI18n) {
381
- rootI18n.onComponentInstanceCreated(this._i18n);
382
- }
383
- } else {
384
- if (false) {}
385
- }
386
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
387
- // root i18n
388
- this._i18n = this.$root.$i18n;
389
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
390
- // parent i18n
391
- this._i18n = options.parent.$i18n;
392
- }
393
- },
394
-
395
- beforeMount: function beforeMount () {
396
- var options = this.$options;
397
- options.i18n = options.i18n || ((options.__i18nBridge || options.__i18n) ? {} : null);
398
-
399
- if (options.i18n) {
400
- if (options.i18n instanceof VueI18n) {
401
- // init locale messages via custom blocks
402
- this._i18n.subscribeDataChanging(this);
403
- this._subscribing = true;
404
- } else if (isPlainObject(options.i18n)) {
405
- this._i18n.subscribeDataChanging(this);
406
- this._subscribing = true;
407
- } else {
408
- if (false) {}
409
- }
410
- } else if (this.$root && this.$root.$i18n && this.$root.$i18n instanceof VueI18n) {
411
- this._i18n.subscribeDataChanging(this);
412
- this._subscribing = true;
413
- } else if (options.parent && options.parent.$i18n && options.parent.$i18n instanceof VueI18n) {
414
- this._i18n.subscribeDataChanging(this);
415
- this._subscribing = true;
416
- }
417
- },
418
-
419
- mounted: mounted,
420
-
421
- beforeDestroy: function beforeDestroy () {
422
- if (!this._i18n) { return }
423
-
424
- var self = this;
425
- this.$nextTick(function () {
426
- if (self._subscribing) {
427
- self._i18n.unsubscribeDataChanging(self);
428
- delete self._subscribing;
429
- }
430
-
431
- if (self._i18nWatcher) {
432
- self._i18nWatcher();
433
- self._i18n.destroyVM();
434
- delete self._i18nWatcher;
435
- }
436
-
437
- if (self._localeWatcher) {
438
- self._localeWatcher();
439
- delete self._localeWatcher;
440
- }
441
- });
442
- }
443
- }
444
- }
445
-
446
- /* */
447
-
448
- var interpolationComponent = {
449
- name: 'i18n',
450
- functional: true,
451
- props: {
452
- tag: {
453
- type: [String, Boolean, Object],
454
- default: 'span'
455
- },
456
- path: {
457
- type: String,
458
- required: true
459
- },
460
- locale: {
461
- type: String
462
- },
463
- places: {
464
- type: [Array, Object]
465
- }
466
- },
467
- render: function render (h, ref) {
468
- var data = ref.data;
469
- var parent = ref.parent;
470
- var props = ref.props;
471
- var slots = ref.slots;
472
-
473
- var $i18n = parent.$i18n;
474
- if (!$i18n) {
475
- if (false) {}
476
- return
477
- }
478
-
479
- var path = props.path;
480
- var locale = props.locale;
481
- var places = props.places;
482
- var params = slots();
483
- var children = $i18n.i(
484
- path,
485
- locale,
486
- onlyHasDefaultPlace(params) || places
487
- ? useLegacyPlaces(params.default, places)
488
- : params
489
- );
490
-
491
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
492
- return tag ? h(tag, data, children) : children
493
- }
494
- };
495
-
496
- function onlyHasDefaultPlace (params) {
497
- var prop;
498
- for (prop in params) {
499
- if (prop !== 'default') { return false }
500
- }
501
- return Boolean(prop)
502
- }
503
-
504
- function useLegacyPlaces (children, places) {
505
- var params = places ? createParamsFromPlaces(places) : {};
506
-
507
- if (!children) { return params }
508
-
509
- // Filter empty text nodes
510
- children = children.filter(function (child) {
511
- return child.tag || child.text.trim() !== ''
512
- });
513
-
514
- var everyPlace = children.every(vnodeHasPlaceAttribute);
515
- if (false) {}
516
-
517
- return children.reduce(
518
- everyPlace ? assignChildPlace : assignChildIndex,
519
- params
520
- )
521
- }
522
-
523
- function createParamsFromPlaces (places) {
524
- if (false) {}
525
-
526
- return Array.isArray(places)
527
- ? places.reduce(assignChildIndex, {})
528
- : Object.assign({}, places)
529
- }
530
-
531
- function assignChildPlace (params, child) {
532
- if (child.data && child.data.attrs && child.data.attrs.place) {
533
- params[child.data.attrs.place] = child;
534
- }
535
- return params
536
- }
537
-
538
- function assignChildIndex (params, child, index) {
539
- params[index] = child;
540
- return params
541
- }
542
-
543
- function vnodeHasPlaceAttribute (vnode) {
544
- return Boolean(vnode.data && vnode.data.attrs && vnode.data.attrs.place)
545
- }
546
-
547
- /* */
548
-
549
- var numberComponent = {
550
- name: 'i18n-n',
551
- functional: true,
552
- props: {
553
- tag: {
554
- type: [String, Boolean, Object],
555
- default: 'span'
556
- },
557
- value: {
558
- type: Number,
559
- required: true
560
- },
561
- format: {
562
- type: [String, Object]
563
- },
564
- locale: {
565
- type: String
566
- }
567
- },
568
- render: function render (h, ref) {
569
- var props = ref.props;
570
- var parent = ref.parent;
571
- var data = ref.data;
572
-
573
- var i18n = parent.$i18n;
574
-
575
- if (!i18n) {
576
- if (false) {}
577
- return null
578
- }
579
-
580
- var key = null;
581
- var options = null;
582
-
583
- if (isString(props.format)) {
584
- key = props.format;
585
- } else if (isObject(props.format)) {
586
- if (props.format.key) {
587
- key = props.format.key;
588
- }
589
-
590
- // Filter out number format options only
591
- options = Object.keys(props.format).reduce(function (acc, prop) {
592
- var obj;
593
-
594
- if (includes(numberFormatKeys, prop)) {
595
- return Object.assign({}, acc, ( obj = {}, obj[prop] = props.format[prop], obj ))
596
- }
597
- return acc
598
- }, null);
599
- }
600
-
601
- var locale = props.locale || i18n.locale;
602
- var parts = i18n._ntp(props.value, locale, key, options);
603
-
604
- var values = parts.map(function (part, index) {
605
- var obj;
606
-
607
- var slot = data.scopedSlots && data.scopedSlots[part.type];
608
- return slot ? slot(( obj = {}, obj[part.type] = part.value, obj.index = index, obj.parts = parts, obj )) : part.value
609
- });
610
-
611
- var tag = (!!props.tag && props.tag !== true) || props.tag === false ? props.tag : 'span';
612
- return tag
613
- ? h(tag, {
614
- attrs: data.attrs,
615
- 'class': data['class'],
616
- staticClass: data.staticClass
617
- }, values)
618
- : values
619
- }
620
- };
621
-
622
- /* */
623
-
624
- function bind (el, binding, vnode) {
625
- if (!assert(el, vnode)) { return }
626
-
627
- t(el, binding, vnode);
628
- }
629
-
630
- function update (el, binding, vnode, oldVNode) {
631
- if (!assert(el, vnode)) { return }
632
-
633
- var i18n = vnode.context.$i18n;
634
- if (localeEqual(el, vnode) &&
635
- (looseEqual(binding.value, binding.oldValue) &&
636
- looseEqual(el._localeMessage, i18n.getLocaleMessage(i18n.locale)))) { return }
637
-
638
- t(el, binding, vnode);
639
- }
640
-
641
- function unbind (el, binding, vnode, oldVNode) {
642
- var vm = vnode.context;
643
- if (!vm) {
644
- warn('Vue instance does not exists in VNode context');
645
- return
646
- }
647
-
648
- var i18n = vnode.context.$i18n || {};
649
- if (!binding.modifiers.preserve && !i18n.preserveDirectiveContent) {
650
- el.textContent = '';
651
- }
652
- el._vt = undefined;
653
- delete el['_vt'];
654
- el._locale = undefined;
655
- delete el['_locale'];
656
- el._localeMessage = undefined;
657
- delete el['_localeMessage'];
658
- }
659
-
660
- function assert (el, vnode) {
661
- var vm = vnode.context;
662
- if (!vm) {
663
- warn('Vue instance does not exists in VNode context');
664
- return false
665
- }
666
-
667
- if (!vm.$i18n) {
668
- warn('VueI18n instance does not exists in Vue instance');
669
- return false
670
- }
671
-
672
- return true
673
- }
674
-
675
- function localeEqual (el, vnode) {
676
- var vm = vnode.context;
677
- return el._locale === vm.$i18n.locale
678
- }
679
-
680
- function t (el, binding, vnode) {
681
- var ref$1, ref$2;
682
-
683
- var value = binding.value;
684
-
685
- var ref = parseValue(value);
686
- var path = ref.path;
687
- var locale = ref.locale;
688
- var args = ref.args;
689
- var choice = ref.choice;
690
- if (!path && !locale && !args) {
691
- warn('value type not supported');
692
- return
693
- }
694
-
695
- if (!path) {
696
- warn('`path` is required in v-t directive');
697
- return
698
- }
699
-
700
- var vm = vnode.context;
701
- if (choice != null) {
702
- el._vt = el.textContent = (ref$1 = vm.$i18n).tc.apply(ref$1, [ path, choice ].concat( makeParams(locale, args) ));
703
- } else {
704
- el._vt = el.textContent = (ref$2 = vm.$i18n).t.apply(ref$2, [ path ].concat( makeParams(locale, args) ));
705
- }
706
- el._locale = vm.$i18n.locale;
707
- el._localeMessage = vm.$i18n.getLocaleMessage(vm.$i18n.locale);
708
- }
709
-
710
- function parseValue (value) {
711
- var path;
712
- var locale;
713
- var args;
714
- var choice;
715
-
716
- if (isString(value)) {
717
- path = value;
718
- } else if (isPlainObject(value)) {
719
- path = value.path;
720
- locale = value.locale;
721
- args = value.args;
722
- choice = value.choice;
723
- }
724
-
725
- return { path: path, locale: locale, args: args, choice: choice }
726
- }
727
-
728
- function makeParams (locale, args) {
729
- var params = [];
730
-
731
- locale && params.push(locale);
732
- if (args && (Array.isArray(args) || isPlainObject(args))) {
733
- params.push(args);
734
- }
735
-
736
- return params
737
- }
738
-
739
- var Vue;
740
-
741
- function install (_Vue, options) {
742
- if ( options === void 0 ) options = { bridge: false };
743
-
744
- /* istanbul ignore if */
745
- if (false) {}
746
- install.installed = true;
747
-
748
- Vue = _Vue;
749
-
750
- var version = (Vue.version && Number(Vue.version.split('.')[0])) || -1;
751
- /* istanbul ignore if */
752
- if (false) {}
753
-
754
- extend(Vue);
755
- Vue.mixin(defineMixin(options.bridge));
756
- Vue.directive('t', { bind: bind, update: update, unbind: unbind });
757
- Vue.component(interpolationComponent.name, interpolationComponent);
758
- Vue.component(numberComponent.name, numberComponent);
759
-
760
- // use simple mergeStrategies to prevent i18n instance lose '__proto__'
761
- var strats = Vue.config.optionMergeStrategies;
762
- strats.i18n = function (parentVal, childVal) {
763
- return childVal === undefined
764
- ? parentVal
765
- : childVal
766
- };
767
- }
768
-
769
- /* */
770
-
771
- var BaseFormatter = function BaseFormatter () {
772
- this._caches = Object.create(null);
773
- };
774
-
775
- BaseFormatter.prototype.interpolate = function interpolate (message, values) {
776
- if (!values) {
777
- return [message]
778
- }
779
- var tokens = this._caches[message];
780
- if (!tokens) {
781
- tokens = parse(message);
782
- this._caches[message] = tokens;
783
- }
784
- return compile(tokens, values)
785
- };
786
-
787
-
788
-
789
- var RE_TOKEN_LIST_VALUE = /^(?:\d)+/;
790
- var RE_TOKEN_NAMED_VALUE = /^(?:\w)+/;
791
-
792
- function parse (format) {
793
- var tokens = [];
794
- var position = 0;
795
-
796
- var text = '';
797
- while (position < format.length) {
798
- var char = format[position++];
799
- if (char === '{') {
800
- if (text) {
801
- tokens.push({ type: 'text', value: text });
802
- }
803
-
804
- text = '';
805
- var sub = '';
806
- char = format[position++];
807
- while (char !== undefined && char !== '}') {
808
- sub += char;
809
- char = format[position++];
810
- }
811
- var isClosed = char === '}';
812
-
813
- var type = RE_TOKEN_LIST_VALUE.test(sub)
814
- ? 'list'
815
- : isClosed && RE_TOKEN_NAMED_VALUE.test(sub)
816
- ? 'named'
817
- : 'unknown';
818
- tokens.push({ value: sub, type: type });
819
- } else if (char === '%') {
820
- // when found rails i18n syntax, skip text capture
821
- if (format[(position)] !== '{') {
822
- text += char;
823
- }
824
- } else {
825
- text += char;
826
- }
827
- }
828
-
829
- text && tokens.push({ type: 'text', value: text });
830
-
831
- return tokens
832
- }
833
-
834
- function compile (tokens, values) {
835
- var compiled = [];
836
- var index = 0;
837
-
838
- var mode = Array.isArray(values)
839
- ? 'list'
840
- : isObject(values)
841
- ? 'named'
842
- : 'unknown';
843
- if (mode === 'unknown') { return compiled }
844
-
845
- while (index < tokens.length) {
846
- var token = tokens[index];
847
- switch (token.type) {
848
- case 'text':
849
- compiled.push(token.value);
850
- break
851
- case 'list':
852
- compiled.push(values[parseInt(token.value, 10)]);
853
- break
854
- case 'named':
855
- if (mode === 'named') {
856
- compiled.push((values)[token.value]);
857
- } else {
858
- if (false) {}
859
- }
860
- break
861
- case 'unknown':
862
- if (false) {}
863
- break
864
- }
865
- index++;
866
- }
867
-
868
- return compiled
869
- }
870
-
871
- /* */
872
-
873
- /**
874
- * Path parser
875
- * - Inspired:
876
- * Vue.js Path parser
877
- */
878
-
879
- // actions
880
- var APPEND = 0;
881
- var PUSH = 1;
882
- var INC_SUB_PATH_DEPTH = 2;
883
- var PUSH_SUB_PATH = 3;
884
-
885
- // states
886
- var BEFORE_PATH = 0;
887
- var IN_PATH = 1;
888
- var BEFORE_IDENT = 2;
889
- var IN_IDENT = 3;
890
- var IN_SUB_PATH = 4;
891
- var IN_SINGLE_QUOTE = 5;
892
- var IN_DOUBLE_QUOTE = 6;
893
- var AFTER_PATH = 7;
894
- var ERROR = 8;
895
-
896
- var pathStateMachine = [];
897
-
898
- pathStateMachine[BEFORE_PATH] = {
899
- 'ws': [BEFORE_PATH],
900
- 'ident': [IN_IDENT, APPEND],
901
- '[': [IN_SUB_PATH],
902
- 'eof': [AFTER_PATH]
903
- };
904
-
905
- pathStateMachine[IN_PATH] = {
906
- 'ws': [IN_PATH],
907
- '.': [BEFORE_IDENT],
908
- '[': [IN_SUB_PATH],
909
- 'eof': [AFTER_PATH]
910
- };
911
-
912
- pathStateMachine[BEFORE_IDENT] = {
913
- 'ws': [BEFORE_IDENT],
914
- 'ident': [IN_IDENT, APPEND],
915
- '0': [IN_IDENT, APPEND],
916
- 'number': [IN_IDENT, APPEND]
917
- };
918
-
919
- pathStateMachine[IN_IDENT] = {
920
- 'ident': [IN_IDENT, APPEND],
921
- '0': [IN_IDENT, APPEND],
922
- 'number': [IN_IDENT, APPEND],
923
- 'ws': [IN_PATH, PUSH],
924
- '.': [BEFORE_IDENT, PUSH],
925
- '[': [IN_SUB_PATH, PUSH],
926
- 'eof': [AFTER_PATH, PUSH]
927
- };
928
-
929
- pathStateMachine[IN_SUB_PATH] = {
930
- "'": [IN_SINGLE_QUOTE, APPEND],
931
- '"': [IN_DOUBLE_QUOTE, APPEND],
932
- '[': [IN_SUB_PATH, INC_SUB_PATH_DEPTH],
933
- ']': [IN_PATH, PUSH_SUB_PATH],
934
- 'eof': ERROR,
935
- 'else': [IN_SUB_PATH, APPEND]
936
- };
937
-
938
- pathStateMachine[IN_SINGLE_QUOTE] = {
939
- "'": [IN_SUB_PATH, APPEND],
940
- 'eof': ERROR,
941
- 'else': [IN_SINGLE_QUOTE, APPEND]
942
- };
943
-
944
- pathStateMachine[IN_DOUBLE_QUOTE] = {
945
- '"': [IN_SUB_PATH, APPEND],
946
- 'eof': ERROR,
947
- 'else': [IN_DOUBLE_QUOTE, APPEND]
948
- };
949
-
950
- /**
951
- * Check if an expression is a literal value.
952
- */
953
-
954
- var literalValueRE = /^\s?(?:true|false|-?[\d.]+|'[^']*'|"[^"]*")\s?$/;
955
- function isLiteral (exp) {
956
- return literalValueRE.test(exp)
957
- }
958
-
959
- /**
960
- * Strip quotes from a string
961
- */
962
-
963
- function stripQuotes (str) {
964
- var a = str.charCodeAt(0);
965
- var b = str.charCodeAt(str.length - 1);
966
- return a === b && (a === 0x22 || a === 0x27)
967
- ? str.slice(1, -1)
968
- : str
969
- }
970
-
971
- /**
972
- * Determine the type of a character in a keypath.
973
- */
974
-
975
- function getPathCharType (ch) {
976
- if (ch === undefined || ch === null) { return 'eof' }
977
-
978
- var code = ch.charCodeAt(0);
979
-
980
- switch (code) {
981
- case 0x5B: // [
982
- case 0x5D: // ]
983
- case 0x2E: // .
984
- case 0x22: // "
985
- case 0x27: // '
986
- return ch
987
-
988
- case 0x5F: // _
989
- case 0x24: // $
990
- case 0x2D: // -
991
- return 'ident'
992
-
993
- case 0x09: // Tab
994
- case 0x0A: // Newline
995
- case 0x0D: // Return
996
- case 0xA0: // No-break space
997
- case 0xFEFF: // Byte Order Mark
998
- case 0x2028: // Line Separator
999
- case 0x2029: // Paragraph Separator
1000
- return 'ws'
1001
- }
1002
-
1003
- return 'ident'
1004
- }
1005
-
1006
- /**
1007
- * Format a subPath, return its plain form if it is
1008
- * a literal string or number. Otherwise prepend the
1009
- * dynamic indicator (*).
1010
- */
1011
-
1012
- function formatSubPath (path) {
1013
- var trimmed = path.trim();
1014
- // invalid leading 0
1015
- if (path.charAt(0) === '0' && isNaN(path)) { return false }
1016
-
1017
- return isLiteral(trimmed) ? stripQuotes(trimmed) : '*' + trimmed
1018
- }
1019
-
1020
- /**
1021
- * Parse a string path into an array of segments
1022
- */
1023
-
1024
- function parse$1 (path) {
1025
- var keys = [];
1026
- var index = -1;
1027
- var mode = BEFORE_PATH;
1028
- var subPathDepth = 0;
1029
- var c;
1030
- var key;
1031
- var newChar;
1032
- var type;
1033
- var transition;
1034
- var action;
1035
- var typeMap;
1036
- var actions = [];
1037
-
1038
- actions[PUSH] = function () {
1039
- if (key !== undefined) {
1040
- keys.push(key);
1041
- key = undefined;
1042
- }
1043
- };
1044
-
1045
- actions[APPEND] = function () {
1046
- if (key === undefined) {
1047
- key = newChar;
1048
- } else {
1049
- key += newChar;
1050
- }
1051
- };
1052
-
1053
- actions[INC_SUB_PATH_DEPTH] = function () {
1054
- actions[APPEND]();
1055
- subPathDepth++;
1056
- };
1057
-
1058
- actions[PUSH_SUB_PATH] = function () {
1059
- if (subPathDepth > 0) {
1060
- subPathDepth--;
1061
- mode = IN_SUB_PATH;
1062
- actions[APPEND]();
1063
- } else {
1064
- subPathDepth = 0;
1065
- if (key === undefined) { return false }
1066
- key = formatSubPath(key);
1067
- if (key === false) {
1068
- return false
1069
- } else {
1070
- actions[PUSH]();
1071
- }
1072
- }
1073
- };
1074
-
1075
- function maybeUnescapeQuote () {
1076
- var nextChar = path[index + 1];
1077
- if ((mode === IN_SINGLE_QUOTE && nextChar === "'") ||
1078
- (mode === IN_DOUBLE_QUOTE && nextChar === '"')) {
1079
- index++;
1080
- newChar = '\\' + nextChar;
1081
- actions[APPEND]();
1082
- return true
1083
- }
1084
- }
1085
-
1086
- while (mode !== null) {
1087
- index++;
1088
- c = path[index];
1089
-
1090
- if (c === '\\' && maybeUnescapeQuote()) {
1091
- continue
1092
- }
1093
-
1094
- type = getPathCharType(c);
1095
- typeMap = pathStateMachine[mode];
1096
- transition = typeMap[type] || typeMap['else'] || ERROR;
1097
-
1098
- if (transition === ERROR) {
1099
- return // parse error
1100
- }
1101
-
1102
- mode = transition[0];
1103
- action = actions[transition[1]];
1104
- if (action) {
1105
- newChar = transition[2];
1106
- newChar = newChar === undefined
1107
- ? c
1108
- : newChar;
1109
- if (action() === false) {
1110
- return
1111
- }
1112
- }
1113
-
1114
- if (mode === AFTER_PATH) {
1115
- return keys
1116
- }
1117
- }
1118
- }
1119
-
1120
-
1121
-
1122
-
1123
-
1124
- var I18nPath = function I18nPath () {
1125
- this._cache = Object.create(null);
1126
- };
1127
-
1128
- /**
1129
- * External parse that check for a cache hit first
1130
- */
1131
- I18nPath.prototype.parsePath = function parsePath (path) {
1132
- var hit = this._cache[path];
1133
- if (!hit) {
1134
- hit = parse$1(path);
1135
- if (hit) {
1136
- this._cache[path] = hit;
1137
- }
1138
- }
1139
- return hit || []
1140
- };
1141
-
1142
- /**
1143
- * Get path value from path string
1144
- */
1145
- I18nPath.prototype.getPathValue = function getPathValue (obj, path) {
1146
- if (!isObject(obj)) { return null }
1147
-
1148
- var paths = this.parsePath(path);
1149
- if (paths.length === 0) {
1150
- return null
1151
- } else {
1152
- var length = paths.length;
1153
- var last = obj;
1154
- var i = 0;
1155
- while (i < length) {
1156
- var value = last[paths[i]];
1157
- if (value === undefined || value === null) {
1158
- return null
1159
- }
1160
- last = value;
1161
- i++;
1162
- }
1163
-
1164
- return last
1165
- }
1166
- };
1167
-
1168
- /* */
1169
-
1170
-
1171
-
1172
- var htmlTagMatcher = /<\/?[\w\s="/.':;#-\/]+>/;
1173
- var linkKeyMatcher = /(?:@(?:\.[a-zA-Z]+)?:(?:[\w\-_|./]+|\([\w\-_:|./]+\)))/g;
1174
- var linkKeyPrefixMatcher = /^@(?:\.([a-zA-Z]+))?:/;
1175
- var bracketsMatcher = /[()]/g;
1176
- var defaultModifiers = {
1177
- 'upper': function (str) { return str.toLocaleUpperCase(); },
1178
- 'lower': function (str) { return str.toLocaleLowerCase(); },
1179
- 'capitalize': function (str) { return ("" + (str.charAt(0).toLocaleUpperCase()) + (str.substr(1))); }
1180
- };
1181
-
1182
- var defaultFormatter = new BaseFormatter();
1183
-
1184
- var VueI18n = function VueI18n (options) {
1185
- var this$1 = this;
1186
- if ( options === void 0 ) options = {};
1187
-
1188
- // Auto install if it is not done yet and `window` has `Vue`.
1189
- // To allow users to avoid auto-installation in some cases,
1190
- // this code should be placed here. See #290
1191
- /* istanbul ignore if */
1192
- if (!Vue && typeof window !== 'undefined' && window.Vue) {
1193
- install(window.Vue);
1194
- }
1195
-
1196
- var locale = options.locale || 'en-US';
1197
- var fallbackLocale = options.fallbackLocale === false
1198
- ? false
1199
- : options.fallbackLocale || 'en-US';
1200
- var messages = options.messages || {};
1201
- var dateTimeFormats = options.dateTimeFormats || options.datetimeFormats || {};
1202
- var numberFormats = options.numberFormats || {};
1203
-
1204
- this._vm = null;
1205
- this._formatter = options.formatter || defaultFormatter;
1206
- this._modifiers = options.modifiers || {};
1207
- this._missing = options.missing || null;
1208
- this._root = options.root || null;
1209
- this._sync = options.sync === undefined ? true : !!options.sync;
1210
- this._fallbackRoot = options.fallbackRoot === undefined
1211
- ? true
1212
- : !!options.fallbackRoot;
1213
- this._fallbackRootWithEmptyString = options.fallbackRootWithEmptyString === undefined
1214
- ? true
1215
- : !!options.fallbackRootWithEmptyString;
1216
- this._formatFallbackMessages = options.formatFallbackMessages === undefined
1217
- ? false
1218
- : !!options.formatFallbackMessages;
1219
- this._silentTranslationWarn = options.silentTranslationWarn === undefined
1220
- ? false
1221
- : options.silentTranslationWarn;
1222
- this._silentFallbackWarn = options.silentFallbackWarn === undefined
1223
- ? false
1224
- : !!options.silentFallbackWarn;
1225
- this._dateTimeFormatters = {};
1226
- this._numberFormatters = {};
1227
- this._path = new I18nPath();
1228
- this._dataListeners = new Set();
1229
- this._componentInstanceCreatedListener = options.componentInstanceCreatedListener || null;
1230
- this._preserveDirectiveContent = options.preserveDirectiveContent === undefined
1231
- ? false
1232
- : !!options.preserveDirectiveContent;
1233
- this.pluralizationRules = options.pluralizationRules || {};
1234
- this._warnHtmlInMessage = options.warnHtmlInMessage || 'off';
1235
- this._postTranslation = options.postTranslation || null;
1236
- this._escapeParameterHtml = options.escapeParameterHtml || false;
1237
-
1238
- if ('__VUE_I18N_BRIDGE__' in options) {
1239
- this.__VUE_I18N_BRIDGE__ = options.__VUE_I18N_BRIDGE__;
1240
- }
1241
-
1242
- /**
1243
- * @param choice {number} a choice index given by the input to $tc: `$tc('path.to.rule', choiceIndex)`
1244
- * @param choicesLength {number} an overall amount of available choices
1245
- * @returns a final choice index
1246
- */
1247
- this.getChoiceIndex = function (choice, choicesLength) {
1248
- var thisPrototype = Object.getPrototypeOf(this$1);
1249
- if (thisPrototype && thisPrototype.getChoiceIndex) {
1250
- var prototypeGetChoiceIndex = (thisPrototype.getChoiceIndex);
1251
- return (prototypeGetChoiceIndex).call(this$1, choice, choicesLength)
1252
- }
1253
-
1254
- // Default (old) getChoiceIndex implementation - english-compatible
1255
- var defaultImpl = function (_choice, _choicesLength) {
1256
- _choice = Math.abs(_choice);
1257
-
1258
- if (_choicesLength === 2) {
1259
- return _choice
1260
- ? _choice > 1
1261
- ? 1
1262
- : 0
1263
- : 1
1264
- }
1265
-
1266
- return _choice ? Math.min(_choice, 2) : 0
1267
- };
1268
-
1269
- if (this$1.locale in this$1.pluralizationRules) {
1270
- return this$1.pluralizationRules[this$1.locale].apply(this$1, [choice, choicesLength])
1271
- } else {
1272
- return defaultImpl(choice, choicesLength)
1273
- }
1274
- };
1275
-
1276
-
1277
- this._exist = function (message, key) {
1278
- if (!message || !key) { return false }
1279
- if (!isNull(this$1._path.getPathValue(message, key))) { return true }
1280
- // fallback for flat key
1281
- if (message[key]) { return true }
1282
- return false
1283
- };
1284
-
1285
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1286
- Object.keys(messages).forEach(function (locale) {
1287
- this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);
1288
- });
1289
- }
1290
-
1291
- this._initVM({
1292
- locale: locale,
1293
- fallbackLocale: fallbackLocale,
1294
- messages: messages,
1295
- dateTimeFormats: dateTimeFormats,
1296
- numberFormats: numberFormats
1297
- });
1298
- };
1299
-
1300
- var prototypeAccessors = { vm: { configurable: true },messages: { configurable: true },dateTimeFormats: { configurable: true },numberFormats: { configurable: true },availableLocales: { configurable: true },locale: { configurable: true },fallbackLocale: { configurable: true },formatFallbackMessages: { configurable: true },missing: { configurable: true },formatter: { configurable: true },silentTranslationWarn: { configurable: true },silentFallbackWarn: { configurable: true },preserveDirectiveContent: { configurable: true },warnHtmlInMessage: { configurable: true },postTranslation: { configurable: true },sync: { configurable: true } };
1301
-
1302
- VueI18n.prototype._checkLocaleMessage = function _checkLocaleMessage (locale, level, message) {
1303
- var paths = [];
1304
-
1305
- var fn = function (level, locale, message, paths) {
1306
- if (isPlainObject(message)) {
1307
- Object.keys(message).forEach(function (key) {
1308
- var val = message[key];
1309
- if (isPlainObject(val)) {
1310
- paths.push(key);
1311
- paths.push('.');
1312
- fn(level, locale, val, paths);
1313
- paths.pop();
1314
- paths.pop();
1315
- } else {
1316
- paths.push(key);
1317
- fn(level, locale, val, paths);
1318
- paths.pop();
1319
- }
1320
- });
1321
- } else if (isArray(message)) {
1322
- message.forEach(function (item, index) {
1323
- if (isPlainObject(item)) {
1324
- paths.push(("[" + index + "]"));
1325
- paths.push('.');
1326
- fn(level, locale, item, paths);
1327
- paths.pop();
1328
- paths.pop();
1329
- } else {
1330
- paths.push(("[" + index + "]"));
1331
- fn(level, locale, item, paths);
1332
- paths.pop();
1333
- }
1334
- });
1335
- } else if (isString(message)) {
1336
- var ret = htmlTagMatcher.test(message);
1337
- if (ret) {
1338
- var msg = "Detected HTML in message '" + message + "' of keypath '" + (paths.join('')) + "' at '" + locale + "'. Consider component interpolation with '<i18n>' to avoid XSS. See https://bit.ly/2ZqJzkp";
1339
- if (level === 'warn') {
1340
- warn(msg);
1341
- } else if (level === 'error') {
1342
- error(msg);
1343
- }
1344
- }
1345
- }
1346
- };
1347
-
1348
- fn(level, locale, message, paths);
1349
- };
1350
-
1351
- VueI18n.prototype._initVM = function _initVM (data) {
1352
- var silent = Vue.config.silent;
1353
- Vue.config.silent = true;
1354
- this._vm = new Vue({ data: data, __VUE18N__INSTANCE__: true });
1355
- Vue.config.silent = silent;
1356
- };
1357
-
1358
- VueI18n.prototype.destroyVM = function destroyVM () {
1359
- this._vm.$destroy();
1360
- };
1361
-
1362
- VueI18n.prototype.subscribeDataChanging = function subscribeDataChanging (vm) {
1363
- this._dataListeners.add(vm);
1364
- };
1365
-
1366
- VueI18n.prototype.unsubscribeDataChanging = function unsubscribeDataChanging (vm) {
1367
- remove(this._dataListeners, vm);
1368
- };
1369
-
1370
- VueI18n.prototype.watchI18nData = function watchI18nData () {
1371
- var this$1 = this;
1372
- return this._vm.$watch('$data', function () {
1373
- var listeners = arrayFrom(this$1._dataListeners);
1374
- var i = listeners.length;
1375
- while(i--) {
1376
- Vue.nextTick(function () {
1377
- listeners[i] && listeners[i].$forceUpdate();
1378
- });
1379
- }
1380
- }, { deep: true })
1381
- };
1382
-
1383
- VueI18n.prototype.watchLocale = function watchLocale (composer) {
1384
- if (!composer) {
1385
- /* istanbul ignore if */
1386
- if (!this._sync || !this._root) { return null }
1387
- var target = this._vm;
1388
- return this._root.$i18n.vm.$watch('locale', function (val) {
1389
- target.$set(target, 'locale', val);
1390
- target.$forceUpdate();
1391
- }, { immediate: true })
1392
- } else {
1393
- // deal with vue-i18n-bridge
1394
- if (!this.__VUE_I18N_BRIDGE__) { return null }
1395
- var self = this;
1396
- var target$1 = this._vm;
1397
- return this.vm.$watch('locale', function (val) {
1398
- target$1.$set(target$1, 'locale', val);
1399
- if (self.__VUE_I18N_BRIDGE__ && composer) {
1400
- composer.locale.value = val;
1401
- }
1402
- target$1.$forceUpdate();
1403
- }, { immediate: true })
1404
- }
1405
- };
1406
-
1407
- VueI18n.prototype.onComponentInstanceCreated = function onComponentInstanceCreated (newI18n) {
1408
- if (this._componentInstanceCreatedListener) {
1409
- this._componentInstanceCreatedListener(newI18n, this);
1410
- }
1411
- };
1412
-
1413
- prototypeAccessors.vm.get = function () { return this._vm };
1414
-
1415
- prototypeAccessors.messages.get = function () { return looseClone(this._getMessages()) };
1416
- prototypeAccessors.dateTimeFormats.get = function () { return looseClone(this._getDateTimeFormats()) };
1417
- prototypeAccessors.numberFormats.get = function () { return looseClone(this._getNumberFormats()) };
1418
- prototypeAccessors.availableLocales.get = function () { return Object.keys(this.messages).sort() };
1419
-
1420
- prototypeAccessors.locale.get = function () { return this._vm.locale };
1421
- prototypeAccessors.locale.set = function (locale) {
1422
- this._vm.$set(this._vm, 'locale', locale);
1423
- };
1424
-
1425
- prototypeAccessors.fallbackLocale.get = function () { return this._vm.fallbackLocale };
1426
- prototypeAccessors.fallbackLocale.set = function (locale) {
1427
- this._localeChainCache = {};
1428
- this._vm.$set(this._vm, 'fallbackLocale', locale);
1429
- };
1430
-
1431
- prototypeAccessors.formatFallbackMessages.get = function () { return this._formatFallbackMessages };
1432
- prototypeAccessors.formatFallbackMessages.set = function (fallback) { this._formatFallbackMessages = fallback; };
1433
-
1434
- prototypeAccessors.missing.get = function () { return this._missing };
1435
- prototypeAccessors.missing.set = function (handler) { this._missing = handler; };
1436
-
1437
- prototypeAccessors.formatter.get = function () { return this._formatter };
1438
- prototypeAccessors.formatter.set = function (formatter) { this._formatter = formatter; };
1439
-
1440
- prototypeAccessors.silentTranslationWarn.get = function () { return this._silentTranslationWarn };
1441
- prototypeAccessors.silentTranslationWarn.set = function (silent) { this._silentTranslationWarn = silent; };
1442
-
1443
- prototypeAccessors.silentFallbackWarn.get = function () { return this._silentFallbackWarn };
1444
- prototypeAccessors.silentFallbackWarn.set = function (silent) { this._silentFallbackWarn = silent; };
1445
-
1446
- prototypeAccessors.preserveDirectiveContent.get = function () { return this._preserveDirectiveContent };
1447
- prototypeAccessors.preserveDirectiveContent.set = function (preserve) { this._preserveDirectiveContent = preserve; };
1448
-
1449
- prototypeAccessors.warnHtmlInMessage.get = function () { return this._warnHtmlInMessage };
1450
- prototypeAccessors.warnHtmlInMessage.set = function (level) {
1451
- var this$1 = this;
1452
-
1453
- var orgLevel = this._warnHtmlInMessage;
1454
- this._warnHtmlInMessage = level;
1455
- if (orgLevel !== level && (level === 'warn' || level === 'error')) {
1456
- var messages = this._getMessages();
1457
- Object.keys(messages).forEach(function (locale) {
1458
- this$1._checkLocaleMessage(locale, this$1._warnHtmlInMessage, messages[locale]);
1459
- });
1460
- }
1461
- };
1462
-
1463
- prototypeAccessors.postTranslation.get = function () { return this._postTranslation };
1464
- prototypeAccessors.postTranslation.set = function (handler) { this._postTranslation = handler; };
1465
-
1466
- prototypeAccessors.sync.get = function () { return this._sync };
1467
- prototypeAccessors.sync.set = function (val) { this._sync = val; };
1468
-
1469
- VueI18n.prototype._getMessages = function _getMessages () { return this._vm.messages };
1470
- VueI18n.prototype._getDateTimeFormats = function _getDateTimeFormats () { return this._vm.dateTimeFormats };
1471
- VueI18n.prototype._getNumberFormats = function _getNumberFormats () { return this._vm.numberFormats };
1472
-
1473
- VueI18n.prototype._warnDefault = function _warnDefault (locale, key, result, vm, values, interpolateMode) {
1474
- if (!isNull(result)) { return result }
1475
- if (this._missing) {
1476
- var missingRet = this._missing.apply(null, [locale, key, vm, values]);
1477
- if (isString(missingRet)) {
1478
- return missingRet
1479
- }
1480
- } else {
1481
- if (false) {}
1482
- }
1483
-
1484
- if (this._formatFallbackMessages) {
1485
- var parsedArgs = parseArgs.apply(void 0, values);
1486
- return this._render(key, interpolateMode, parsedArgs.params, key)
1487
- } else {
1488
- return key
1489
- }
1490
- };
1491
-
1492
- VueI18n.prototype._isFallbackRoot = function _isFallbackRoot (val) {
1493
- return (this._fallbackRootWithEmptyString? !val : isNull(val)) && !isNull(this._root) && this._fallbackRoot
1494
- };
1495
-
1496
- VueI18n.prototype._isSilentFallbackWarn = function _isSilentFallbackWarn (key) {
1497
- return this._silentFallbackWarn instanceof RegExp
1498
- ? this._silentFallbackWarn.test(key)
1499
- : this._silentFallbackWarn
1500
- };
1501
-
1502
- VueI18n.prototype._isSilentFallback = function _isSilentFallback (locale, key) {
1503
- return this._isSilentFallbackWarn(key) && (this._isFallbackRoot() || locale !== this.fallbackLocale)
1504
- };
1505
-
1506
- VueI18n.prototype._isSilentTranslationWarn = function _isSilentTranslationWarn (key) {
1507
- return this._silentTranslationWarn instanceof RegExp
1508
- ? this._silentTranslationWarn.test(key)
1509
- : this._silentTranslationWarn
1510
- };
1511
-
1512
- VueI18n.prototype._interpolate = function _interpolate (
1513
- locale,
1514
- message,
1515
- key,
1516
- host,
1517
- interpolateMode,
1518
- values,
1519
- visitedLinkStack
1520
- ) {
1521
- if (!message) { return null }
1522
-
1523
- var pathRet = this._path.getPathValue(message, key);
1524
- if (isArray(pathRet) || isPlainObject(pathRet)) { return pathRet }
1525
-
1526
- var ret;
1527
- if (isNull(pathRet)) {
1528
- /* istanbul ignore else */
1529
- if (isPlainObject(message)) {
1530
- ret = message[key];
1531
- if (!(isString(ret) || isFunction(ret))) {
1532
- if (false) {}
1533
- return null
1534
- }
1535
- } else {
1536
- return null
1537
- }
1538
- } else {
1539
- /* istanbul ignore else */
1540
- if (isString(pathRet) || isFunction(pathRet)) {
1541
- ret = pathRet;
1542
- } else {
1543
- if (false) {}
1544
- return null
1545
- }
1546
- }
1547
-
1548
- // Check for the existence of links within the translated string
1549
- if (isString(ret) && (ret.indexOf('@:') >= 0 || ret.indexOf('@.') >= 0)) {
1550
- ret = this._link(locale, message, ret, host, 'raw', values, visitedLinkStack);
1551
- }
1552
-
1553
- return this._render(ret, interpolateMode, values, key)
1554
- };
1555
-
1556
- VueI18n.prototype._link = function _link (
1557
- locale,
1558
- message,
1559
- str,
1560
- host,
1561
- interpolateMode,
1562
- values,
1563
- visitedLinkStack
1564
- ) {
1565
- var ret = str;
1566
-
1567
- // Match all the links within the local
1568
- // We are going to replace each of
1569
- // them with its translation
1570
- var matches = ret.match(linkKeyMatcher);
1571
-
1572
- // eslint-disable-next-line no-autofix/prefer-const
1573
- for (var idx in matches) {
1574
- // ie compatible: filter custom array
1575
- // prototype method
1576
- if (!matches.hasOwnProperty(idx)) {
1577
- continue
1578
- }
1579
- var link = matches[idx];
1580
- var linkKeyPrefixMatches = link.match(linkKeyPrefixMatcher);
1581
- var linkPrefix = linkKeyPrefixMatches[0];
1582
- var formatterName = linkKeyPrefixMatches[1];
1583
-
1584
- // Remove the leading @:, @.case: and the brackets
1585
- var linkPlaceholder = link.replace(linkPrefix, '').replace(bracketsMatcher, '');
1586
-
1587
- if (includes(visitedLinkStack, linkPlaceholder)) {
1588
- if (false) {}
1589
- return ret
1590
- }
1591
- visitedLinkStack.push(linkPlaceholder);
1592
-
1593
- // Translate the link
1594
- var translated = this._interpolate(
1595
- locale, message, linkPlaceholder, host,
1596
- interpolateMode === 'raw' ? 'string' : interpolateMode,
1597
- interpolateMode === 'raw' ? undefined : values,
1598
- visitedLinkStack
1599
- );
1600
-
1601
- if (this._isFallbackRoot(translated)) {
1602
- if (false) {}
1603
- /* istanbul ignore if */
1604
- if (!this._root) { throw Error('unexpected error') }
1605
- var root = this._root.$i18n;
1606
- translated = root._translate(
1607
- root._getMessages(), root.locale, root.fallbackLocale,
1608
- linkPlaceholder, host, interpolateMode, values
1609
- );
1610
- }
1611
- translated = this._warnDefault(
1612
- locale, linkPlaceholder, translated, host,
1613
- isArray(values) ? values : [values],
1614
- interpolateMode
1615
- );
1616
-
1617
- if (this._modifiers.hasOwnProperty(formatterName)) {
1618
- translated = this._modifiers[formatterName](translated);
1619
- } else if (defaultModifiers.hasOwnProperty(formatterName)) {
1620
- translated = defaultModifiers[formatterName](translated);
1621
- }
1622
-
1623
- visitedLinkStack.pop();
1624
-
1625
- // Replace the link with the translated
1626
- ret = !translated ? ret : ret.replace(link, translated);
1627
- }
1628
-
1629
- return ret
1630
- };
1631
-
1632
- VueI18n.prototype._createMessageContext = function _createMessageContext (values, formatter, path, interpolateMode) {
1633
- var this$1 = this;
1634
-
1635
- var _list = isArray(values) ? values : [];
1636
- var _named = isObject(values) ? values : {};
1637
- var list = function (index) { return _list[index]; };
1638
- var named = function (key) { return _named[key]; };
1639
- var messages = this._getMessages();
1640
- var locale = this.locale;
1641
-
1642
- return {
1643
- list: list,
1644
- named: named,
1645
- values: values,
1646
- formatter: formatter,
1647
- path: path,
1648
- messages: messages,
1649
- locale: locale,
1650
- linked: function (linkedKey) { return this$1._interpolate(locale, messages[locale] || {}, linkedKey, null, interpolateMode, undefined, [linkedKey]); }
1651
- }
1652
- };
1653
-
1654
- VueI18n.prototype._render = function _render (message, interpolateMode, values, path) {
1655
- if (isFunction(message)) {
1656
- return message(
1657
- this._createMessageContext(values, this._formatter || defaultFormatter, path, interpolateMode)
1658
- )
1659
- }
1660
-
1661
- var ret = this._formatter.interpolate(message, values, path);
1662
-
1663
- // If the custom formatter refuses to work - apply the default one
1664
- if (!ret) {
1665
- ret = defaultFormatter.interpolate(message, values, path);
1666
- }
1667
-
1668
- // if interpolateMode is **not** 'string' ('row'),
1669
- // return the compiled data (e.g. ['foo', VNode, 'bar']) with formatter
1670
- return interpolateMode === 'string' && !isString(ret) ? ret.join('') : ret
1671
- };
1672
-
1673
- VueI18n.prototype._appendItemToChain = function _appendItemToChain (chain, item, blocks) {
1674
- var follow = false;
1675
- if (!includes(chain, item)) {
1676
- follow = true;
1677
- if (item) {
1678
- follow = item[item.length - 1] !== '!';
1679
- item = item.replace(/!/g, '');
1680
- chain.push(item);
1681
- if (blocks && blocks[item]) {
1682
- follow = blocks[item];
1683
- }
1684
- }
1685
- }
1686
- return follow
1687
- };
1688
-
1689
- VueI18n.prototype._appendLocaleToChain = function _appendLocaleToChain (chain, locale, blocks) {
1690
- var follow;
1691
- var tokens = locale.split('-');
1692
- do {
1693
- var item = tokens.join('-');
1694
- follow = this._appendItemToChain(chain, item, blocks);
1695
- tokens.splice(-1, 1);
1696
- } while (tokens.length && (follow === true))
1697
- return follow
1698
- };
1699
-
1700
- VueI18n.prototype._appendBlockToChain = function _appendBlockToChain (chain, block, blocks) {
1701
- var follow = true;
1702
- for (var i = 0; (i < block.length) && (isBoolean(follow)); i++) {
1703
- var locale = block[i];
1704
- if (isString(locale)) {
1705
- follow = this._appendLocaleToChain(chain, locale, blocks);
1706
- }
1707
- }
1708
- return follow
1709
- };
1710
-
1711
- VueI18n.prototype._getLocaleChain = function _getLocaleChain (start, fallbackLocale) {
1712
- if (start === '') { return [] }
1713
-
1714
- if (!this._localeChainCache) {
1715
- this._localeChainCache = {};
1716
- }
1717
-
1718
- var chain = this._localeChainCache[start];
1719
- if (!chain) {
1720
- if (!fallbackLocale) {
1721
- fallbackLocale = this.fallbackLocale;
1722
- }
1723
- chain = [];
1724
-
1725
- // first block defined by start
1726
- var block = [start];
1727
-
1728
- // while any intervening block found
1729
- while (isArray(block)) {
1730
- block = this._appendBlockToChain(
1731
- chain,
1732
- block,
1733
- fallbackLocale
1734
- );
1735
- }
1736
-
1737
- // last block defined by default
1738
- var defaults;
1739
- if (isArray(fallbackLocale)) {
1740
- defaults = fallbackLocale;
1741
- } else if (isObject(fallbackLocale)) {
1742
- /* $FlowFixMe */
1743
- if (fallbackLocale['default']) {
1744
- defaults = fallbackLocale['default'];
1745
- } else {
1746
- defaults = null;
1747
- }
1748
- } else {
1749
- defaults = fallbackLocale;
1750
- }
1751
-
1752
- // convert defaults to array
1753
- if (isString(defaults)) {
1754
- block = [defaults];
1755
- } else {
1756
- block = defaults;
1757
- }
1758
- if (block) {
1759
- this._appendBlockToChain(
1760
- chain,
1761
- block,
1762
- null
1763
- );
1764
- }
1765
- this._localeChainCache[start] = chain;
1766
- }
1767
- return chain
1768
- };
1769
-
1770
- VueI18n.prototype._translate = function _translate (
1771
- messages,
1772
- locale,
1773
- fallback,
1774
- key,
1775
- host,
1776
- interpolateMode,
1777
- args
1778
- ) {
1779
- var chain = this._getLocaleChain(locale, fallback);
1780
- var res;
1781
- for (var i = 0; i < chain.length; i++) {
1782
- var step = chain[i];
1783
- res =
1784
- this._interpolate(step, messages[step], key, host, interpolateMode, args, [key]);
1785
- if (!isNull(res)) {
1786
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
1787
- warn(("Fall back to translate the keypath '" + key + "' with '" + step + "' locale."));
1788
- }
1789
- return res
1790
- }
1791
- }
1792
- return null
1793
- };
1794
-
1795
- VueI18n.prototype._t = function _t (key, _locale, messages, host) {
1796
- var ref;
1797
-
1798
- var values = [], len = arguments.length - 4;
1799
- while ( len-- > 0 ) values[ len ] = arguments[ len + 4 ];
1800
- if (!key) { return '' }
1801
-
1802
- var parsedArgs = parseArgs.apply(void 0, values);
1803
- if(this._escapeParameterHtml) {
1804
- parsedArgs.params = escapeParams(parsedArgs.params);
1805
- }
1806
-
1807
- var locale = parsedArgs.locale || _locale;
1808
-
1809
- var ret = this._translate(
1810
- messages, locale, this.fallbackLocale, key,
1811
- host, 'string', parsedArgs.params
1812
- );
1813
- if (this._isFallbackRoot(ret)) {
1814
- if (false) {}
1815
- /* istanbul ignore if */
1816
- if (!this._root) { throw Error('unexpected error') }
1817
- return (ref = this._root).$t.apply(ref, [ key ].concat( values ))
1818
- } else {
1819
- ret = this._warnDefault(locale, key, ret, host, values, 'string');
1820
- if (this._postTranslation && ret !== null && ret !== undefined) {
1821
- ret = this._postTranslation(ret, key);
1822
- }
1823
- return ret
1824
- }
1825
- };
1826
-
1827
- VueI18n.prototype.t = function t (key) {
1828
- var ref;
1829
-
1830
- var values = [], len = arguments.length - 1;
1831
- while ( len-- > 0 ) values[ len ] = arguments[ len + 1 ];
1832
- return (ref = this)._t.apply(ref, [ key, this.locale, this._getMessages(), null ].concat( values ))
1833
- };
1834
-
1835
- VueI18n.prototype._i = function _i (key, locale, messages, host, values) {
1836
- var ret =
1837
- this._translate(messages, locale, this.fallbackLocale, key, host, 'raw', values);
1838
- if (this._isFallbackRoot(ret)) {
1839
- if (false) {}
1840
- if (!this._root) { throw Error('unexpected error') }
1841
- return this._root.$i18n.i(key, locale, values)
1842
- } else {
1843
- return this._warnDefault(locale, key, ret, host, [values], 'raw')
1844
- }
1845
- };
1846
-
1847
- VueI18n.prototype.i = function i (key, locale, values) {
1848
- /* istanbul ignore if */
1849
- if (!key) { return '' }
1850
-
1851
- if (!isString(locale)) {
1852
- locale = this.locale;
1853
- }
1854
-
1855
- return this._i(key, locale, this._getMessages(), null, values)
1856
- };
1857
-
1858
- VueI18n.prototype._tc = function _tc (
1859
- key,
1860
- _locale,
1861
- messages,
1862
- host,
1863
- choice
1864
- ) {
1865
- var ref;
1866
-
1867
- var values = [], len = arguments.length - 5;
1868
- while ( len-- > 0 ) values[ len ] = arguments[ len + 5 ];
1869
- if (!key) { return '' }
1870
- if (choice === undefined) {
1871
- choice = 1;
1872
- }
1873
-
1874
- var predefined = { 'count': choice, 'n': choice };
1875
- var parsedArgs = parseArgs.apply(void 0, values);
1876
- parsedArgs.params = Object.assign(predefined, parsedArgs.params);
1877
- values = parsedArgs.locale === null ? [parsedArgs.params] : [parsedArgs.locale, parsedArgs.params];
1878
- return this.fetchChoice((ref = this)._t.apply(ref, [ key, _locale, messages, host ].concat( values )), choice)
1879
- };
1880
-
1881
- VueI18n.prototype.fetchChoice = function fetchChoice (message, choice) {
1882
- /* istanbul ignore if */
1883
- if (!message || !isString(message)) { return null }
1884
- var choices = message.split('|');
1885
-
1886
- choice = this.getChoiceIndex(choice, choices.length);
1887
- if (!choices[choice]) { return message }
1888
- return choices[choice].trim()
1889
- };
1890
-
1891
- VueI18n.prototype.tc = function tc (key, choice) {
1892
- var ref;
1893
-
1894
- var values = [], len = arguments.length - 2;
1895
- while ( len-- > 0 ) values[ len ] = arguments[ len + 2 ];
1896
- return (ref = this)._tc.apply(ref, [ key, this.locale, this._getMessages(), null, choice ].concat( values ))
1897
- };
1898
-
1899
- VueI18n.prototype._te = function _te (key, locale, messages) {
1900
- var args = [], len = arguments.length - 3;
1901
- while ( len-- > 0 ) args[ len ] = arguments[ len + 3 ];
1902
-
1903
- var _locale = parseArgs.apply(void 0, args).locale || locale;
1904
- return this._exist(messages[_locale], key)
1905
- };
1906
-
1907
- VueI18n.prototype.te = function te (key, locale) {
1908
- return this._te(key, this.locale, this._getMessages(), locale)
1909
- };
1910
-
1911
- VueI18n.prototype.getLocaleMessage = function getLocaleMessage (locale) {
1912
- return looseClone(this._vm.messages[locale] || {})
1913
- };
1914
-
1915
- VueI18n.prototype.setLocaleMessage = function setLocaleMessage (locale, message) {
1916
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1917
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
1918
- }
1919
- this._vm.$set(this._vm.messages, locale, message);
1920
- };
1921
-
1922
- VueI18n.prototype.mergeLocaleMessage = function mergeLocaleMessage (locale, message) {
1923
- if (this._warnHtmlInMessage === 'warn' || this._warnHtmlInMessage === 'error') {
1924
- this._checkLocaleMessage(locale, this._warnHtmlInMessage, message);
1925
- }
1926
- this._vm.$set(this._vm.messages, locale, merge(
1927
- typeof this._vm.messages[locale] !== 'undefined' && Object.keys(this._vm.messages[locale]).length
1928
- ? Object.assign({}, this._vm.messages[locale])
1929
- : {},
1930
- message
1931
- ));
1932
- };
1933
-
1934
- VueI18n.prototype.getDateTimeFormat = function getDateTimeFormat (locale) {
1935
- return looseClone(this._vm.dateTimeFormats[locale] || {})
1936
- };
1937
-
1938
- VueI18n.prototype.setDateTimeFormat = function setDateTimeFormat (locale, format) {
1939
- this._vm.$set(this._vm.dateTimeFormats, locale, format);
1940
- this._clearDateTimeFormat(locale, format);
1941
- };
1942
-
1943
- VueI18n.prototype.mergeDateTimeFormat = function mergeDateTimeFormat (locale, format) {
1944
- this._vm.$set(this._vm.dateTimeFormats, locale, merge(this._vm.dateTimeFormats[locale] || {}, format));
1945
- this._clearDateTimeFormat(locale, format);
1946
- };
1947
-
1948
- VueI18n.prototype._clearDateTimeFormat = function _clearDateTimeFormat (locale, format) {
1949
- // eslint-disable-next-line no-autofix/prefer-const
1950
- for (var key in format) {
1951
- var id = locale + "__" + key;
1952
-
1953
- if (!this._dateTimeFormatters.hasOwnProperty(id)) {
1954
- continue
1955
- }
1956
-
1957
- delete this._dateTimeFormatters[id];
1958
- }
1959
- };
1960
-
1961
- VueI18n.prototype._localizeDateTime = function _localizeDateTime (
1962
- value,
1963
- locale,
1964
- fallback,
1965
- dateTimeFormats,
1966
- key,
1967
- options
1968
- ) {
1969
- var _locale = locale;
1970
- var formats = dateTimeFormats[_locale];
1971
-
1972
- var chain = this._getLocaleChain(locale, fallback);
1973
- for (var i = 0; i < chain.length; i++) {
1974
- var current = _locale;
1975
- var step = chain[i];
1976
- formats = dateTimeFormats[step];
1977
- _locale = step;
1978
- // fallback locale
1979
- if (isNull(formats) || isNull(formats[key])) {
1980
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
1981
- warn(("Fall back to '" + step + "' datetime formats from '" + current + "' datetime formats."));
1982
- }
1983
- } else {
1984
- break
1985
- }
1986
- }
1987
-
1988
- if (isNull(formats) || isNull(formats[key])) {
1989
- return null
1990
- } else {
1991
- var format = formats[key];
1992
-
1993
- var formatter;
1994
- if (options) {
1995
- formatter = new Intl.DateTimeFormat(_locale, Object.assign({}, format, options));
1996
- } else {
1997
- var id = _locale + "__" + key;
1998
- formatter = this._dateTimeFormatters[id];
1999
- if (!formatter) {
2000
- formatter = this._dateTimeFormatters[id] = new Intl.DateTimeFormat(_locale, format);
2001
- }
2002
- }
2003
-
2004
- return formatter.format(value)
2005
- }
2006
- };
2007
-
2008
- VueI18n.prototype._d = function _d (value, locale, key, options) {
2009
- /* istanbul ignore if */
2010
- if (false) {}
2011
-
2012
- if (!key) {
2013
- var dtf = !options ? new Intl.DateTimeFormat(locale) : new Intl.DateTimeFormat(locale, options);
2014
- return dtf.format(value)
2015
- }
2016
-
2017
- var ret =
2018
- this._localizeDateTime(value, locale, this.fallbackLocale, this._getDateTimeFormats(), key, options);
2019
- if (this._isFallbackRoot(ret)) {
2020
- if (false) {}
2021
- /* istanbul ignore if */
2022
- if (!this._root) { throw Error('unexpected error') }
2023
- return this._root.$i18n.d(value, key, locale)
2024
- } else {
2025
- return ret || ''
2026
- }
2027
- };
2028
-
2029
- VueI18n.prototype.d = function d (value) {
2030
- var args = [], len = arguments.length - 1;
2031
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2032
-
2033
- var locale = this.locale;
2034
- var key = null;
2035
- var options = null;
2036
-
2037
- if (args.length === 1) {
2038
- if (isString(args[0])) {
2039
- key = args[0];
2040
- } else if (isObject(args[0])) {
2041
- if (args[0].locale) {
2042
- locale = args[0].locale;
2043
- }
2044
- if (args[0].key) {
2045
- key = args[0].key;
2046
- }
2047
- }
2048
-
2049
- options = Object.keys(args[0]).reduce(function (acc, key) {
2050
- var obj;
2051
-
2052
- if (includes(dateTimeFormatKeys, key)) {
2053
- return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))
2054
- }
2055
- return acc
2056
- }, null);
2057
-
2058
- } else if (args.length === 2) {
2059
- if (isString(args[0])) {
2060
- key = args[0];
2061
- }
2062
- if (isString(args[1])) {
2063
- locale = args[1];
2064
- }
2065
- }
2066
-
2067
- return this._d(value, locale, key, options)
2068
- };
2069
-
2070
- VueI18n.prototype.getNumberFormat = function getNumberFormat (locale) {
2071
- return looseClone(this._vm.numberFormats[locale] || {})
2072
- };
2073
-
2074
- VueI18n.prototype.setNumberFormat = function setNumberFormat (locale, format) {
2075
- this._vm.$set(this._vm.numberFormats, locale, format);
2076
- this._clearNumberFormat(locale, format);
2077
- };
2078
-
2079
- VueI18n.prototype.mergeNumberFormat = function mergeNumberFormat (locale, format) {
2080
- this._vm.$set(this._vm.numberFormats, locale, merge(this._vm.numberFormats[locale] || {}, format));
2081
- this._clearNumberFormat(locale, format);
2082
- };
2083
-
2084
- VueI18n.prototype._clearNumberFormat = function _clearNumberFormat (locale, format) {
2085
- // eslint-disable-next-line no-autofix/prefer-const
2086
- for (var key in format) {
2087
- var id = locale + "__" + key;
2088
-
2089
- if (!this._numberFormatters.hasOwnProperty(id)) {
2090
- continue
2091
- }
2092
-
2093
- delete this._numberFormatters[id];
2094
- }
2095
- };
2096
-
2097
- VueI18n.prototype._getNumberFormatter = function _getNumberFormatter (
2098
- value,
2099
- locale,
2100
- fallback,
2101
- numberFormats,
2102
- key,
2103
- options
2104
- ) {
2105
- var _locale = locale;
2106
- var formats = numberFormats[_locale];
2107
-
2108
- var chain = this._getLocaleChain(locale, fallback);
2109
- for (var i = 0; i < chain.length; i++) {
2110
- var current = _locale;
2111
- var step = chain[i];
2112
- formats = numberFormats[step];
2113
- _locale = step;
2114
- // fallback locale
2115
- if (isNull(formats) || isNull(formats[key])) {
2116
- if (step !== locale && "production" !== 'production' && !this._isSilentTranslationWarn(key) && !this._isSilentFallbackWarn(key)) {
2117
- warn(("Fall back to '" + step + "' number formats from '" + current + "' number formats."));
2118
- }
2119
- } else {
2120
- break
2121
- }
2122
- }
2123
-
2124
- if (isNull(formats) || isNull(formats[key])) {
2125
- return null
2126
- } else {
2127
- var format = formats[key];
2128
-
2129
- var formatter;
2130
- if (options) {
2131
- // If options specified - create one time number formatter
2132
- formatter = new Intl.NumberFormat(_locale, Object.assign({}, format, options));
2133
- } else {
2134
- var id = _locale + "__" + key;
2135
- formatter = this._numberFormatters[id];
2136
- if (!formatter) {
2137
- formatter = this._numberFormatters[id] = new Intl.NumberFormat(_locale, format);
2138
- }
2139
- }
2140
- return formatter
2141
- }
2142
- };
2143
-
2144
- VueI18n.prototype._n = function _n (value, locale, key, options) {
2145
- /* istanbul ignore if */
2146
- if (!VueI18n.availabilities.numberFormat) {
2147
- if (false) {}
2148
- return ''
2149
- }
2150
-
2151
- if (!key) {
2152
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2153
- return nf.format(value)
2154
- }
2155
-
2156
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2157
- var ret = formatter && formatter.format(value);
2158
- if (this._isFallbackRoot(ret)) {
2159
- if (false) {}
2160
- /* istanbul ignore if */
2161
- if (!this._root) { throw Error('unexpected error') }
2162
- return this._root.$i18n.n(value, Object.assign({}, { key: key, locale: locale }, options))
2163
- } else {
2164
- return ret || ''
2165
- }
2166
- };
2167
-
2168
- VueI18n.prototype.n = function n (value) {
2169
- var args = [], len = arguments.length - 1;
2170
- while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2171
-
2172
- var locale = this.locale;
2173
- var key = null;
2174
- var options = null;
2175
-
2176
- if (args.length === 1) {
2177
- if (isString(args[0])) {
2178
- key = args[0];
2179
- } else if (isObject(args[0])) {
2180
- if (args[0].locale) {
2181
- locale = args[0].locale;
2182
- }
2183
- if (args[0].key) {
2184
- key = args[0].key;
2185
- }
2186
-
2187
- // Filter out number format options only
2188
- options = Object.keys(args[0]).reduce(function (acc, key) {
2189
- var obj;
2190
-
2191
- if (includes(numberFormatKeys, key)) {
2192
- return Object.assign({}, acc, ( obj = {}, obj[key] = args[0][key], obj ))
2193
- }
2194
- return acc
2195
- }, null);
2196
- }
2197
- } else if (args.length === 2) {
2198
- if (isString(args[0])) {
2199
- key = args[0];
2200
- }
2201
- if (isString(args[1])) {
2202
- locale = args[1];
2203
- }
2204
- }
2205
-
2206
- return this._n(value, locale, key, options)
2207
- };
2208
-
2209
- VueI18n.prototype._ntp = function _ntp (value, locale, key, options) {
2210
- /* istanbul ignore if */
2211
- if (!VueI18n.availabilities.numberFormat) {
2212
- if (false) {}
2213
- return []
2214
- }
2215
-
2216
- if (!key) {
2217
- var nf = !options ? new Intl.NumberFormat(locale) : new Intl.NumberFormat(locale, options);
2218
- return nf.formatToParts(value)
2219
- }
2220
-
2221
- var formatter = this._getNumberFormatter(value, locale, this.fallbackLocale, this._getNumberFormats(), key, options);
2222
- var ret = formatter && formatter.formatToParts(value);
2223
- if (this._isFallbackRoot(ret)) {
2224
- if (false) {}
2225
- /* istanbul ignore if */
2226
- if (!this._root) { throw Error('unexpected error') }
2227
- return this._root.$i18n._ntp(value, locale, key, options)
2228
- } else {
2229
- return ret || []
2230
- }
2231
- };
2232
-
2233
- Object.defineProperties( VueI18n.prototype, prototypeAccessors );
2234
-
2235
- var availabilities;
2236
- // $FlowFixMe
2237
- Object.defineProperty(VueI18n, 'availabilities', {
2238
- get: function get () {
2239
- if (!availabilities) {
2240
- var intlDefined = typeof Intl !== 'undefined';
2241
- availabilities = {
2242
- dateTimeFormat: intlDefined && typeof Intl.DateTimeFormat !== 'undefined',
2243
- numberFormat: intlDefined && typeof Intl.NumberFormat !== 'undefined'
2244
- };
2245
- }
2246
-
2247
- return availabilities
2248
- }
2249
- });
2250
-
2251
- VueI18n.install = install;
2252
- VueI18n.version = '8.28.2';
2253
-
2254
- /* harmony default export */ __webpack_exports__["a"] = (VueI18n);
2255
-
2256
-
2257
- /***/ })
2258
-
2259
- }]);