@kong-ui-public/i18n 0.5.1-pr.518.cd7bc6a.0 → 0.5.1-pr.533.64ab10c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/dist/i18n.es.js +77 -84
- package/dist/i18n.umd.js +10 -11
- package/dist/types/i18n.d.ts +9 -3
- package/dist/types/i18n.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/i18n.es.js.map +0 -1
- package/dist/i18n.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ In order to provide full autocompletion for the translation keys, you need to pa
|
|
|
37
37
|
import { createI18n, Translation } from '@kong-ui-public/i18n'
|
|
38
38
|
import english from './locales/en.json'
|
|
39
39
|
|
|
40
|
-
const i18n = createI18n<typeof english>('en-us', english, true)
|
|
40
|
+
const i18n = createI18n<typeof english>('en-us', english, {isGlobal: true})
|
|
41
41
|
app.use(Translation.install<typeof english>, { i18n })
|
|
42
42
|
|
|
43
43
|
// composables/index.ts
|
|
@@ -60,7 +60,7 @@ const i18n = composables.useI18n()
|
|
|
60
60
|
import { Translation, createI18n } from '@kong-ui-public/i18n'
|
|
61
61
|
import english from './locales/en.json'
|
|
62
62
|
|
|
63
|
-
const i18n = createI18n<typeof english>('en-us', english, true)
|
|
63
|
+
const i18n = createI18n<typeof english>('en-us', english, {isGlobal: true})
|
|
64
64
|
const app = createApp(App)
|
|
65
65
|
app.use(Translation.install<typeof english>, { i18n })
|
|
66
66
|
|
|
@@ -80,7 +80,7 @@ import english from './locales/en.json'
|
|
|
80
80
|
...
|
|
81
81
|
|
|
82
82
|
// this will create Application instance of Intl object
|
|
83
|
-
createI18n<typeof english>('en-us', english, true)
|
|
83
|
+
createI18n<typeof english>('en-us', english, {isGlobal: true})
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
|
|
@@ -100,30 +100,36 @@ const i18n = useI18n<typeof english>()
|
|
|
100
100
|
|
|
101
101
|
### Override config while create instance
|
|
102
102
|
|
|
103
|
-
For some applications there is a need to create Intl instance with config settings overridden.
|
|
103
|
+
For some applications there is a need to create Intl instance with config settings overridden. One example of this is when application needs to define error/warning handlers.
|
|
104
104
|
|
|
105
105
|
Example:
|
|
106
106
|
|
|
107
107
|
in `main.ts` (application hydration code):
|
|
108
108
|
|
|
109
109
|
```ts
|
|
110
|
-
import {
|
|
110
|
+
import { createI18n } from '@kong-ui-public/i18n'
|
|
111
|
+
import type { IntlConfigCore } from '@kong-ui-public/i18n'
|
|
112
|
+
|
|
111
113
|
import english from './locales/en.json'
|
|
112
114
|
|
|
113
115
|
...
|
|
114
116
|
|
|
115
117
|
// this will create Application instance of Intl object
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
118
|
+
createI18n<typeof english>(
|
|
119
|
+
'en-us',
|
|
120
|
+
english,
|
|
121
|
+
{
|
|
122
|
+
onError: (err) {
|
|
123
|
+
console.error(`this is my own i18n errorhandler ${err}`)
|
|
124
|
+
},
|
|
125
|
+
isGlobal: true
|
|
126
|
+
})
|
|
123
127
|
```
|
|
124
128
|
|
|
125
129
|
and then use i18n as described above.
|
|
126
130
|
|
|
131
|
+
Third parameter to `createI18n` could be simple boolean (for backwards compatibility), or [IntlConfig object without locale and messages](https://formatjs.io/docs/intl/#intlshape)
|
|
132
|
+
|
|
127
133
|
## Use in shared component
|
|
128
134
|
|
|
129
135
|
When used in [shared component](https://github.com/Kong/shared-ui-components/pull/118/files#diff-f296a0775f650cac9ecd4b5d7ccef015ca73587be833b40eeae1e396426b0f4fR45) (outside of application code), we need `Intl` that is local to that component, so that it is using component's own localization strings:
|
package/dist/i18n.es.js
CHANGED
|
@@ -41,10 +41,10 @@ function P(e, t, n) {
|
|
|
41
41
|
(a || !(r in t)) && (a || (a = Array.prototype.slice.call(t, 0, r)), a[r] = t[r]);
|
|
42
42
|
return e.concat(a || Array.prototype.slice.call(t));
|
|
43
43
|
}
|
|
44
|
-
var
|
|
44
|
+
var g;
|
|
45
45
|
(function(e) {
|
|
46
46
|
e[e.EXPECT_ARGUMENT_CLOSING_BRACE = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE", e[e.EMPTY_ARGUMENT = 2] = "EMPTY_ARGUMENT", e[e.MALFORMED_ARGUMENT = 3] = "MALFORMED_ARGUMENT", e[e.EXPECT_ARGUMENT_TYPE = 4] = "EXPECT_ARGUMENT_TYPE", e[e.INVALID_ARGUMENT_TYPE = 5] = "INVALID_ARGUMENT_TYPE", e[e.EXPECT_ARGUMENT_STYLE = 6] = "EXPECT_ARGUMENT_STYLE", e[e.INVALID_NUMBER_SKELETON = 7] = "INVALID_NUMBER_SKELETON", e[e.INVALID_DATE_TIME_SKELETON = 8] = "INVALID_DATE_TIME_SKELETON", e[e.EXPECT_NUMBER_SKELETON = 9] = "EXPECT_NUMBER_SKELETON", e[e.EXPECT_DATE_TIME_SKELETON = 10] = "EXPECT_DATE_TIME_SKELETON", e[e.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE", e[e.EXPECT_SELECT_ARGUMENT_OPTIONS = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS", e[e.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE", e[e.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE", e[e.EXPECT_SELECT_ARGUMENT_SELECTOR = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR", e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR", e[e.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT", e[e.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT", e[e.INVALID_PLURAL_ARGUMENT_SELECTOR = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR", e[e.DUPLICATE_PLURAL_ARGUMENT_SELECTOR = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR", e[e.DUPLICATE_SELECT_ARGUMENT_SELECTOR = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR", e[e.MISSING_OTHER_CLAUSE = 22] = "MISSING_OTHER_CLAUSE", e[e.INVALID_TAG = 23] = "INVALID_TAG", e[e.INVALID_TAG_NAME = 25] = "INVALID_TAG_NAME", e[e.UNMATCHED_CLOSING_TAG = 26] = "UNMATCHED_CLOSING_TAG", e[e.UNCLOSED_TAG = 27] = "UNCLOSED_TAG";
|
|
47
|
-
})(
|
|
47
|
+
})(g || (g = {}));
|
|
48
48
|
var d;
|
|
49
49
|
(function(e) {
|
|
50
50
|
e[e.literal = 0] = "literal", e[e.argument = 1] = "argument", e[e.number = 2] = "number", e[e.date = 3] = "date", e[e.time = 4] = "time", e[e.select = 5] = "select", e[e.plural = 6] = "plural", e[e.pound = 7] = "pound", e[e.tag = 8] = "tag";
|
|
@@ -330,13 +330,13 @@ function tt(e) {
|
|
|
330
330
|
case "integer-width":
|
|
331
331
|
if (i.options.length > 1)
|
|
332
332
|
throw new RangeError("integer-width stems only accept a single optional option");
|
|
333
|
-
i.options[0].replace(Ke, function(h, l, u, f, c,
|
|
333
|
+
i.options[0].replace(Ke, function(h, l, u, f, c, p) {
|
|
334
334
|
if (l)
|
|
335
335
|
t.minimumIntegerDigits = u.length;
|
|
336
336
|
else {
|
|
337
337
|
if (f && c)
|
|
338
338
|
throw new Error("We currently do not support maximum integer digits");
|
|
339
|
-
if (
|
|
339
|
+
if (p)
|
|
340
340
|
throw new Error("We currently do not support exact integer digits");
|
|
341
341
|
}
|
|
342
342
|
return "";
|
|
@@ -350,8 +350,8 @@ function tt(e) {
|
|
|
350
350
|
if (oe.test(i.stem)) {
|
|
351
351
|
if (i.options.length > 1)
|
|
352
352
|
throw new RangeError("Fraction-precision stems only accept a single optional option");
|
|
353
|
-
i.stem.replace(oe, function(h, l, u, f, c,
|
|
354
|
-
return u === "*" ? t.minimumFractionDigits = l.length : f && f[0] === "#" ? t.maximumFractionDigits = f.length : c &&
|
|
353
|
+
i.stem.replace(oe, function(h, l, u, f, c, p) {
|
|
354
|
+
return u === "*" ? t.minimumFractionDigits = l.length : f && f[0] === "#" ? t.maximumFractionDigits = f.length : c && p ? (t.minimumFractionDigits = c.length, t.maximumFractionDigits = c.length + p.length) : (t.minimumFractionDigits = l.length, t.maximumFractionDigits = l.length), "";
|
|
355
355
|
});
|
|
356
356
|
var a = i.options[0];
|
|
357
357
|
a === "w" ? t = m(m({}, t), { trailingZeroDisplay: "stripIfInteger" }) : a && (t = m(m({}, t), se(a)));
|
|
@@ -1877,7 +1877,7 @@ var bt = (
|
|
|
1877
1877
|
} else if (a === 60 && !this.ignoreTag && this.peek() === 47) {
|
|
1878
1878
|
if (r)
|
|
1879
1879
|
break;
|
|
1880
|
-
return this.error(
|
|
1880
|
+
return this.error(g.UNMATCHED_CLOSING_TAG, v(this.clonePosition(), this.clonePosition()));
|
|
1881
1881
|
} else if (a === 60 && !this.ignoreTag && K(this.peek() || 0)) {
|
|
1882
1882
|
var o = this.parseTag(t, n);
|
|
1883
1883
|
if (o.err)
|
|
@@ -1912,9 +1912,9 @@ var bt = (
|
|
|
1912
1912
|
var o = a.val, s = this.clonePosition();
|
|
1913
1913
|
if (this.bumpIf("</")) {
|
|
1914
1914
|
if (this.isEOF() || !K(this.char()))
|
|
1915
|
-
return this.error(
|
|
1915
|
+
return this.error(g.INVALID_TAG, v(s, this.clonePosition()));
|
|
1916
1916
|
var h = this.clonePosition(), l = this.parseTagName();
|
|
1917
|
-
return i !== l ? this.error(
|
|
1917
|
+
return i !== l ? this.error(g.UNMATCHED_CLOSING_TAG, v(h, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
|
|
1918
1918
|
val: {
|
|
1919
1919
|
type: d.tag,
|
|
1920
1920
|
value: i,
|
|
@@ -1922,11 +1922,11 @@ var bt = (
|
|
|
1922
1922
|
location: v(r, this.clonePosition())
|
|
1923
1923
|
},
|
|
1924
1924
|
err: null
|
|
1925
|
-
} : this.error(
|
|
1925
|
+
} : this.error(g.INVALID_TAG, v(s, this.clonePosition())));
|
|
1926
1926
|
} else
|
|
1927
|
-
return this.error(
|
|
1927
|
+
return this.error(g.UNCLOSED_TAG, v(r, this.clonePosition()));
|
|
1928
1928
|
} else
|
|
1929
|
-
return this.error(
|
|
1929
|
+
return this.error(g.INVALID_TAG, v(r, this.clonePosition()));
|
|
1930
1930
|
}, e.prototype.parseTagName = function() {
|
|
1931
1931
|
var t = this.offset();
|
|
1932
1932
|
for (this.bump(); !this.isEOF() && dt(this.char()); )
|
|
@@ -2001,14 +2001,14 @@ var bt = (
|
|
|
2001
2001
|
}, e.prototype.parseArgument = function(t, n) {
|
|
2002
2002
|
var r = this.clonePosition();
|
|
2003
2003
|
if (this.bump(), this.bumpSpace(), this.isEOF())
|
|
2004
|
-
return this.error(
|
|
2004
|
+
return this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition()));
|
|
2005
2005
|
if (this.char() === 125)
|
|
2006
|
-
return this.bump(), this.error(
|
|
2006
|
+
return this.bump(), this.error(g.EMPTY_ARGUMENT, v(r, this.clonePosition()));
|
|
2007
2007
|
var i = this.parseIdentifierIfPossible().value;
|
|
2008
2008
|
if (!i)
|
|
2009
|
-
return this.error(
|
|
2009
|
+
return this.error(g.MALFORMED_ARGUMENT, v(r, this.clonePosition()));
|
|
2010
2010
|
if (this.bumpSpace(), this.isEOF())
|
|
2011
|
-
return this.error(
|
|
2011
|
+
return this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition()));
|
|
2012
2012
|
switch (this.char()) {
|
|
2013
2013
|
case 125:
|
|
2014
2014
|
return this.bump(), {
|
|
@@ -2021,9 +2021,9 @@ var bt = (
|
|
|
2021
2021
|
err: null
|
|
2022
2022
|
};
|
|
2023
2023
|
case 44:
|
|
2024
|
-
return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(
|
|
2024
|
+
return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition())) : this.parseArgumentOptions(t, n, i, r);
|
|
2025
2025
|
default:
|
|
2026
|
-
return this.error(
|
|
2026
|
+
return this.error(g.MALFORMED_ARGUMENT, v(r, this.clonePosition()));
|
|
2027
2027
|
}
|
|
2028
2028
|
}, e.prototype.parseIdentifierIfPossible = function() {
|
|
2029
2029
|
var t = this.clonePosition(), n = this.offset(), r = $(this.message, n), i = n + r.length;
|
|
@@ -2034,7 +2034,7 @@ var bt = (
|
|
|
2034
2034
|
var a, o = this.clonePosition(), s = this.parseIdentifierIfPossible().value, h = this.clonePosition();
|
|
2035
2035
|
switch (s) {
|
|
2036
2036
|
case "":
|
|
2037
|
-
return this.error(
|
|
2037
|
+
return this.error(g.EXPECT_ARGUMENT_TYPE, v(o, h));
|
|
2038
2038
|
case "number":
|
|
2039
2039
|
case "date":
|
|
2040
2040
|
case "time": {
|
|
@@ -2047,9 +2047,9 @@ var bt = (
|
|
|
2047
2047
|
return f;
|
|
2048
2048
|
var c = vt(f.val);
|
|
2049
2049
|
if (c.length === 0)
|
|
2050
|
-
return this.error(
|
|
2051
|
-
var
|
|
2052
|
-
l = { style: c, styleLocation:
|
|
2050
|
+
return this.error(g.EXPECT_ARGUMENT_STYLE, v(this.clonePosition(), this.clonePosition()));
|
|
2051
|
+
var p = v(u, this.clonePosition());
|
|
2052
|
+
l = { style: c, styleLocation: p };
|
|
2053
2053
|
}
|
|
2054
2054
|
var b = this.tryParseArgumentClose(i);
|
|
2055
2055
|
if (b.err)
|
|
@@ -2065,7 +2065,7 @@ var bt = (
|
|
|
2065
2065
|
};
|
|
2066
2066
|
} else {
|
|
2067
2067
|
if (y.length === 0)
|
|
2068
|
-
return this.error(
|
|
2068
|
+
return this.error(g.EXPECT_DATE_TIME_SKELETON, E);
|
|
2069
2069
|
var x = y;
|
|
2070
2070
|
this.locale && (x = rt(y, this.locale));
|
|
2071
2071
|
var c = {
|
|
@@ -2095,14 +2095,14 @@ var bt = (
|
|
|
2095
2095
|
case "select": {
|
|
2096
2096
|
var T = this.clonePosition();
|
|
2097
2097
|
if (this.bumpSpace(), !this.bumpIf(","))
|
|
2098
|
-
return this.error(
|
|
2098
|
+
return this.error(g.EXPECT_SELECT_ARGUMENT_OPTIONS, v(T, m({}, T)));
|
|
2099
2099
|
this.bumpSpace();
|
|
2100
2100
|
var D = this.parseIdentifierIfPossible(), R = 0;
|
|
2101
2101
|
if (s !== "select" && D.value === "offset") {
|
|
2102
2102
|
if (!this.bumpIf(":"))
|
|
2103
|
-
return this.error(
|
|
2103
|
+
return this.error(g.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, v(this.clonePosition(), this.clonePosition()));
|
|
2104
2104
|
this.bumpSpace();
|
|
2105
|
-
var f = this.tryParseDecimalInteger(
|
|
2105
|
+
var f = this.tryParseDecimalInteger(g.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, g.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
|
|
2106
2106
|
if (f.err)
|
|
2107
2107
|
return f;
|
|
2108
2108
|
this.bumpSpace(), D = this.parseIdentifierIfPossible(), R = f.val;
|
|
@@ -2135,10 +2135,10 @@ var bt = (
|
|
|
2135
2135
|
};
|
|
2136
2136
|
}
|
|
2137
2137
|
default:
|
|
2138
|
-
return this.error(
|
|
2138
|
+
return this.error(g.INVALID_ARGUMENT_TYPE, v(o, h));
|
|
2139
2139
|
}
|
|
2140
2140
|
}, e.prototype.tryParseArgumentClose = function(t) {
|
|
2141
|
-
return this.isEOF() || this.char() !== 125 ? this.error(
|
|
2141
|
+
return this.isEOF() || this.char() !== 125 ? this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(t, this.clonePosition())) : (this.bump(), { val: !0, err: null });
|
|
2142
2142
|
}, e.prototype.parseSimpleArgStyleIfPossible = function() {
|
|
2143
2143
|
for (var t = 0, n = this.clonePosition(); !this.isEOF(); ) {
|
|
2144
2144
|
var r = this.char();
|
|
@@ -2147,7 +2147,7 @@ var bt = (
|
|
|
2147
2147
|
this.bump();
|
|
2148
2148
|
var i = this.clonePosition();
|
|
2149
2149
|
if (!this.bumpUntil("'"))
|
|
2150
|
-
return this.error(
|
|
2150
|
+
return this.error(g.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, v(i, this.clonePosition()));
|
|
2151
2151
|
this.bump();
|
|
2152
2152
|
break;
|
|
2153
2153
|
}
|
|
@@ -2179,7 +2179,7 @@ var bt = (
|
|
|
2179
2179
|
try {
|
|
2180
2180
|
r = Ye(t);
|
|
2181
2181
|
} catch {
|
|
2182
|
-
return this.error(
|
|
2182
|
+
return this.error(g.INVALID_NUMBER_SKELETON, n);
|
|
2183
2183
|
}
|
|
2184
2184
|
return {
|
|
2185
2185
|
val: {
|
|
@@ -2195,7 +2195,7 @@ var bt = (
|
|
|
2195
2195
|
if (l.length === 0) {
|
|
2196
2196
|
var f = this.clonePosition();
|
|
2197
2197
|
if (n !== "select" && this.bumpIf("=")) {
|
|
2198
|
-
var c = this.tryParseDecimalInteger(
|
|
2198
|
+
var c = this.tryParseDecimalInteger(g.EXPECT_PLURAL_ARGUMENT_SELECTOR, g.INVALID_PLURAL_ARGUMENT_SELECTOR);
|
|
2199
2199
|
if (c.err)
|
|
2200
2200
|
return c;
|
|
2201
2201
|
u = v(f, this.clonePosition()), l = this.message.slice(f.offset, this.offset());
|
|
@@ -2203,26 +2203,26 @@ var bt = (
|
|
|
2203
2203
|
break;
|
|
2204
2204
|
}
|
|
2205
2205
|
if (h.has(l))
|
|
2206
|
-
return this.error(n === "select" ?
|
|
2206
|
+
return this.error(n === "select" ? g.DUPLICATE_SELECT_ARGUMENT_SELECTOR : g.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, u);
|
|
2207
2207
|
l === "other" && (o = !0), this.bumpSpace();
|
|
2208
|
-
var
|
|
2208
|
+
var p = this.clonePosition();
|
|
2209
2209
|
if (!this.bumpIf("{"))
|
|
2210
|
-
return this.error(n === "select" ?
|
|
2210
|
+
return this.error(n === "select" ? g.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : g.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, v(this.clonePosition(), this.clonePosition()));
|
|
2211
2211
|
var b = this.parseMessage(t + 1, n, r);
|
|
2212
2212
|
if (b.err)
|
|
2213
2213
|
return b;
|
|
2214
|
-
var E = this.tryParseArgumentClose(
|
|
2214
|
+
var E = this.tryParseArgumentClose(p);
|
|
2215
2215
|
if (E.err)
|
|
2216
2216
|
return E;
|
|
2217
2217
|
s.push([
|
|
2218
2218
|
l,
|
|
2219
2219
|
{
|
|
2220
2220
|
value: b.val,
|
|
2221
|
-
location: v(
|
|
2221
|
+
location: v(p, this.clonePosition())
|
|
2222
2222
|
}
|
|
2223
2223
|
]), h.add(l), this.bumpSpace(), a = this.parseIdentifierIfPossible(), l = a.value, u = a.location;
|
|
2224
2224
|
}
|
|
2225
|
-
return s.length === 0 ? this.error(n === "select" ?
|
|
2225
|
+
return s.length === 0 ? this.error(n === "select" ? g.EXPECT_SELECT_ARGUMENT_SELECTOR : g.EXPECT_PLURAL_ARGUMENT_SELECTOR, v(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !o ? this.error(g.MISSING_OTHER_CLAUSE, v(this.clonePosition(), this.clonePosition())) : { val: s, err: null };
|
|
2226
2226
|
}, e.prototype.tryParseDecimalInteger = function(t, n) {
|
|
2227
2227
|
var r = 1, i = this.clonePosition();
|
|
2228
2228
|
this.bumpIf("+") || this.bumpIf("-") && (r = -1);
|
|
@@ -2328,7 +2328,7 @@ function xt(e, t) {
|
|
|
2328
2328
|
t === void 0 && (t = {}), t = m({ shouldParseSkeletons: !0, requiresOtherClause: !0 }, t);
|
|
2329
2329
|
var n = new bt(e, t).parse();
|
|
2330
2330
|
if (n.err) {
|
|
2331
|
-
var r = SyntaxError(
|
|
2331
|
+
var r = SyntaxError(g[n.err.kind]);
|
|
2332
2332
|
throw r.location = n.err.location, r.originalMessage = n.err.message, r;
|
|
2333
2333
|
}
|
|
2334
2334
|
return t != null && t.captureLocation || ee(n.val), n.val;
|
|
@@ -2475,26 +2475,26 @@ function k(e, t, n, r, i, a, o) {
|
|
|
2475
2475
|
continue;
|
|
2476
2476
|
}
|
|
2477
2477
|
if (de(u)) {
|
|
2478
|
-
var
|
|
2478
|
+
var p = typeof u.style == "string" ? r.date[u.style] : J(u.style) ? u.style.parsedOptions : void 0;
|
|
2479
2479
|
s.push({
|
|
2480
2480
|
type: S.literal,
|
|
2481
|
-
value: n.getDateTimeFormat(t,
|
|
2481
|
+
value: n.getDateTimeFormat(t, p).format(c)
|
|
2482
2482
|
});
|
|
2483
2483
|
continue;
|
|
2484
2484
|
}
|
|
2485
2485
|
if (ye(u)) {
|
|
2486
|
-
var
|
|
2486
|
+
var p = typeof u.style == "string" ? r.time[u.style] : J(u.style) ? u.style.parsedOptions : r.time.medium;
|
|
2487
2487
|
s.push({
|
|
2488
2488
|
type: S.literal,
|
|
2489
|
-
value: n.getDateTimeFormat(t,
|
|
2489
|
+
value: n.getDateTimeFormat(t, p).format(c)
|
|
2490
2490
|
});
|
|
2491
2491
|
continue;
|
|
2492
2492
|
}
|
|
2493
2493
|
if (Ee(u)) {
|
|
2494
|
-
var
|
|
2495
|
-
|
|
2494
|
+
var p = typeof u.style == "string" ? r.number[u.style] : Ie(u.style) ? u.style.parsedOptions : void 0;
|
|
2495
|
+
p && p.scale && (c = c * (p.scale || 1)), s.push({
|
|
2496
2496
|
type: S.literal,
|
|
2497
|
-
value: n.getNumberFormat(t,
|
|
2497
|
+
value: n.getNumberFormat(t, p).format(c)
|
|
2498
2498
|
});
|
|
2499
2499
|
continue;
|
|
2500
2500
|
}
|
|
@@ -2924,7 +2924,7 @@ function ge(e, t) {
|
|
|
2924
2924
|
return m(m(m({}, n), e), { date: pe(V(n.date, t), V(e.date || {}, t)), time: pe(V(n.time, t), V(e.time || {}, t)) });
|
|
2925
2925
|
}
|
|
2926
2926
|
var ve = function(e, t, n, r, i) {
|
|
2927
|
-
var a = e.locale, o = e.formats, s = e.messages, h = e.defaultLocale, l = e.defaultFormats, u = e.fallbackOnEmptyString, f = e.onError, c = e.timeZone,
|
|
2927
|
+
var a = e.locale, o = e.formats, s = e.messages, h = e.defaultLocale, l = e.defaultFormats, u = e.fallbackOnEmptyString, f = e.onError, c = e.timeZone, p = e.defaultRichTextElements;
|
|
2928
2928
|
n === void 0 && (n = { id: "" });
|
|
2929
2929
|
var b = n.id, E = n.defaultMessage;
|
|
2930
2930
|
Vt(!!b, "[@formatjs/intl] An `id` must be provided to format a message. You can either:\n1. Configure your build toolchain with [babel-plugin-formatjs](https://formatjs.io/docs/tooling/babel-plugin)\nor [@formatjs/ts-transformer](https://formatjs.io/docs/tooling/ts-transformer) OR\n2. Configure your `eslint` config to include [eslint-plugin-formatjs](https://formatjs.io/docs/tooling/linter#enforce-id)\nto autofix this issue");
|
|
@@ -2936,9 +2936,9 @@ var ve = function(e, t, n, r, i) {
|
|
|
2936
2936
|
);
|
|
2937
2937
|
if (Array.isArray(x) && x.length === 1 && x[0].type === d.literal)
|
|
2938
2938
|
return x[0].value;
|
|
2939
|
-
if (!r && x && typeof x == "string" && !
|
|
2939
|
+
if (!r && x && typeof x == "string" && !p)
|
|
2940
2940
|
return x.replace(/'\{(.*?)\}'/gi, "{$1}");
|
|
2941
|
-
if (r = m(m({},
|
|
2941
|
+
if (r = m(m({}, p), r || {}), o = ge(o, c), l = ge(l, c), !x) {
|
|
2942
2942
|
if (u === !1 && x === "")
|
|
2943
2943
|
return x;
|
|
2944
2944
|
if ((!E || a && a.toLowerCase() !== h.toLowerCase()) && f(new Dt(n, a)), E)
|
|
@@ -3228,7 +3228,7 @@ function F(e, t) {
|
|
|
3228
3228
|
const n = t.delimiter || ".", r = t.maxDepth, i = t.transformKey || Ue, a = {};
|
|
3229
3229
|
function o(s, h, l) {
|
|
3230
3230
|
l = l || 1, Object.keys(s).forEach(function(u) {
|
|
3231
|
-
const f = s[u], c = t.safe && Array.isArray(f),
|
|
3231
|
+
const f = s[u], c = t.safe && Array.isArray(f), p = Object.prototype.toString.call(f), b = Ge(f), E = p === "[object Object]" || p === "[object Array]", y = h ? h + n + i(u) : i(u);
|
|
3232
3232
|
if (!c && !b && E && Object.keys(f).length && (!t.maxDepth || l < r))
|
|
3233
3233
|
return o(f, y, l + 1);
|
|
3234
3234
|
a[y] = f;
|
|
@@ -3246,16 +3246,16 @@ function je(e, t) {
|
|
|
3246
3246
|
return isNaN(f) || u.indexOf(".") !== -1 || t.object ? u : f;
|
|
3247
3247
|
}
|
|
3248
3248
|
function h(u, f, c) {
|
|
3249
|
-
return Object.keys(c).reduce(function(
|
|
3250
|
-
return
|
|
3249
|
+
return Object.keys(c).reduce(function(p, b) {
|
|
3250
|
+
return p[u + n + b] = c[b], p;
|
|
3251
3251
|
}, f);
|
|
3252
3252
|
}
|
|
3253
3253
|
function l(u) {
|
|
3254
|
-
const f = Object.prototype.toString.call(u), c = f === "[object Array]",
|
|
3254
|
+
const f = Object.prototype.toString.call(u), c = f === "[object Array]", p = f === "[object Object]";
|
|
3255
3255
|
if (u) {
|
|
3256
3256
|
if (c)
|
|
3257
3257
|
return !u.length;
|
|
3258
|
-
if (
|
|
3258
|
+
if (p)
|
|
3259
3259
|
return !Object.keys(u).length;
|
|
3260
3260
|
} else
|
|
3261
3261
|
return !0;
|
|
@@ -3269,49 +3269,44 @@ function je(e, t) {
|
|
|
3269
3269
|
);
|
|
3270
3270
|
}, {}), Object.keys(e).forEach(function(u) {
|
|
3271
3271
|
const f = u.split(n).map(i);
|
|
3272
|
-
let c = s(f.shift()),
|
|
3273
|
-
for (;
|
|
3272
|
+
let c = s(f.shift()), p = s(f[0]), b = a;
|
|
3273
|
+
for (; p !== void 0; ) {
|
|
3274
3274
|
if (c === "__proto__")
|
|
3275
3275
|
return;
|
|
3276
3276
|
const E = Object.prototype.toString.call(b[c]), y = E === "[object Object]" || E === "[object Array]";
|
|
3277
3277
|
if (!r && !y && typeof b[c] < "u")
|
|
3278
3278
|
return;
|
|
3279
|
-
(r && !y || !r && b[c] == null) && (b[c] = typeof
|
|
3279
|
+
(r && !y || !r && b[c] == null) && (b[c] = typeof p == "number" && !t.object ? [] : {}), b = b[c], f.length > 0 && (c = s(f.shift()), p = s(f[0]));
|
|
3280
3280
|
}
|
|
3281
3281
|
b[c] = je(e[u], t);
|
|
3282
3282
|
}), a;
|
|
3283
3283
|
}
|
|
3284
3284
|
const fr = Ce();
|
|
3285
3285
|
let Ve;
|
|
3286
|
-
const
|
|
3287
|
-
const
|
|
3286
|
+
const pr = (e, t, n = !1) => {
|
|
3287
|
+
const r = hr(
|
|
3288
3288
|
{
|
|
3289
|
-
...
|
|
3290
|
-
|
|
3289
|
+
...typeof n == "boolean" ? null : n,
|
|
3290
|
+
locale: e,
|
|
3291
|
+
messages: lr.flatten(t, {
|
|
3291
3292
|
safe: !0
|
|
3292
3293
|
// Preserve arrays
|
|
3293
3294
|
})
|
|
3294
3295
|
},
|
|
3295
3296
|
fr
|
|
3296
|
-
), { $t:
|
|
3297
|
-
t: (
|
|
3298
|
-
te: (
|
|
3299
|
-
tm: (
|
|
3300
|
-
...
|
|
3301
|
-
source:
|
|
3297
|
+
), { $t: i, ...a } = r, o = a, u = {
|
|
3298
|
+
t: (f, c, p) => o.formatMessage({ id: f }, c, p),
|
|
3299
|
+
te: (f) => !!o.messages[f],
|
|
3300
|
+
tm: (f) => o.messages[f] || [],
|
|
3301
|
+
...o,
|
|
3302
|
+
source: t
|
|
3302
3303
|
};
|
|
3303
|
-
return
|
|
3304
|
-
}
|
|
3305
|
-
|
|
3306
|
-
locale: e,
|
|
3307
|
-
messages: t
|
|
3308
|
-
},
|
|
3309
|
-
n
|
|
3310
|
-
);
|
|
3311
|
-
function vr() {
|
|
3304
|
+
return (typeof n == "boolean" && n === !0 || typeof n != "boolean" && n.isGlobal === !0) && (Ve = u), u;
|
|
3305
|
+
};
|
|
3306
|
+
function gr() {
|
|
3312
3307
|
return Ve;
|
|
3313
3308
|
}
|
|
3314
|
-
const
|
|
3309
|
+
const cr = (e = null) => ke({
|
|
3315
3310
|
name: "I18nT",
|
|
3316
3311
|
props: {
|
|
3317
3312
|
i18n: {
|
|
@@ -3346,17 +3341,15 @@ const mr = (e = null) => ke({
|
|
|
3346
3341
|
}), Xe(t.tag, t, o);
|
|
3347
3342
|
};
|
|
3348
3343
|
}
|
|
3349
|
-
}),
|
|
3344
|
+
}), vr = {
|
|
3350
3345
|
install(e, t) {
|
|
3351
3346
|
const { i18n: n } = t;
|
|
3352
|
-
e.component("I18nT",
|
|
3347
|
+
e.component("I18nT", cr(n));
|
|
3353
3348
|
}
|
|
3354
3349
|
};
|
|
3355
3350
|
export {
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
cr as
|
|
3359
|
-
|
|
3360
|
-
vr as useI18n
|
|
3351
|
+
vr as Translation,
|
|
3352
|
+
pr as createI18n,
|
|
3353
|
+
cr as i18nTComponent,
|
|
3354
|
+
gr as useI18n
|
|
3361
3355
|
};
|
|
3362
|
-
//# sourceMappingURL=i18n.es.js.map
|