@internationalized/message 3.1.8 → 3.1.9

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 (26) hide show
  1. package/dist/{main.js → index.cjs} +5 -5
  2. package/dist/{main.js.map → index.cjs.map} +1 -1
  3. package/dist/{module.js → index.js} +4 -4
  4. package/dist/{module.js.map → index.js.map} +1 -1
  5. package/dist/{import.mjs → index.mjs} +4 -4
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/{MessageDictionary.main.js → private/MessageDictionary.cjs} +13 -13
  8. package/dist/private/MessageDictionary.cjs.map +1 -0
  9. package/dist/{MessageDictionary.module.js → private/MessageDictionary.js} +7 -7
  10. package/dist/{MessageDictionary.module.js.map → private/MessageDictionary.js.map} +1 -1
  11. package/dist/{MessageDictionary.mjs → private/MessageDictionary.mjs} +13 -13
  12. package/dist/private/MessageDictionary.mjs.map +1 -0
  13. package/dist/{MessageFormatter.main.js → private/MessageFormatter.cjs} +10 -10
  14. package/dist/private/MessageFormatter.cjs.map +1 -0
  15. package/dist/{MessageFormatter.module.js → private/MessageFormatter.js} +5 -5
  16. package/dist/{MessageFormatter.module.js.map → private/MessageFormatter.js.map} +1 -1
  17. package/dist/{MessageFormatter.mjs → private/MessageFormatter.mjs} +10 -10
  18. package/dist/private/MessageFormatter.mjs.map +1 -0
  19. package/dist/types/src/MessageDictionary.d.ts +15 -0
  20. package/dist/types/src/MessageFormatter.d.ts +12 -0
  21. package/dist/types/src/index.d.ts +3 -0
  22. package/package.json +26 -11
  23. package/dist/MessageDictionary.main.js.map +0 -1
  24. package/dist/MessageFormatter.main.js.map +0 -1
  25. package/dist/types.d.ts +0 -23
  26. package/dist/types.d.ts.map +0 -1
@@ -1,13 +1,13 @@
1
- var $9a5a7b8408290694$exports = require("./MessageDictionary.main.js");
2
- var $7a31ee9993c13f0b$exports = require("./MessageFormatter.main.js");
1
+ var $8862a42b4614f9a7$exports = require("./private/MessageDictionary.cjs");
2
+ var $2d21f5a7e66832cf$exports = require("./private/MessageFormatter.cjs");
3
3
 
4
4
 
5
5
  function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
