Socket
Socket
Sign inDemoInstall

@internationalized/string

Package Overview
Dependencies
Maintainers
2
Versions
444
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@internationalized/string - npm Package Compare versions

Comparing version 3.1.2-nightly.4324 to 3.1.2-nightly.4327

30

dist/main.js

@@ -28,4 +28,13 @@

* governing permissions and limitations under the License.
*/ class $f80be5fd4d03dda9$export$c17fa47878dc55b6 {
*/ const $f80be5fd4d03dda9$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
const $f80be5fd4d03dda9$var$stringsSymbol = Symbol.for("react-aria.i18n.strings");
let $f80be5fd4d03dda9$var$cachedGlobalStrings = undefined;
class $f80be5fd4d03dda9$export$c17fa47878dc55b6 {
/** Returns a localized string for the given key and locale. */ getStringForLocale(key, locale) {
let strings = this.getStringsForLocale(locale);
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
}
/** Returns all localized strings for the given locale. */ getStringsForLocale(locale) {
let strings = this.strings[locale];

@@ -36,6 +45,19 @@ if (!strings) {

}
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
return strings;
}
static getGlobalDictionaryForPackage(packageName) {
if (typeof window === "undefined") return null;
let locale = window[$f80be5fd4d03dda9$var$localeSymbol];
if ($f80be5fd4d03dda9$var$cachedGlobalStrings === undefined) {
let globalStrings = window[$f80be5fd4d03dda9$var$stringsSymbol];
if (!globalStrings) return null;
$f80be5fd4d03dda9$var$cachedGlobalStrings = {};
for(let pkg in globalStrings)$f80be5fd4d03dda9$var$cachedGlobalStrings[pkg] = new $f80be5fd4d03dda9$export$c17fa47878dc55b6({
[locale]: globalStrings[pkg]
}, locale);
}
let dictionary = $f80be5fd4d03dda9$var$cachedGlobalStrings === null || $f80be5fd4d03dda9$var$cachedGlobalStrings === void 0 ? void 0 : $f80be5fd4d03dda9$var$cachedGlobalStrings[packageName];
if (!dictionary) throw new Error(`Strings for package "${packageName}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);
return dictionary;
}
constructor(messages, defaultLocale = "en-US"){

@@ -42,0 +64,0 @@ // Clone messages so we don't modify the original object.

@@ -21,4 +21,13 @@ /*

* governing permissions and limitations under the License.
*/ class $5b160d28a433310d$export$c17fa47878dc55b6 {
*/ const $5b160d28a433310d$var$localeSymbol = Symbol.for("react-aria.i18n.locale");
const $5b160d28a433310d$var$stringsSymbol = Symbol.for("react-aria.i18n.strings");
let $5b160d28a433310d$var$cachedGlobalStrings = undefined;
class $5b160d28a433310d$export$c17fa47878dc55b6 {
/** Returns a localized string for the given key and locale. */ getStringForLocale(key, locale) {
let strings = this.getStringsForLocale(locale);
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
}
/** Returns all localized strings for the given locale. */ getStringsForLocale(locale) {
let strings = this.strings[locale];

@@ -29,6 +38,19 @@ if (!strings) {

}
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
return strings;
}
static getGlobalDictionaryForPackage(packageName) {
if (typeof window === "undefined") return null;
let locale = window[$5b160d28a433310d$var$localeSymbol];
if ($5b160d28a433310d$var$cachedGlobalStrings === undefined) {
let globalStrings = window[$5b160d28a433310d$var$stringsSymbol];
if (!globalStrings) return null;
$5b160d28a433310d$var$cachedGlobalStrings = {};
for(let pkg in globalStrings)$5b160d28a433310d$var$cachedGlobalStrings[pkg] = new $5b160d28a433310d$export$c17fa47878dc55b6({
[locale]: globalStrings[pkg]
}, locale);
}
let dictionary = $5b160d28a433310d$var$cachedGlobalStrings === null || $5b160d28a433310d$var$cachedGlobalStrings === void 0 ? void 0 : $5b160d28a433310d$var$cachedGlobalStrings[packageName];
if (!dictionary) throw new Error(`Strings for package "${packageName}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);
return dictionary;
}
constructor(messages, defaultLocale = "en-US"){

@@ -35,0 +57,0 @@ // Clone messages so we don't modify the original object.

@@ -12,2 +12,5 @@ export type LocalizedStrings<K extends string, T extends LocalizedString> = {

getStringForLocale(key: K, locale: string): T;
/** Returns all localized strings for the given locale. */
getStringsForLocale(locale: string): Record<K, T>;
static getGlobalDictionaryForPackage<K extends string = string, T extends LocalizedString = string>(packageName: string): LocalizedStringDictionary<K, T> | null;
}

@@ -14,0 +17,0 @@ export type Variables = Record<string, string | number | boolean> | undefined;

4

package.json
{
"name": "@internationalized/string",
"version": "3.1.2-nightly.4324+a2146aa2e",
"version": "3.1.2-nightly.4327+ee403ec3b",
"description": "Internationalized string formatting and locale negotiation",

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

},
"gitHead": "a2146aa2eb9cc28f4d90c8f520e6be5ff90471c4"
"gitHead": "ee403ec3ba5dba7c66903e3454b8f510c628a8f9"
}

@@ -19,2 +19,6 @@ /*

const localeSymbol = Symbol.for('react-aria.i18n.locale');
const stringsSymbol = Symbol.for('react-aria.i18n.strings');
let cachedGlobalStrings: {[packageName: string]: LocalizedStringDictionary<any, any>} | null | undefined = undefined;
/**

@@ -36,2 +40,13 @@ * Stores a mapping of localized strings. Can be used to find the

getStringForLocale(key: K, locale: string): T {
let strings = this.getStringsForLocale(locale);
let string = strings[key];
if (!string) {
throw new Error(`Could not find intl message ${key} in ${locale} locale`);
}
return string;
}
/** Returns all localized strings for the given locale. */
getStringsForLocale(locale: string): Record<K, T> {
let strings = this.strings[locale];

@@ -43,8 +58,29 @@ if (!strings) {

let string = strings[key];
if (!string) {
throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return strings;
}
static getGlobalDictionaryForPackage<K extends string = string, T extends LocalizedString = string>(packageName: string): LocalizedStringDictionary<K, T> | null {
if (typeof window === 'undefined') {
return null;
}
return string;
let locale = window[localeSymbol];
if (cachedGlobalStrings === undefined) {
let globalStrings = window[stringsSymbol];
if (!globalStrings) {
return null;
}
cachedGlobalStrings = {};
for (let pkg in globalStrings) {
cachedGlobalStrings[pkg] = new LocalizedStringDictionary({[locale]: globalStrings[pkg]}, locale);
}
}
let dictionary = cachedGlobalStrings?.[packageName];
if (!dictionary) {
throw new Error(`Strings for package "${packageName}" were not included by LocalizedStringProvider. Please add it to the list passed to createLocalizedStringDictionary.`);
}
return dictionary;
}

@@ -51,0 +87,0 @@ }

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc