@kong-ui-public/i18n 0.5.0 → 0.5.1-pr.518.cd7bc6a.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 CHANGED
@@ -5,6 +5,7 @@
5
5
  - [Global Registration](#global-registration)
6
6
  - [Vue Plugin](#vue-plugin)
7
7
  - [Use in application](#use-in-application)
8
+ - [Override config while create instance](#override-config-while-create-instance)
8
9
  - [Use in shared component](#use-in-shared-component)
9
10
  - [Formatting messages](#formatting-messages)
10
11
  - [Where is my helpText?](#where-is-my-helptext)
@@ -82,6 +83,7 @@ import english from './locales/en.json'
82
83
  createI18n<typeof english>('en-us', english, true)
83
84
  ```
84
85
 
86
+
85
87
  And then, anywhere in application code where `i18n` is needed:
86
88
 
87
89
  ```html
@@ -96,6 +98,32 @@ const i18n = useI18n<typeof english>()
96
98
  </script>
97
99
  ```
98
100
 
101
+ ### Override config while create instance
102
+
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. In this case use `createI18nEx` function.
104
+
105
+ Example:
106
+
107
+ in `main.ts` (application hydration code):
108
+
109
+ ```ts
110
+ import { createI18nEx } from '@kong-ui-public/i18n'
111
+ import english from './locales/en.json'
112
+
113
+ ...
114
+
115
+ // this will create Application instance of Intl object
116
+ createI18nEx<typeof english>({
117
+ locale'en-us',
118
+ messages: english,
119
+ onError: (err) {
120
+ console.error(`this is my own i18n errorhandler ${err}`)
121
+ }
122
+ }, true)
123
+ ```
124
+
125
+ and then use i18n as described above.
126
+
99
127
  ## Use in shared component
100
128
 
101
129
  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 g;
44
+ var p;
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
- })(g || (g = {}));
47
+ })(p || (p = {}));
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, p) {
333
+ i.options[0].replace(Ke, function(h, l, u, f, c, g) {
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 (p)
339
+ if (g)
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, 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), "";
353
+ i.stem.replace(oe, function(h, l, u, f, c, g) {
354
+ return u === "*" ? t.minimumFractionDigits = l.length : f && f[0] === "#" ? t.maximumFractionDigits = f.length : c && g ? (t.minimumFractionDigits = c.length, t.maximumFractionDigits = c.length + g.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(g.UNMATCHED_CLOSING_TAG, v(this.clonePosition(), this.clonePosition()));
1880
+ return this.error(p.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(g.INVALID_TAG, v(s, this.clonePosition()));
1915
+ return this.error(p.INVALID_TAG, v(s, this.clonePosition()));
1916
1916
  var h = this.clonePosition(), l = this.parseTagName();
1917
- return i !== l ? this.error(g.UNMATCHED_CLOSING_TAG, v(h, this.clonePosition())) : (this.bumpSpace(), this.bumpIf(">") ? {
1917
+ return i !== l ? this.error(p.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(g.INVALID_TAG, v(s, this.clonePosition())));
1925
+ } : this.error(p.INVALID_TAG, v(s, this.clonePosition())));
1926
1926
  } else
1927
- return this.error(g.UNCLOSED_TAG, v(r, this.clonePosition()));
1927
+ return this.error(p.UNCLOSED_TAG, v(r, this.clonePosition()));
1928
1928
  } else
1929
- return this.error(g.INVALID_TAG, v(r, this.clonePosition()));
1929
+ return this.error(p.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(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition()));
2004
+ return this.error(p.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition()));
2005
2005
  if (this.char() === 125)
2006
- return this.bump(), this.error(g.EMPTY_ARGUMENT, v(r, this.clonePosition()));
2006
+ return this.bump(), this.error(p.EMPTY_ARGUMENT, v(r, this.clonePosition()));
2007
2007
  var i = this.parseIdentifierIfPossible().value;
2008
2008
  if (!i)
2009
- return this.error(g.MALFORMED_ARGUMENT, v(r, this.clonePosition()));
2009
+ return this.error(p.MALFORMED_ARGUMENT, v(r, this.clonePosition()));
2010
2010
  if (this.bumpSpace(), this.isEOF())
2011
- return this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition()));
2011
+ return this.error(p.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(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition())) : this.parseArgumentOptions(t, n, i, r);
2024
+ return this.bump(), this.bumpSpace(), this.isEOF() ? this.error(p.EXPECT_ARGUMENT_CLOSING_BRACE, v(r, this.clonePosition())) : this.parseArgumentOptions(t, n, i, r);
2025
2025
  default:
2026
- return this.error(g.MALFORMED_ARGUMENT, v(r, this.clonePosition()));
2026
+ return this.error(p.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(g.EXPECT_ARGUMENT_TYPE, v(o, h));
2037
+ return this.error(p.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(g.EXPECT_ARGUMENT_STYLE, v(this.clonePosition(), this.clonePosition()));
2051
- var p = v(u, this.clonePosition());
2052
- l = { style: c, styleLocation: p };
2050
+ return this.error(p.EXPECT_ARGUMENT_STYLE, v(this.clonePosition(), this.clonePosition()));
2051
+ var g = v(u, this.clonePosition());
2052
+ l = { style: c, styleLocation: g };
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(g.EXPECT_DATE_TIME_SKELETON, E);
2068
+ return this.error(p.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(g.EXPECT_SELECT_ARGUMENT_OPTIONS, v(T, m({}, T)));
2098
+ return this.error(p.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(g.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, v(this.clonePosition(), this.clonePosition()));
2103
+ return this.error(p.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, v(this.clonePosition(), this.clonePosition()));
2104
2104
  this.bumpSpace();
2105
- var f = this.tryParseDecimalInteger(g.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, g.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE);
2105
+ var f = this.tryParseDecimalInteger(p.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, p.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(g.INVALID_ARGUMENT_TYPE, v(o, h));
2138
+ return this.error(p.INVALID_ARGUMENT_TYPE, v(o, h));
2139
2139
  }
2140
2140
  }, e.prototype.tryParseArgumentClose = function(t) {
2141
- return this.isEOF() || this.char() !== 125 ? this.error(g.EXPECT_ARGUMENT_CLOSING_BRACE, v(t, this.clonePosition())) : (this.bump(), { val: !0, err: null });
2141
+ return this.isEOF() || this.char() !== 125 ? this.error(p.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(g.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, v(i, this.clonePosition()));
2150
+ return this.error(p.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(g.INVALID_NUMBER_SKELETON, n);
2182
+ return this.error(p.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(g.EXPECT_PLURAL_ARGUMENT_SELECTOR, g.INVALID_PLURAL_ARGUMENT_SELECTOR);
2198
+ var c = this.tryParseDecimalInteger(p.EXPECT_PLURAL_ARGUMENT_SELECTOR, p.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" ? g.DUPLICATE_SELECT_ARGUMENT_SELECTOR : g.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, u);
2206
+ return this.error(n === "select" ? p.DUPLICATE_SELECT_ARGUMENT_SELECTOR : p.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, u);
2207
2207
  l === "other" && (o = !0), this.bumpSpace();
2208
- var p = this.clonePosition();
2208
+ var g = this.clonePosition();
2209
2209
  if (!this.bumpIf("{"))
2210
- return this.error(n === "select" ? g.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : g.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, v(this.clonePosition(), this.clonePosition()));
2210
+ return this.error(n === "select" ? p.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT : p.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(p);
2214
+ var E = this.tryParseArgumentClose(g);
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(p, this.clonePosition())
2221
+ location: v(g, 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" ? 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 };
2225
+ return s.length === 0 ? this.error(n === "select" ? p.EXPECT_SELECT_ARGUMENT_SELECTOR : p.EXPECT_PLURAL_ARGUMENT_SELECTOR, v(this.clonePosition(), this.clonePosition())) : this.requiresOtherClause && !o ? this.error(p.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(g[n.err.kind]);
2331
+ var r = SyntaxError(p[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 p = typeof u.style == "string" ? r.date[u.style] : J(u.style) ? u.style.parsedOptions : void 0;
2478
+ var g = 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, p).format(c)
2481
+ value: n.getDateTimeFormat(t, g).format(c)
2482
2482
  });
2483
2483
  continue;
2484
2484
  }
2485
2485
  if (ye(u)) {
2486
- var p = typeof u.style == "string" ? r.time[u.style] : J(u.style) ? u.style.parsedOptions : r.time.medium;
2486
+ var g = 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, p).format(c)
2489
+ value: n.getDateTimeFormat(t, g).format(c)
2490
2490
  });
2491
2491
  continue;
2492
2492
  }
2493
2493
  if (Ee(u)) {
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({
2494
+ var g = typeof u.style == "string" ? r.number[u.style] : Ie(u.style) ? u.style.parsedOptions : void 0;
2495
+ g && g.scale && (c = c * (g.scale || 1)), s.push({
2496
2496
  type: S.literal,
2497
- value: n.getNumberFormat(t, p).format(c)
2497
+ value: n.getNumberFormat(t, g).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, p = e.defaultRichTextElements;
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, g = 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" && !p)
2939
+ if (!r && x && typeof x == "string" && !g)
2940
2940
  return x.replace(/'\{(.*?)\}'/gi, "{$1}");
2941
- if (r = m(m({}, p), r || {}), o = ge(o, c), l = ge(l, c), !x) {
2941
+ if (r = m(m({}, g), 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), p = Object.prototype.toString.call(f), b = Ge(f), E = p === "[object Object]" || p === "[object Array]", y = h ? h + n + i(u) : i(u);
3231
+ const f = s[u], c = t.safe && Array.isArray(f), g = Object.prototype.toString.call(f), b = Ge(f), E = g === "[object Object]" || g === "[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(p, b) {
3250
- return p[u + n + b] = c[b], p;
3249
+ return Object.keys(c).reduce(function(g, b) {
3250
+ return g[u + n + b] = c[b], g;
3251
3251
  }, f);
3252
3252
  }
3253
3253
  function l(u) {
3254
- const f = Object.prototype.toString.call(u), c = f === "[object Array]", p = f === "[object Object]";
3254
+ const f = Object.prototype.toString.call(u), c = f === "[object Array]", g = f === "[object Object]";
3255
3255
  if (u) {
3256
3256
  if (c)
3257
3257
  return !u.length;
3258
- if (p)
3258
+ if (g)
3259
3259
  return !Object.keys(u).length;
3260
3260
  } else
3261
3261
  return !0;
@@ -3269,43 +3269,49 @@ 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()), p = s(f[0]), b = a;
3273
- for (; p !== void 0; ) {
3272
+ let c = s(f.shift()), g = s(f[0]), b = a;
3273
+ for (; g !== 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 p == "number" && !t.object ? [] : {}), b = b[c], f.length > 0 && (c = s(f.shift()), p = s(f[0]));
3279
+ (r && !y || !r && b[c] == null) && (b[c] = typeof g == "number" && !t.object ? [] : {}), b = b[c], f.length > 0 && (c = s(f.shift()), g = 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 pr = (e, t, n = !1) => {
3287
- const r = hr(
3286
+ const cr = (e, t = !1) => {
3287
+ const n = hr(
3288
3288
  {
3289
- locale: e,
3290
- messages: lr.flatten(t, {
3289
+ ...e,
3290
+ messages: lr.flatten(e.messages, {
3291
3291
  safe: !0
3292
3292
  // Preserve arrays
3293
3293
  })
3294
3294
  },
3295
3295
  fr
3296
- ), { $t: i, ...a } = r, o = a, u = {
3297
- t: (f, c, p) => o.formatMessage({ id: f }, c, p),
3298
- te: (f) => !!o.messages[f],
3299
- tm: (f) => o.messages[f] || [],
3300
- ...o,
3301
- source: t
3296
+ ), { $t: r, ...i } = n, a = i, l = {
3297
+ t: (u, f, c) => a.formatMessage({ id: u }, f, c),
3298
+ te: (u) => !!a.messages[u],
3299
+ tm: (u) => a.messages[u] || [],
3300
+ ...a,
3301
+ source: e.messages
3302
3302
  };
3303
- return n && (Ve = u), u;
3304
- };
3305
- function gr() {
3303
+ return t && (Ve = l), l;
3304
+ }, gr = (e, t, n = !1) => cr(
3305
+ {
3306
+ locale: e,
3307
+ messages: t
3308
+ },
3309
+ n
3310
+ );
3311
+ function vr() {
3306
3312
  return Ve;
3307
3313
  }
3308
- const cr = (e = null) => ke({
3314
+ const mr = (e = null) => ke({
3309
3315
  name: "I18nT",
3310
3316
  props: {
3311
3317
  i18n: {
@@ -3340,16 +3346,17 @@ const cr = (e = null) => ke({
3340
3346
  }), Xe(t.tag, t, o);
3341
3347
  };
3342
3348
  }
3343
- }), vr = {
3349
+ }), br = {
3344
3350
  install(e, t) {
3345
3351
  const { i18n: n } = t;
3346
- e.component("I18nT", cr(n));
3352
+ e.component("I18nT", mr(n));
3347
3353
  }
3348
3354
  };
3349
3355
  export {
3350
- vr as Translation,
3351
- pr as createI18n,
3352
- cr as i18nTComponent,
3353
- gr as useI18n
3356
+ br as Translation,
3357
+ gr as createI18n,
3358
+ cr as createI18nEx,
3359
+ mr as i18nTComponent,
3360
+ vr as useI18n
3354
3361
  };
3355
3362
  //# sourceMappingURL=i18n.es.js.map