- $parcel$export(module.exports, "MessageDictionary", () => $9a5a7b8408290694$exports.MessageDictionary);
10
- $parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$exports.MessageFormatter);
9
+ $parcel$export(module.exports, "MessageDictionary", function () { return $8862a42b4614f9a7$exports.MessageDictionary; });
10
+ $parcel$export(module.exports, "MessageFormatter", function () { return $2d21f5a7e66832cf$exports.MessageFormatter; });
11
11
  /*
12
12
  * Copyright 2020 Adobe. All rights reserved.
13
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -22,4 +22,4 @@ $parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$expor
22
22
 
23
23
 
24
24
 
25
- //# sourceMappingURL=main.js.map
25
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/message/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/message/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"index.cjs.map"}
@@ -1,5 +1,5 @@
1
- import {MessageDictionary as $d6fd23bc337660df$export$64839e615120df17} from "./MessageDictionary.module.js";
2
- import {MessageFormatter as $972eb555d604f491$export$526ebc05ff964723} from "./MessageFormatter.module.js";
1
+ import {MessageDictionary as $04b807f024b36740$export$64839e615120df17} from "./private/MessageDictionary.js";
2
+ import {MessageFormatter as $6c4b92c606f6c9ec$export$526ebc05ff964723} from "./private/MessageFormatter.js";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {MessageFormatter as $972eb555d604f491$export$526ebc05ff964723} from "./M
15
15
 
16
16
 
17
17
 
18
- export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary, $972eb555d604f491$export$526ebc05ff964723 as MessageFormatter};
19
- //# sourceMappingURL=module.js.map
18
+ export {$04b807f024b36740$export$64839e615120df17 as MessageDictionary, $6c4b92c606f6c9ec$export$526ebc05ff964723 as MessageFormatter};
19
+ //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/message/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/message/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"index.js.map"}
@@ -1,5 +1,5 @@
1
- import {MessageDictionary as $d6fd23bc337660df$export$64839e615120df17} from "./MessageDictionary.mjs";
2
- import {MessageFormatter as $972eb555d604f491$export$526ebc05ff964723} from "./MessageFormatter.mjs";
1
+ import {MessageDictionary as $87b7f54626b6e2f0$export$64839e615120df17} from "./private/MessageDictionary.mjs";
2
+ import {MessageFormatter as $53ce84155a688a77$export$526ebc05ff964723} from "./private/MessageFormatter.mjs";
3
3
 
4
4
  /*
5
5
  * Copyright 2020 Adobe. All rights reserved.
@@ -15,5 +15,5 @@ import {MessageFormatter as $972eb555d604f491$export$526ebc05ff964723} from "./M
15
15
 
16
16
 
17
17
 
18
- export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary, $972eb555d604f491$export$526ebc05ff964723 as MessageFormatter};
19
- //# sourceMappingURL=module.js.map
18
+ export {$87b7f54626b6e2f0$export$64839e615120df17 as MessageDictionary, $53ce84155a688a77$export$526ebc05ff964723 as MessageFormatter};
19
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC","sources":["packages/@internationalized/message/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"index.mjs.map"}
@@ -3,7 +3,7 @@ function $parcel$export(e, n, v, s) {
3
3
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
4
4
  }
5
5
 
6
- $parcel$export(module.exports, "MessageDictionary", () => $9a5a7b8408290694$export$64839e615120df17);
6
+ $parcel$export(module.exports, "MessageDictionary", function () { return $8862a42b4614f9a7$export$64839e615120df17; });
7
7
  /*
8
8
  * Copyright 2020 Adobe. All rights reserved.
9
9
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -14,25 +14,25 @@ $parcel$export(module.exports, "MessageDictionary", () => $9a5a7b8408290694$expo
14
14
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
15
  * OF ANY KIND, either express or implied. See the License for the specific language
16
16
  * governing permissions and limitations under the License.
17
- */ class $9a5a7b8408290694$export$64839e615120df17 {
17
+ */ class $8862a42b4614f9a7$export$64839e615120df17 {
18
+ constructor(messages, defaultLocale = 'en-US'){
19
+ // Clone messages so we don't modify the original object.
20
+ // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
21
+ this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
22
+ this.defaultLocale = defaultLocale;
23
+ }
18
24
  getStringForLocale(key, locale) {
19
25
  let strings = this.messages[locale];
20
26
  if (!strings) {
21
- strings = $9a5a7b8408290694$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
27
+ strings = $8862a42b4614f9a7$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
22
28
  this.messages[locale] = strings;
23
29
  }
24
30
  let string = strings[key];
25
31
  if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
26
32
  return string;
27
33
  }
28
- constructor(messages, defaultLocale = 'en-US'){
29
- // Clone messages so we don't modify the original object.
30
- // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
31
- this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
32
- this.defaultLocale = defaultLocale;
33
- }
34
34
  }
35
- function $9a5a7b8408290694$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
35
+ function $8862a42b4614f9a7$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
36
36
  // If there is an exact match, use it.
37
37
  if (strings[locale]) return strings[locale];
38
38
  // Attempt to find the closest match by language.
@@ -40,7 +40,7 @@ function $9a5a7b8408290694$var$getStringsForLocale(locale, strings, defaultLocal
40
40
  // an fr-FR (France) set of strings, use that.
41
41
  // This could be replaced with Intl.LocaleMatcher once it is supported.
42
42
  // https://github.com/tc39/proposal-intl-localematcher
43
- let language = $9a5a7b8408290694$var$getLanguage(locale);
43
+ let language = $8862a42b4614f9a7$var$getLanguage(locale);
44
44
  if (strings[language]) return strings[language];
45
45
  for(let key in strings){
46
46
  if (key.startsWith(language + '-')) return strings[key];
@@ -48,10 +48,10 @@ function $9a5a7b8408290694$var$getStringsForLocale(locale, strings, defaultLocal
48
48
  // Nothing close, use english.
49
49
  return strings[defaultLocale];
50
50
  }
51
- function $9a5a7b8408290694$var$getLanguage(locale) {
51
+ function $8862a42b4614f9a7$var$getLanguage(locale) {
52
52
  if (Intl.Locale) return new Intl.Locale(locale).language;
53
53
  return locale.split('-')[0];
54
54
  }
55
55
 
56
56
 
57
- //# sourceMappingURL=MessageDictionary.main.js.map
57
+ //# sourceMappingURL=MessageDictionary.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IAIX,YAAY,QAA0B,EAAE,gBAAwB,OAAO,CAAE;QACvE,yDAAyD;QACzD,uGAAuG;QACvG,IAAI,CAAC,QAAQ,GAAG,OAAO,WAAW,CAChC,OAAO,OAAO,CAAC,UAAU,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK;QAE7C,IAAI,CAAC,aAAa,GAAG;IACvB;IAEA,mBAAmB,GAAW,EAAE,MAAc,EAAU;QACtD,IAAI,UAAU,IAAI,CAAC,QAAQ,CAAC,OAAO;QACnC,IAAI,CAAC,SAAS;YACZ,UAAU,0CAAoB,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa;YACvE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG;QAC1B;QAEA,IAAI,SAAS,OAAO,CAAC,IAAI;QACzB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO,CAAC;QAG1E,OAAO;IACT;AACF;AAEA,SAAS,0CAAoB,MAAc,EAAE,OAAyB,EAAE,gBAAgB,OAAO;IAC7F,sCAAsC;IACtC,IAAI,OAAO,CAAC,OAAO,EACjB,OAAO,OAAO,CAAC,OAAO;IAGxB,iDAAiD;IACjD,2EAA2E;IAC3E,8CAA8C;IAC9C,uEAAuE;IACvE,sDAAsD;IACtD,IAAI,WAAW,kCAAY;IAC3B,IAAI,OAAO,CAAC,SAAS,EACnB,OAAO,OAAO,CAAC,SAAS;IAG1B,IAAK,IAAI,OAAO,QAAS;QACvB,IAAI,IAAI,UAAU,CAAC,WAAW,MAC5B,OAAO,OAAO,CAAC,IAAI;IAEvB;IAEA,8BAA8B;IAC9B,OAAO,OAAO,CAAC,cAAc;AAC/B;AAEA,SAAS,kCAAY,MAAc;IACjC,IAAI,KAAK,MAAM,EACb,OAAO,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ;IAGzC,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7B","sources":["packages/@internationalized/message/src/MessageDictionary.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type LocalizedStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\n/**\n * Stores a mapping of localized strings. Can be used to find the\n * closest available string for a given locale.\n */\nexport class MessageDictionary {\n private messages: LocalizedStrings;\n private defaultLocale: string;\n\n constructor(messages: LocalizedStrings, defaultLocale: string = 'en-US') {\n // Clone messages so we don't modify the original object.\n // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.\n this.messages = Object.fromEntries(\n Object.entries(messages).filter(([, v]) => v)\n );\n this.defaultLocale = defaultLocale;\n }\n\n getStringForLocale(key: string, locale: string): string {\n let strings = this.messages[locale];\n if (!strings) {\n strings = getStringsForLocale(locale, this.messages, this.defaultLocale);\n this.messages[locale] = strings;\n }\n\n let string = strings[key];\n if (!string) {\n throw new Error(`Could not find intl message ${key} in ${locale} locale`);\n }\n\n return string;\n }\n}\n\nfunction getStringsForLocale(locale: string, strings: LocalizedStrings, defaultLocale = 'en-US') {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n // This could be replaced with Intl.LocaleMatcher once it is supported.\n // https://github.com/tc39/proposal-intl-localematcher\n let language = getLanguage(locale);\n if (strings[language]) {\n return strings[language];\n }\n\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings[defaultLocale];\n}\n\nfunction getLanguage(locale: string) {\n if (Intl.Locale) {\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\n}\n"],"names":[],"version":3,"file":"MessageDictionary.cjs.map"}
@@ -8,11 +8,11 @@
8
8
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
- */ class $d6fd23bc337660df$export$64839e615120df17 {
11
+ */ class $04b807f024b36740$export$64839e615120df17 {
12
12
  getStringForLocale(key, locale) {
13
13
  let strings = this.messages[locale];
14
14
  if (!strings) {
15
- strings = $d6fd23bc337660df$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
15
+ strings = $04b807f024b36740$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
16
16
  this.messages[locale] = strings;
17
17
  }
18
18
  let string = strings[key];
@@ -26,7 +26,7 @@
26
26
  this.defaultLocale = defaultLocale;
27
27
  }
28
28
  }
29
- function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
29
+ function $04b807f024b36740$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
30
30
  // If there is an exact match, use it.
31
31
  if (strings[locale]) return strings[locale];
32
32
  // Attempt to find the closest match by language.
@@ -34,7 +34,7 @@ function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocal
34
34
  // an fr-FR (France) set of strings, use that.
35
35
  // This could be replaced with Intl.LocaleMatcher once it is supported.
36
36
  // https://github.com/tc39/proposal-intl-localematcher
37
- let language = $d6fd23bc337660df$var$getLanguage(locale);
37
+ let language = $04b807f024b36740$var$getLanguage(locale);
38
38
  if (strings[language]) return strings[language];
39
39
  for(let key in strings){
40
40
  if (key.startsWith(language + '-')) return strings[key];
@@ -42,11 +42,11 @@ function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocal
42
42
  // Nothing close, use english.
43
43
  return strings[defaultLocale];
44
44
  }
45
- function $d6fd23bc337660df$var$getLanguage(locale) {
45
+ function $04b807f024b36740$var$getLanguage(locale) {
46
46
  if (Intl.Locale) return new Intl.Locale(locale).language;
47
47
  return locale.split('-')[0];
48
48
  }
49
49
 
50
50
 
51
- export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary};
52
- //# sourceMappingURL=MessageDictionary.module.js.map
51
+ export {$04b807f024b36740$export$64839e615120df17 as MessageDictionary};
52
+ //# sourceMappingURL=MessageDictionary.js.map
@@ -1 +1 @@
1
- {"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IAaX,mBAAmB,GAAW,EAAE,MAAc,EAAU;QACtD,IAAI,UAAU,IAAI,CAAC,QAAQ,CAAC,OAAO;QACnC,IAAI,CAAC,SAAS;YACZ,UAAU,0CAAoB,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa;YACvE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG;QAC1B;QAEA,IAAI,SAAS,OAAO,CAAC,IAAI;QACzB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO,CAAC;QAG1E,OAAO;IACT;IAtBA,YAAY,QAA0B,EAAE,gBAAwB,OAAO,CAAE;QACvE,yDAAyD;QACzD,uGAAuG;QACvG,IAAI,CAAC,QAAQ,GAAG,OAAO,WAAW,CAChC,OAAO,OAAO,CAAC,UAAU,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK;QAE7C,IAAI,CAAC,aAAa,GAAG;IACvB;AAgBF;AAEA,SAAS,0CAAoB,MAAc,EAAE,OAAyB,EAAE,gBAAgB,OAAO;IAC7F,sCAAsC;IACtC,IAAI,OAAO,CAAC,OAAO,EACjB,OAAO,OAAO,CAAC,OAAO;IAGxB,iDAAiD;IACjD,2EAA2E;IAC3E,8CAA8C;IAC9C,uEAAuE;IACvE,sDAAsD;IACtD,IAAI,WAAW,kCAAY;IAC3B,IAAI,OAAO,CAAC,SAAS,EACnB,OAAO,OAAO,CAAC,SAAS;IAG1B,IAAK,IAAI,OAAO,QAAS;QACvB,IAAI,IAAI,UAAU,CAAC,WAAW,MAC5B,OAAO,OAAO,CAAC,IAAI;IAEvB;IAEA,8BAA8B;IAC9B,OAAO,OAAO,CAAC,cAAc;AAC/B;AAEA,SAAS,kCAAY,MAAc;IACjC,IAAI,KAAK,MAAM,EACb,OAAO,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ;IAGzC,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7B","sources":["packages/@internationalized/message/src/MessageDictionary.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type LocalizedStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\n/**\n * Stores a mapping of localized strings. Can be used to find the\n * closest available string for a given locale.\n */\nexport class MessageDictionary {\n private messages: LocalizedStrings;\n private defaultLocale: string;\n\n constructor(messages: LocalizedStrings, defaultLocale: string = 'en-US') {\n // Clone messages so we don't modify the original object.\n // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.\n this.messages = Object.fromEntries(\n Object.entries(messages).filter(([, v]) => v)\n );\n this.defaultLocale = defaultLocale;\n }\n\n getStringForLocale(key: string, locale: string): string {\n let strings = this.messages[locale];\n if (!strings) {\n strings = getStringsForLocale(locale, this.messages, this.defaultLocale);\n this.messages[locale] = strings;\n }\n\n let string = strings[key];\n if (!string) {\n throw new Error(`Could not find intl message ${key} in ${locale} locale`);\n }\n\n return string;\n }\n}\n\nfunction getStringsForLocale(locale: string, strings: LocalizedStrings, defaultLocale = 'en-US') {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n // This could be replaced with Intl.LocaleMatcher once it is supported.\n // https://github.com/tc39/proposal-intl-localematcher\n let language = getLanguage(locale);\n if (strings[language]) {\n return strings[language];\n }\n\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings[defaultLocale];\n}\n\nfunction getLanguage(locale: string) {\n if (Intl.Locale) {\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\n}\n"],"names":[],"version":3,"file":"MessageDictionary.module.js.map"}
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IAaX,mBAAmB,GAAW,EAAE,MAAc,EAAU;QACtD,IAAI,UAAU,IAAI,CAAC,QAAQ,CAAC,OAAO;QACnC,IAAI,CAAC,SAAS;YACZ,UAAU,0CAAoB,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa;YACvE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG;QAC1B;QAEA,IAAI,SAAS,OAAO,CAAC,IAAI;QACzB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO,CAAC;QAG1E,OAAO;IACT;IAtBA,YAAY,QAA0B,EAAE,gBAAwB,OAAO,CAAE;QACvE,yDAAyD;QACzD,uGAAuG;QACvG,IAAI,CAAC,QAAQ,GAAG,OAAO,WAAW,CAChC,OAAO,OAAO,CAAC,UAAU,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK;QAE7C,IAAI,CAAC,aAAa,GAAG;IACvB;AAgBF;AAEA,SAAS,0CAAoB,MAAc,EAAE,OAAyB,EAAE,gBAAgB,OAAO;IAC7F,sCAAsC;IACtC,IAAI,OAAO,CAAC,OAAO,EACjB,OAAO,OAAO,CAAC,OAAO;IAGxB,iDAAiD;IACjD,2EAA2E;IAC3E,8CAA8C;IAC9C,uEAAuE;IACvE,sDAAsD;IACtD,IAAI,WAAW,kCAAY;IAC3B,IAAI,OAAO,CAAC,SAAS,EACnB,OAAO,OAAO,CAAC,SAAS;IAG1B,IAAK,IAAI,OAAO,QAAS;QACvB,IAAI,IAAI,UAAU,CAAC,WAAW,MAC5B,OAAO,OAAO,CAAC,IAAI;IAEvB;IAEA,8BAA8B;IAC9B,OAAO,OAAO,CAAC,cAAc;AAC/B;AAEA,SAAS,kCAAY,MAAc;IACjC,IAAI,KAAK,MAAM,EACb,OAAO,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ;IAGzC,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7B","sources":["packages/@internationalized/message/src/MessageDictionary.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type LocalizedStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\n/**\n * Stores a mapping of localized strings. Can be used to find the\n * closest available string for a given locale.\n */\nexport class MessageDictionary {\n private messages: LocalizedStrings;\n private defaultLocale: string;\n\n constructor(messages: LocalizedStrings, defaultLocale: string = 'en-US') {\n // Clone messages so we don't modify the original object.\n // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.\n this.messages = Object.fromEntries(\n Object.entries(messages).filter(([, v]) => v)\n );\n this.defaultLocale = defaultLocale;\n }\n\n getStringForLocale(key: string, locale: string): string {\n let strings = this.messages[locale];\n if (!strings) {\n strings = getStringsForLocale(locale, this.messages, this.defaultLocale);\n this.messages[locale] = strings;\n }\n\n let string = strings[key];\n if (!string) {\n throw new Error(`Could not find intl message ${key} in ${locale} locale`);\n }\n\n return string;\n }\n}\n\nfunction getStringsForLocale(locale: string, strings: LocalizedStrings, defaultLocale = 'en-US') {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n // This could be replaced with Intl.LocaleMatcher once it is supported.\n // https://github.com/tc39/proposal-intl-localematcher\n let language = getLanguage(locale);\n if (strings[language]) {\n return strings[language];\n }\n\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings[defaultLocale];\n}\n\nfunction getLanguage(locale: string) {\n if (Intl.Locale) {\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\n}\n"],"names":[],"version":3,"file":"MessageDictionary.js.map"}
@@ -8,25 +8,25 @@
8
8
  * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
9
  * OF ANY KIND, either express or implied. See the License for the specific language
10
10
  * governing permissions and limitations under the License.
11
- */ class $d6fd23bc337660df$export$64839e615120df17 {
11
+ */ class $87b7f54626b6e2f0$export$64839e615120df17 {
12
+ constructor(messages, defaultLocale = 'en-US'){
13
+ // Clone messages so we don't modify the original object.
14
+ // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
15
+ this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
16
+ this.defaultLocale = defaultLocale;
17
+ }
12
18
  getStringForLocale(key, locale) {
13
19
  let strings = this.messages[locale];
14
20
  if (!strings) {
15
- strings = $d6fd23bc337660df$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
21
+ strings = $87b7f54626b6e2f0$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
16
22
  this.messages[locale] = strings;
17
23
  }
18
24
  let string = strings[key];
19
25
  if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
20
26
  return string;
21
27
  }
22
- constructor(messages, defaultLocale = 'en-US'){
23
- // Clone messages so we don't modify the original object.
24
- // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
25
- this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
26
- this.defaultLocale = defaultLocale;
27
- }
28
28
  }
29
- function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
29
+ function $87b7f54626b6e2f0$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
30
30
  // If there is an exact match, use it.
31
31
  if (strings[locale]) return strings[locale];
32
32
  // Attempt to find the closest match by language.
@@ -34,7 +34,7 @@ function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocal
34
34
  // an fr-FR (France) set of strings, use that.
35
35
  // This could be replaced with Intl.LocaleMatcher once it is supported.
36
36
  // https://github.com/tc39/proposal-intl-localematcher
37
- let language = $d6fd23bc337660df$var$getLanguage(locale);
37
+ let language = $87b7f54626b6e2f0$var$getLanguage(locale);
38
38
  if (strings[language]) return strings[language];
39
39
  for(let key in strings){
40
40
  if (key.startsWith(language + '-')) return strings[key];
@@ -42,11 +42,11 @@ function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocal
42
42
  // Nothing close, use english.
43
43
  return strings[defaultLocale];
44
44
  }
45
- function $d6fd23bc337660df$var$getLanguage(locale) {
45
+ function $87b7f54626b6e2f0$var$getLanguage(locale) {
46
46
  if (Intl.Locale) return new Intl.Locale(locale).language;
47
47
  return locale.split('-')[0];
48
48
  }
49
49
 
50
50
 
51
- export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary};
52
- //# sourceMappingURL=MessageDictionary.module.js.map
51
+ export {$87b7f54626b6e2f0$export$64839e615120df17 as MessageDictionary};
52
+ //# sourceMappingURL=MessageDictionary.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":"AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IAIX,YAAY,QAA0B,EAAE,gBAAwB,OAAO,CAAE;QACvE,yDAAyD;QACzD,uGAAuG;QACvG,IAAI,CAAC,QAAQ,GAAG,OAAO,WAAW,CAChC,OAAO,OAAO,CAAC,UAAU,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK;QAE7C,IAAI,CAAC,aAAa,GAAG;IACvB;IAEA,mBAAmB,GAAW,EAAE,MAAc,EAAU;QACtD,IAAI,UAAU,IAAI,CAAC,QAAQ,CAAC,OAAO;QACnC,IAAI,CAAC,SAAS;YACZ,UAAU,0CAAoB,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa;YACvE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG;QAC1B;QAEA,IAAI,SAAS,OAAO,CAAC,IAAI;QACzB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO,CAAC;QAG1E,OAAO;IACT;AACF;AAEA,SAAS,0CAAoB,MAAc,EAAE,OAAyB,EAAE,gBAAgB,OAAO;IAC7F,sCAAsC;IACtC,IAAI,OAAO,CAAC,OAAO,EACjB,OAAO,OAAO,CAAC,OAAO;IAGxB,iDAAiD;IACjD,2EAA2E;IAC3E,8CAA8C;IAC9C,uEAAuE;IACvE,sDAAsD;IACtD,IAAI,WAAW,kCAAY;IAC3B,IAAI,OAAO,CAAC,SAAS,EACnB,OAAO,OAAO,CAAC,SAAS;IAG1B,IAAK,IAAI,OAAO,QAAS;QACvB,IAAI,IAAI,UAAU,CAAC,WAAW,MAC5B,OAAO,OAAO,CAAC,IAAI;IAEvB;IAEA,8BAA8B;IAC9B,OAAO,OAAO,CAAC,cAAc;AAC/B;AAEA,SAAS,kCAAY,MAAc;IACjC,IAAI,KAAK,MAAM,EACb,OAAO,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ;IAGzC,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7B","sources":["packages/@internationalized/message/src/MessageDictionary.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type LocalizedStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\n/**\n * Stores a mapping of localized strings. Can be used to find the\n * closest available string for a given locale.\n */\nexport class MessageDictionary {\n private messages: LocalizedStrings;\n private defaultLocale: string;\n\n constructor(messages: LocalizedStrings, defaultLocale: string = 'en-US') {\n // Clone messages so we don't modify the original object.\n // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.\n this.messages = Object.fromEntries(\n Object.entries(messages).filter(([, v]) => v)\n );\n this.defaultLocale = defaultLocale;\n }\n\n getStringForLocale(key: string, locale: string): string {\n let strings = this.messages[locale];\n if (!strings) {\n strings = getStringsForLocale(locale, this.messages, this.defaultLocale);\n this.messages[locale] = strings;\n }\n\n let string = strings[key];\n if (!string) {\n throw new Error(`Could not find intl message ${key} in ${locale} locale`);\n }\n\n return string;\n }\n}\n\nfunction getStringsForLocale(locale: string, strings: LocalizedStrings, defaultLocale = 'en-US') {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n // This could be replaced with Intl.LocaleMatcher once it is supported.\n // https://github.com/tc39/proposal-intl-localematcher\n let language = getLanguage(locale);\n if (strings[language]) {\n return strings[language];\n }\n\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings[defaultLocale];\n}\n\nfunction getLanguage(locale: string) {\n if (Intl.Locale) {\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\n}\n"],"names":[],"version":3,"file":"MessageDictionary.mjs.map"}
@@ -1,4 +1,4 @@
1
- var $f4V3v$intlmessageformat = require("intl-messageformat");
1
+ var $3NOZx$intlmessageformat = require("intl-messageformat");
2
2
 
3
3
 
4
4
  function $parcel$interopDefault(a) {
@@ -9,7 +9,7 @@ function $parcel$export(e, n, v, s) {
9
9
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
10
  }
11
11
 
12
- $parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$export$526ebc05ff964723);
12
+ $parcel$export(module.exports, "MessageFormatter", function () { return $2d21f5a7e66832cf$export$526ebc05ff964723; });
13
13
  /*
14
14
  * Copyright 2020 Adobe. All rights reserved.
15
15
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -21,13 +21,18 @@ $parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$expor
21
21
  * OF ANY KIND, either express or implied. See the License for the specific language
22
22
  * governing permissions and limitations under the License.
23
23
  */
24
- class $7a31ee9993c13f0b$export$526ebc05ff964723 {
24
+ class $2d21f5a7e66832cf$export$526ebc05ff964723 {
25
+ constructor(locale, messages){
26
+ this.locale = locale;
27
+ this.messages = messages;
28
+ this.cache = {};
29
+ }
25
30
  format(key, variables) {
26
31
  let message = this.cache[key];
27
32
  if (!message) {
28
33
  let msg = this.messages.getStringForLocale(key, this.locale);
29
34
  if (!msg) throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);
30
- message = new (0, ($parcel$interopDefault($f4V3v$intlmessageformat)))(msg, this.locale);
35
+ message = new (0, ($parcel$interopDefault($3NOZx$intlmessageformat)))(msg, this.locale);
31
36
  this.cache[key] = message;
32
37
  }
33
38
  let varCopy;
@@ -37,12 +42,7 @@ class $7a31ee9993c13f0b$export$526ebc05ff964723 {
37
42
  }, {});
38
43
  return message.format(varCopy);
39
44
  }
40
- constructor(locale, messages){
41
- this.locale = locale;
42
- this.messages = messages;
43
- this.cache = {};
44
- }
45
45
  }
46
46
 
47
47
 
48
- //# sourceMappingURL=MessageFormatter.main.js.map
48
+ //# sourceMappingURL=MessageFormatter.cjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AASM,MAAM;IAKX,YAAY,MAAc,EAAE,QAA2B,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC;IAChB;IAEA,OAAiB,GAAW,EAAE,SAA6G,EAA+B;QACxK,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI;QAC7B,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAG/E,UAAU,IAAI,CAAA,GAAA,kDAAgB,EAAE,KAAK,IAAI,CAAC,MAAM;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG;QACpB;QACA,IAAI;QACJ,IAAI,WACF,UAAU,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;YAC5C,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,IAAI;YAC1D,OAAO;QACT,GAAG,CAAC;QAGN,OAAO,QAAQ,MAAM,CAAC;IACxB;AACF","sources":["packages/@internationalized/message/src/MessageFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';\nimport IntlMessageFormat from 'intl-messageformat';\nimport {MessageDictionary} from './MessageDictionary';\n\n/**\n * Formats ICU Message strings to create localized strings from a MessageDictionary.\n */\nexport class MessageFormatter {\n private locale: string;\n private messages: MessageDictionary;\n private cache: {[key: string]: IntlMessageFormat};\n\n constructor(locale: string, messages: MessageDictionary) {\n this.locale = locale;\n this.messages = messages;\n this.cache = {};\n }\n\n format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[] {\n let message = this.cache[key];\n if (!message) {\n let msg = this.messages.getStringForLocale(key, this.locale);\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);\n }\n\n message = new IntlMessageFormat(msg, this.locale);\n this.cache[key] = message;\n }\n let varCopy: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined;\n if (variables) {\n varCopy = Object.keys(variables).reduce((acc, key) => {\n acc[key] = variables[key] == null ? false : variables[key];\n return acc;\n }, {});\n }\n\n return message.format(varCopy);\n }\n}\n"],"names":[],"version":3,"file":"MessageFormatter.cjs.map"}
@@ -1,4 +1,4 @@
1
- import $9UXlH$intlmessageformat from "intl-messageformat";
1
+ import $iVHIe$intlmessageformat from "intl-messageformat";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -11,13 +11,13 @@ import $9UXlH$intlmessageformat from "intl-messageformat";
11
11
  * OF ANY KIND, either express or implied. See the License for the specific language
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
- class $972eb555d604f491$export$526ebc05ff964723 {
14
+ class $6c4b92c606f6c9ec$export$526ebc05ff964723 {
15
15
  format(key, variables) {
16
16
  let message = this.cache[key];
17
17
  if (!message) {
18
18
  let msg = this.messages.getStringForLocale(key, this.locale);
19
19
  if (!msg) throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);
20
- message = new (0, $9UXlH$intlmessageformat)(msg, this.locale);
20
+ message = new (0, $iVHIe$intlmessageformat)(msg, this.locale);
21
21
  this.cache[key] = message;
22
22
  }
23
23
  let varCopy;
@@ -35,5 +35,5 @@ class $972eb555d604f491$export$526ebc05ff964723 {
35
35
  }
36
36
 
37
37
 
38
- export {$972eb555d604f491$export$526ebc05ff964723 as MessageFormatter};
39
- //# sourceMappingURL=MessageFormatter.module.js.map
38
+ export {$6c4b92c606f6c9ec$export$526ebc05ff964723 as MessageFormatter};
39
+ //# sourceMappingURL=MessageFormatter.js.map
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AASM,MAAM;IAWX,OAAiB,GAAW,EAAE,SAA6G,EAA+B;QACxK,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI;QAC7B,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAG/E,UAAU,IAAI,CAAA,GAAA,wBAAgB,EAAE,KAAK,IAAI,CAAC,MAAM;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG;QACpB;QACA,IAAI;QACJ,IAAI,WACF,UAAU,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;YAC5C,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,IAAI;YAC1D,OAAO;QACT,GAAG,CAAC;QAGN,OAAO,QAAQ,MAAM,CAAC;IACxB;IA1BA,YAAY,MAAc,EAAE,QAA2B,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC;IAChB;AAuBF","sources":["packages/@internationalized/message/src/MessageFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';\nimport IntlMessageFormat from 'intl-messageformat';\nimport {MessageDictionary} from './MessageDictionary';\n\n/**\n * Formats ICU Message strings to create localized strings from a MessageDictionary.\n */\nexport class MessageFormatter {\n private locale: string;\n private messages: MessageDictionary;\n private cache: {[key: string]: IntlMessageFormat};\n\n constructor(locale: string, messages: MessageDictionary) {\n this.locale = locale;\n this.messages = messages;\n this.cache = {};\n }\n\n format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[] {\n let message = this.cache[key];\n if (!message) {\n let msg = this.messages.getStringForLocale(key, this.locale);\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);\n }\n\n message = new IntlMessageFormat(msg, this.locale);\n this.cache[key] = message;\n }\n let varCopy: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined;\n if (variables) {\n varCopy = Object.keys(variables).reduce((acc, key) => {\n acc[key] = variables[key] == null ? false : variables[key];\n return acc;\n }, {});\n }\n\n return message.format(varCopy);\n }\n}\n"],"names":[],"version":3,"file":"MessageFormatter.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AASM,MAAM;IAWX,OAAiB,GAAW,EAAE,SAA6G,EAA+B;QACxK,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI;QAC7B,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAG/E,UAAU,IAAI,CAAA,GAAA,wBAAgB,EAAE,KAAK,IAAI,CAAC,MAAM;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG;QACpB;QACA,IAAI;QACJ,IAAI,WACF,UAAU,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;YAC5C,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,IAAI;YAC1D,OAAO;QACT,GAAG,CAAC;QAGN,OAAO,QAAQ,MAAM,CAAC;IACxB;IA1BA,YAAY,MAAc,EAAE,QAA2B,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC;IAChB;AAuBF","sources":["packages/@internationalized/message/src/MessageFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';\nimport IntlMessageFormat from 'intl-messageformat';\nimport {MessageDictionary} from './MessageDictionary';\n\n/**\n * Formats ICU Message strings to create localized strings from a MessageDictionary.\n */\nexport class MessageFormatter {\n private locale: string;\n private messages: MessageDictionary;\n private cache: {[key: string]: IntlMessageFormat};\n\n constructor(locale: string, messages: MessageDictionary) {\n this.locale = locale;\n this.messages = messages;\n this.cache = {};\n }\n\n format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[] {\n let message = this.cache[key];\n if (!message) {\n let msg = this.messages.getStringForLocale(key, this.locale);\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);\n }\n\n message = new IntlMessageFormat(msg, this.locale);\n this.cache[key] = message;\n }\n let varCopy: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined;\n if (variables) {\n varCopy = Object.keys(variables).reduce((acc, key) => {\n acc[key] = variables[key] == null ? false : variables[key];\n return acc;\n }, {});\n }\n\n return message.format(varCopy);\n }\n}\n"],"names":[],"version":3,"file":"MessageFormatter.js.map"}
@@ -1,4 +1,4 @@
1
- import $9UXlH$intlmessageformat from "intl-messageformat";
1
+ import $9QPT7$intlmessageformat from "intl-messageformat";
2
2
 
3
3
  /*
4
4
  * Copyright 2020 Adobe. All rights reserved.
@@ -11,13 +11,18 @@ import $9UXlH$intlmessageformat from "intl-messageformat";
11
11
  * OF ANY KIND, either express or implied. See the License for the specific language
12
12
  * governing permissions and limitations under the License.
13
13
  */
14
- class $972eb555d604f491$export$526ebc05ff964723 {
14
+ class $53ce84155a688a77$export$526ebc05ff964723 {
15
+ constructor(locale, messages){
16
+ this.locale = locale;
17
+ this.messages = messages;
18
+ this.cache = {};
19
+ }
15
20
  format(key, variables) {
16
21
  let message = this.cache[key];
17
22
  if (!message) {
18
23
  let msg = this.messages.getStringForLocale(key, this.locale);
19
24
  if (!msg) throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);
20
- message = new (0, $9UXlH$intlmessageformat)(msg, this.locale);
25
+ message = new (0, $9QPT7$intlmessageformat)(msg, this.locale);
21
26
  this.cache[key] = message;
22
27
  }
23
28
  let varCopy;
@@ -27,13 +32,8 @@ class $972eb555d604f491$export$526ebc05ff964723 {
27
32
  }, {});
28
33
  return message.format(varCopy);
29
34
  }
30
- constructor(locale, messages){
31
- this.locale = locale;
32
- this.messages = messages;
33
- this.cache = {};
34
- }
35
35
  }
36
36
 
37
37
 
38
- export {$972eb555d604f491$export$526ebc05ff964723 as MessageFormatter};
39
- //# sourceMappingURL=MessageFormatter.module.js.map
38
+ export {$53ce84155a688a77$export$526ebc05ff964723 as MessageFormatter};
39
+ //# sourceMappingURL=MessageFormatter.mjs.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AASM,MAAM;IAKX,YAAY,MAAc,EAAE,QAA2B,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC;IAChB;IAEA,OAAiB,GAAW,EAAE,SAA6G,EAA+B;QACxK,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI;QAC7B,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAG/E,UAAU,IAAI,CAAA,GAAA,wBAAgB,EAAE,KAAK,IAAI,CAAC,MAAM;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG;QACpB;QACA,IAAI;QACJ,IAAI,WACF,UAAU,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;YAC5C,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,IAAI;YAC1D,OAAO;QACT,GAAG,CAAC;QAGN,OAAO,QAAQ,MAAM,CAAC;IACxB;AACF","sources":["packages/@internationalized/message/src/MessageFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';\nimport IntlMessageFormat from 'intl-messageformat';\nimport {MessageDictionary} from './MessageDictionary';\n\n/**\n * Formats ICU Message strings to create localized strings from a MessageDictionary.\n */\nexport class MessageFormatter {\n private locale: string;\n private messages: MessageDictionary;\n private cache: {[key: string]: IntlMessageFormat};\n\n constructor(locale: string, messages: MessageDictionary) {\n this.locale = locale;\n this.messages = messages;\n this.cache = {};\n }\n\n format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[] {\n let message = this.cache[key];\n if (!message) {\n let msg = this.messages.getStringForLocale(key, this.locale);\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);\n }\n\n message = new IntlMessageFormat(msg, this.locale);\n this.cache[key] = message;\n }\n let varCopy: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined;\n if (variables) {\n varCopy = Object.keys(variables).reduce((acc, key) => {\n acc[key] = variables[key] == null ? false : variables[key];\n return acc;\n }, {});\n }\n\n return message.format(varCopy);\n }\n}\n"],"names":[],"version":3,"file":"MessageFormatter.mjs.map"}
@@ -0,0 +1,15 @@
1
+ export type LocalizedStrings = {
2
+ [lang: string]: {
3
+ [key: string]: string;
4
+ };
5
+ };
6
+ /**
7
+ * Stores a mapping of localized strings. Can be used to find the
8
+ * closest available string for a given locale.
9
+ */
10
+ export declare class MessageDictionary {
11
+ private messages;
12
+ private defaultLocale;
13
+ constructor(messages: LocalizedStrings, defaultLocale?: string);
14
+ getStringForLocale(key: string, locale: string): string;
15
+ }
@@ -0,0 +1,12 @@
1
+ import { FormatXMLElementFn, PrimitiveType } from 'intl-messageformat/src/formatters';
2
+ import { MessageDictionary } from './MessageDictionary';
3
+ /**
4
+ * Formats ICU Message strings to create localized strings from a MessageDictionary.
5
+ */
6
+ export declare class MessageFormatter {
7
+ private locale;
8
+ private messages;
9
+ private cache;
10
+ constructor(locale: string, messages: MessageDictionary);
11
+ format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[];
12
+ }
@@ -0,0 +1,3 @@
1
+ export type { LocalizedStrings } from './MessageDictionary';
2
+ export { MessageDictionary } from './MessageDictionary';
3
+ export { MessageFormatter } from './MessageFormatter';
package/package.json CHANGED
@@ -1,20 +1,18 @@
1
1
  {
2
2
  "name": "@internationalized/message",
3
- "version": "3.1.8",
3
+ "version": "3.1.9",
4
4
  "description": "Internationalized message formatting and locale negotiation",
5
5
  "license": "Apache-2.0",
6
- "main": "dist/main.js",
7
- "module": "dist/module.js",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "import": "dist/index.mjs",
8
9
  "exports": {
9
10
  "source": "./src/index.ts",
10
- "types": [
11
- "./dist/types.d.ts",
12
- "./src/index.ts"
13
- ],
14
- "import": "./dist/import.mjs",
15
- "require": "./dist/main.js"
11
+ "types": "./dist/types/src/index.d.ts",
12
+ "import": "./dist/index.mjs",
13
+ "require": "./dist/index.cjs"
16
14
  },
17
- "types": "dist/types.d.ts",
15
+ "types": "./dist/types/src/index.d.ts",
18
16
  "source": "src/index.ts",
19
17
  "files": [
20
18
  "dist",
@@ -32,5 +30,22 @@
32
30
  "publishConfig": {
33
31
  "access": "public"
34
32
  },
35
- "gitHead": "265b4d7f107905ee1c6e87a8af1613ab440a6849"
33
+ "targets": {
34
+ "types": false,
35
+ "module": {
36
+ "engines": {
37
+ "browsers": [
38
+ "chrome >= 79",
39
+ "firefox >= 85",
40
+ "safari >= 13"
41
+ ]
42
+ }
43
+ },
44
+ "import": {
45
+ "isLibrary": true,
46
+ "outputFormat": "esmodule",
47
+ "includeNodeModules": false
48
+ }
49
+ },
50
+ "gitHead": "a6999bdf494a2e9c0381a5881908328bdd22ddae"
36
51
  }
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAYM,MAAM;IAaX,mBAAmB,GAAW,EAAE,MAAc,EAAU;QACtD,IAAI,UAAU,IAAI,CAAC,QAAQ,CAAC,OAAO;QACnC,IAAI,CAAC,SAAS;YACZ,UAAU,0CAAoB,QAAQ,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa;YACvE,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG;QAC1B;QAEA,IAAI,SAAS,OAAO,CAAC,IAAI;QACzB,IAAI,CAAC,QACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,OAAO,OAAO,CAAC;QAG1E,OAAO;IACT;IAtBA,YAAY,QAA0B,EAAE,gBAAwB,OAAO,CAAE;QACvE,yDAAyD;QACzD,uGAAuG;QACvG,IAAI,CAAC,QAAQ,GAAG,OAAO,WAAW,CAChC,OAAO,OAAO,CAAC,UAAU,MAAM,CAAC,CAAC,GAAG,EAAE,GAAK;QAE7C,IAAI,CAAC,aAAa,GAAG;IACvB;AAgBF;AAEA,SAAS,0CAAoB,MAAc,EAAE,OAAyB,EAAE,gBAAgB,OAAO;IAC7F,sCAAsC;IACtC,IAAI,OAAO,CAAC,OAAO,EACjB,OAAO,OAAO,CAAC,OAAO;IAGxB,iDAAiD;IACjD,2EAA2E;IAC3E,8CAA8C;IAC9C,uEAAuE;IACvE,sDAAsD;IACtD,IAAI,WAAW,kCAAY;IAC3B,IAAI,OAAO,CAAC,SAAS,EACnB,OAAO,OAAO,CAAC,SAAS;IAG1B,IAAK,IAAI,OAAO,QAAS;QACvB,IAAI,IAAI,UAAU,CAAC,WAAW,MAC5B,OAAO,OAAO,CAAC,IAAI;IAEvB;IAEA,8BAA8B;IAC9B,OAAO,OAAO,CAAC,cAAc;AAC/B;AAEA,SAAS,kCAAY,MAAc;IACjC,IAAI,KAAK,MAAM,EACb,OAAO,IAAI,KAAK,MAAM,CAAC,QAAQ,QAAQ;IAGzC,OAAO,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE;AAC7B","sources":["packages/@internationalized/message/src/MessageDictionary.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type LocalizedStrings = {\n [lang: string]: {\n [key: string]: string\n }\n};\n\n/**\n * Stores a mapping of localized strings. Can be used to find the\n * closest available string for a given locale.\n */\nexport class MessageDictionary {\n private messages: LocalizedStrings;\n private defaultLocale: string;\n\n constructor(messages: LocalizedStrings, defaultLocale: string = 'en-US') {\n // Clone messages so we don't modify the original object.\n // Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.\n this.messages = Object.fromEntries(\n Object.entries(messages).filter(([, v]) => v)\n );\n this.defaultLocale = defaultLocale;\n }\n\n getStringForLocale(key: string, locale: string): string {\n let strings = this.messages[locale];\n if (!strings) {\n strings = getStringsForLocale(locale, this.messages, this.defaultLocale);\n this.messages[locale] = strings;\n }\n\n let string = strings[key];\n if (!string) {\n throw new Error(`Could not find intl message ${key} in ${locale} locale`);\n }\n\n return string;\n }\n}\n\nfunction getStringsForLocale(locale: string, strings: LocalizedStrings, defaultLocale = 'en-US') {\n // If there is an exact match, use it.\n if (strings[locale]) {\n return strings[locale];\n }\n\n // Attempt to find the closest match by language.\n // For example, if the locale is fr-CA (French Canadian), but there is only\n // an fr-FR (France) set of strings, use that.\n // This could be replaced with Intl.LocaleMatcher once it is supported.\n // https://github.com/tc39/proposal-intl-localematcher\n let language = getLanguage(locale);\n if (strings[language]) {\n return strings[language];\n }\n\n for (let key in strings) {\n if (key.startsWith(language + '-')) {\n return strings[key];\n }\n }\n\n // Nothing close, use english.\n return strings[defaultLocale];\n}\n\nfunction getLanguage(locale: string) {\n if (Intl.Locale) {\n return new Intl.Locale(locale).language;\n }\n\n return locale.split('-')[0];\n}\n"],"names":[],"version":3,"file":"MessageDictionary.main.js.map"}
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AASM,MAAM;IAWX,OAAiB,GAAW,EAAE,SAA6G,EAA+B;QACxK,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI;QAC7B,IAAI,CAAC,SAAS;YACZ,IAAI,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,KAAK,IAAI,CAAC,MAAM;YAC3D,IAAI,CAAC,KACH,MAAM,IAAI,MAAM,CAAC,4BAA4B,EAAE,IAAI,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;YAG/E,UAAU,IAAI,CAAA,GAAA,kDAAgB,EAAE,KAAK,IAAI,CAAC,MAAM;YAChD,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG;QACpB;QACA,IAAI;QACJ,IAAI,WACF,UAAU,OAAO,IAAI,CAAC,WAAW,MAAM,CAAC,CAAC,KAAK;YAC5C,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI,IAAI,OAAO,QAAQ,SAAS,CAAC,IAAI;YAC1D,OAAO;QACT,GAAG,CAAC;QAGN,OAAO,QAAQ,MAAM,CAAC;IACxB;IA1BA,YAAY,MAAc,EAAE,QAA2B,CAAE;QACvD,IAAI,CAAC,MAAM,GAAG;QACd,IAAI,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,KAAK,GAAG,CAAC;IAChB;AAuBF","sources":["packages/@internationalized/message/src/MessageFormatter.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {FormatXMLElementFn, PrimitiveType} from 'intl-messageformat/src/formatters';\nimport IntlMessageFormat from 'intl-messageformat';\nimport {MessageDictionary} from './MessageDictionary';\n\n/**\n * Formats ICU Message strings to create localized strings from a MessageDictionary.\n */\nexport class MessageFormatter {\n private locale: string;\n private messages: MessageDictionary;\n private cache: {[key: string]: IntlMessageFormat};\n\n constructor(locale: string, messages: MessageDictionary) {\n this.locale = locale;\n this.messages = messages;\n this.cache = {};\n }\n\n format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[] {\n let message = this.cache[key];\n if (!message) {\n let msg = this.messages.getStringForLocale(key, this.locale);\n if (!msg) {\n throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);\n }\n\n message = new IntlMessageFormat(msg, this.locale);\n this.cache[key] = message;\n }\n let varCopy: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined;\n if (variables) {\n varCopy = Object.keys(variables).reduce((acc, key) => {\n acc[key] = variables[key] == null ? false : variables[key];\n return acc;\n }, {});\n }\n\n return message.format(varCopy);\n }\n}\n"],"names":[],"version":3,"file":"MessageFormatter.main.js.map"}
package/dist/types.d.ts DELETED
@@ -1,23 +0,0 @@
1
- import { FormatXMLElementFn, PrimitiveType } from "intl-messageformat/src/formatters";
2
- export type LocalizedStrings = {
3
- [lang: string]: {
4
- [key: string]: string;
5
- };
6
- };
7
- /**
8
- * Stores a mapping of localized strings. Can be used to find the
9
- * closest available string for a given locale.
10
- */
11
- export class MessageDictionary {
12
- constructor(messages: LocalizedStrings, defaultLocale?: string);
13
- getStringForLocale(key: string, locale: string): string;
14
- }
15
- /**
16
- * Formats ICU Message strings to create localized strings from a MessageDictionary.
17
- */
18
- export class MessageFormatter {
19
- constructor(locale: string, messages: MessageDictionary);
20
- format<T = void>(key: string, variables: Record<string, PrimitiveType | T | FormatXMLElementFn<T, string | T | (string | T)[]>> | undefined): string | T | (string | T)[];
21
- }
22
-
23
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"mappings":";AAYA,+BAA+B;IAC7B,CAAC,IAAI,EAAE,MAAM,GAAG;QACd,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KACtB,CAAA;CACF,CAAC;AAEF;;;GAGG;AACH;gBAIc,QAAQ,EAAE,gBAAgB,EAAE,aAAa,GAAE,MAAgB;IASvE,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM;CAcxD;ACjCD;;GAEG;AACH;gBAKc,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,iBAAiB;IAMvD,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,CAAC,GAAG,mBAAmB,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,GAAG,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE;CAqB1K","sources":["packages/@internationalized/message/src/packages/@internationalized/message/src/MessageDictionary.ts","packages/@internationalized/message/src/packages/@internationalized/message/src/MessageFormatter.ts","packages/@internationalized/message/src/packages/@internationalized/message/src/index.ts","packages/@internationalized/message/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nexport type {LocalizedStrings} from './MessageDictionary';\nexport {MessageDictionary} from './MessageDictionary';\nexport {MessageFormatter} from './MessageFormatter';\n"],"names":[],"version":3,"file":"types.d.ts.map"}