New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/react-i18n

Package Overview
Dependencies
Maintainers
18
Versions
289
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/react-i18n - npm Package Compare versions

Comparing version 0.0.0-snapshot-20221101220000 to 0.0.0-snapshot-20221101233331

5

build/cjs/constants/index.js

@@ -85,3 +85,8 @@ 'use strict';

const EASTERN_NAME_ORDER_FORMATTERS = new Map([['ko', (firstName, lastName, full) => full ? `${lastName}${firstName}` : lastName], ['ja', (firstName, lastName, full) => full ? `${lastName}${firstName}` : `${lastName}様`], ['zh-CN', (firstName, lastName, full) => full ? `${lastName}${firstName}` : lastName], ['zh-TW', (firstName, lastName, full) => full ? `${lastName}${firstName}` : lastName]]);
const CurrencyShortFormException = {
BRL: 'R$',
HKD: 'HK$'
};
exports.CurrencyShortFormException = CurrencyShortFormException;
exports.DEFAULT_WEEK_START_DAY = DEFAULT_WEEK_START_DAY;

@@ -88,0 +93,0 @@ exports.EASTERN_NAME_ORDER_FORMATTERS = EASTERN_NAME_ORDER_FORMATTERS;

53

build/cjs/i18n.js

@@ -54,3 +54,3 @@ 'use strict';

constructor(translations, {
locale,
locale: _locale,
currency: _currency,

@@ -74,3 +74,3 @@ timezone,

this.getCurrencySymbol = currencyCode => {
this.getCurrencySymbol = (currencyCode, locale = this.locale) => {
const currency = currencyCode || this.defaultCurrency;

@@ -82,6 +82,6 @@

return this.getCurrencySymbolLocalized(this.locale, currency);
return this.getShortCurrencySymbol(currency, locale);
};
this.locale = locale;
this.locale = _locale;
this.defaultCountry = country;

@@ -291,6 +291,7 @@ this.defaultCurrency = _currency;

/**
* @deprecated Replace usage of `i18n.getCurrencySymbolLocalized(locale, currency)` with `i18n.getCurrencySymbol(currency, locale)`
*/
getCurrencySymbolLocalized(locale, currency) {
return money.getCurrencySymbol(locale, {
currency
});
return this.getShortCurrencySymbol(currency, locale);
}

@@ -398,11 +399,31 @@

getShortCurrencySymbol(currencyCode = this.defaultCurrency || '') {
const currency = currencyCode || this.defaultCurrency || '';
getShortCurrencySymbol(currency = this.defaultCurrency || '', locale = this.locale) {
const regionCode = currency.substring(0, 2);
const info = this.getCurrencySymbol(currency);
const shortSymbol = info.symbol.replace(regionCode, '');
let shortSymbolResult; // currencyDisplay: 'narrowSymbol' was added to iOS in v14.5. See https://caniuse.com/?search=currencydisplay
// We still support ios 12/13, so we need to check if this works and fallback to the default if not
// All other supported browsers understand narrowSymbol, so once our minimum iOS version is updated we can remove this fallback
try {
shortSymbolResult = money.getCurrencySymbol(locale, {
currency,
currencyDisplay: 'narrowSymbol'
});
} catch {
shortSymbolResult = money.getCurrencySymbol(locale, {
currency
});
}
if (currency in index.CurrencyShortFormException) {
return {
symbol: index.CurrencyShortFormException[currency],
prefixed: shortSymbolResult.prefixed
};
}
const shortSymbol = shortSymbolResult.symbol.replace(regionCode, '');
const alphabeticCharacters = /[A-Za-zÀ-ÖØ-öø-ÿĀ-ɏḂ-ỳ]/;
return alphabeticCharacters.exec(shortSymbol) ? info : {
return alphabeticCharacters.exec(shortSymbol) ? shortSymbolResult : {
symbol: shortSymbol,
prefixed: info.prefixed
prefixed: shortSymbolResult.prefixed
};

@@ -412,7 +433,3 @@ }

humanizeDate(date, options) {
if (dates.isFutureDate(date)) {
return this.humanizeFutureDate(date, options);
} else {
return this.humanizePastDate(date, options);
}
return dates.isFutureDate(date) ? this.humanizeFutureDate(date, options) : this.humanizePastDate(date, options);
}

@@ -419,0 +436,0 @@

@@ -51,2 +51,6 @@ export declare enum DateStyle {

export declare const EASTERN_NAME_ORDER_FORMATTERS: Map<string, (firstName: string, lastName: string, full: boolean) => string>;
export declare const CurrencyShortFormException: {
readonly BRL: "R$";
readonly HKD: "HK$";
};
//# sourceMappingURL=index.d.ts.map

@@ -53,8 +53,11 @@ /// <reference types="react" />

weekStartDay(argCountry?: I18n['defaultCountry']): Weekday;
getCurrencySymbol: (currencyCode?: string) => {
symbol: string;
getCurrencySymbol: (currencyCode?: string, locale?: string) => {
symbol: any;
prefixed: boolean;
};
/**
* @deprecated Replace usage of `i18n.getCurrencySymbolLocalized(locale, currency)` with `i18n.getCurrencySymbol(currency, locale)`
*/
getCurrencySymbolLocalized(locale: string, currency: string): {
symbol: string;
symbol: any;
prefixed: boolean;

@@ -61,0 +64,0 @@ };

{
"name": "@shopify/react-i18n",
"version": "0.0.0-snapshot-20221101220000",
"version": "0.0.0-snapshot-20221101233331",
"license": "MIT",

@@ -5,0 +5,0 @@ "description": "i18n utilities for React handling translations, formatting, and more",

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

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