Socket
Socket
Sign inDemoInstall

@internationalized/message

Package Overview
Dependencies
8
Maintainers
2
Versions
597
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.3-nightly.4555 to 3.1.3-nightly.4558

dist/MessageDictionary.main.js

96

dist/main.js

@@ -1,2 +0,3 @@

var $g9nQA$intlmessageformat = require("intl-messageformat");
var $9a5a7b8408290694$exports = require("./MessageDictionary.main.js");
var $7a31ee9993c13f0b$exports = require("./MessageFormatter.main.js");

@@ -8,8 +9,4 @@

function $parcel$interopDefault(a) {
return a && a.__esModule ? a.default : a;
}
$parcel$export(module.exports, "MessageDictionary", () => $9a5a7b8408290694$export$64839e615120df17);
$parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$export$526ebc05ff964723);
$parcel$export(module.exports, "MessageDictionary", () => $9a5a7b8408290694$exports.MessageDictionary);
$parcel$export(module.exports, "MessageFormatter", () => $7a31ee9993c13f0b$exports.MessageFormatter);
/*

@@ -25,91 +22,6 @@ * Copyright 2020 Adobe. All rights reserved.

* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ class $9a5a7b8408290694$export$64839e615120df17 {
getStringForLocale(key, locale) {
let strings = this.messages[locale];
if (!strings) {
strings = $9a5a7b8408290694$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
this.messages[locale] = strings;
}
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
}
constructor(messages, defaultLocale = "en-US"){
// Clone messages so we don't modify the original object.
// Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
this.defaultLocale = defaultLocale;
}
}
function $9a5a7b8408290694$var$getStringsForLocale(locale, strings, defaultLocale = "en-US") {
// If there is an exact match, use it.
if (strings[locale]) return strings[locale];
// Attempt to find the closest match by language.
// For example, if the locale is fr-CA (French Canadian), but there is only
// an fr-FR (France) set of strings, use that.
// This could be replaced with Intl.LocaleMatcher once it is supported.
// https://github.com/tc39/proposal-intl-localematcher
let language = $9a5a7b8408290694$var$getLanguage(locale);
if (strings[language]) return strings[language];
for(let key in strings){
if (key.startsWith(language + "-")) return strings[key];
}
// Nothing close, use english.
return strings[defaultLocale];
}
function $9a5a7b8408290694$var$getLanguage(locale) {
// @ts-ignore
if (Intl.Locale) // @ts-ignore
return new Intl.Locale(locale).language;
return locale.split("-")[0];
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
class $7a31ee9993c13f0b$export$526ebc05ff964723 {
format(key, variables) {
let message = this.cache[key];
if (!message) {
let msg = this.messages.getStringForLocale(key, this.locale);
if (!msg) throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);
message = new (0, ($parcel$interopDefault($g9nQA$intlmessageformat)))(msg, this.locale);
this.cache[key] = message;
}
let varCopy;
if (variables) varCopy = Object.keys(variables).reduce((acc, key)=>{
acc[key] = variables[key] == null ? false : variables[key];
return acc;
}, {});
return message.format(varCopy);
}
constructor(locale, messages){
this.locale = locale;
this.messages = messages;
this.cache = {};
}
}
//# sourceMappingURL=main.js.map

@@ -1,2 +0,3 @@

import $1DoQa$intlmessageformat from "intl-messageformat";
import {MessageDictionary as $d6fd23bc337660df$export$64839e615120df17} from "./MessageDictionary.module.js";
import {MessageFormatter as $972eb555d604f491$export$526ebc05ff964723} from "./MessageFormatter.module.js";

@@ -13,92 +14,7 @@ /*

* governing permissions and limitations under the License.
*/ /*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ class $d6fd23bc337660df$export$64839e615120df17 {
getStringForLocale(key, locale) {
let strings = this.messages[locale];
if (!strings) {
strings = $d6fd23bc337660df$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
this.messages[locale] = strings;
}
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
}
constructor(messages, defaultLocale = "en-US"){
// Clone messages so we don't modify the original object.
// Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
this.defaultLocale = defaultLocale;
}
}
function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocale = "en-US") {
// If there is an exact match, use it.
if (strings[locale]) return strings[locale];
// Attempt to find the closest match by language.
// For example, if the locale is fr-CA (French Canadian), but there is only
// an fr-FR (France) set of strings, use that.
// This could be replaced with Intl.LocaleMatcher once it is supported.
// https://github.com/tc39/proposal-intl-localematcher
let language = $d6fd23bc337660df$var$getLanguage(locale);
if (strings[language]) return strings[language];
for(let key in strings){
if (key.startsWith(language + "-")) return strings[key];
}
// Nothing close, use english.
return strings[defaultLocale];
}
function $d6fd23bc337660df$var$getLanguage(locale) {
// @ts-ignore
if (Intl.Locale) // @ts-ignore
return new Intl.Locale(locale).language;
return locale.split("-")[0];
}
/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
class $972eb555d604f491$export$526ebc05ff964723 {
format(key, variables) {
let message = this.cache[key];
if (!message) {
let msg = this.messages.getStringForLocale(key, this.locale);
if (!msg) throw new Error(`Could not find intl message ${key} in ${this.locale} locale`);
message = new (0, $1DoQa$intlmessageformat)(msg, this.locale);
this.cache[key] = message;
}
let varCopy;
if (variables) varCopy = Object.keys(variables).reduce((acc, key)=>{
acc[key] = variables[key] == null ? false : variables[key];
return acc;
}, {});
return message.format(varCopy);
}
constructor(locale, messages){
this.locale = locale;
this.messages = messages;
this.cache = {};
}
}
export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary, $972eb555d604f491$export$526ebc05ff964723 as MessageFormatter};
//# sourceMappingURL=module.js.map
{
"name": "@internationalized/message",
"version": "3.1.3-nightly.4555+81162ea39",
"version": "3.1.3-nightly.4558+c5e4b3701",
"description": "Internationalized message formatting and locale negotiation",

@@ -31,3 +31,3 @@ "license": "Apache-2.0",

},
"gitHead": "81162ea392926d06ec3d25c228e6f9b6b5479d59"
"gitHead": "c5e4b3701fdb89eb551f1b3697ac253f06ef68fa"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc