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-20221028203549 to 0.0.0-snapshot-20221101220000

5

build/cjs/constants/index.js

@@ -85,8 +85,3 @@ '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;

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

61

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, locale = this.locale) => {
this.getCurrencySymbol = currencyCode => {
const currency = currencyCode || this.defaultCurrency;

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

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

@@ -197,8 +197,6 @@ this.defaultCurrency = _currency;

return this.formatCurrencyNone(amount, options);
default:
return this.formatCurrencyAuto(amount, options);
}
return this.formatNumber(amount, {
as: 'currency',
...options
});
}

@@ -294,7 +292,6 @@

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

@@ -402,31 +399,11 @@

getShortCurrencySymbol(currency = this.defaultCurrency || '', locale = this.locale) {
getShortCurrencySymbol(currencyCode = this.defaultCurrency || '') {
const currency = currencyCode || this.defaultCurrency || '';
const regionCode = currency.substring(0, 2);
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 info = this.getCurrencySymbol(currency);
const shortSymbol = info.symbol.replace(regionCode, '');
const alphabeticCharacters = /[A-Za-zÀ-ÖØ-öø-ÿĀ-ɏḂ-ỳ]/;
return alphabeticCharacters.exec(shortSymbol) ? shortSymbolResult : {
return alphabeticCharacters.exec(shortSymbol) ? info : {
symbol: shortSymbol,
prefixed: shortSymbolResult.prefixed
prefixed: info.prefixed
};

@@ -436,3 +413,7 @@ }

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

@@ -439,0 +420,0 @@

@@ -51,6 +51,2 @@ 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,11 +53,8 @@ /// <reference types="react" />

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

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

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

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

@@ -136,3 +136,3 @@ # `@shopify/react-i18n`

- if `form: 'auto'` is given, then `explicit` will be selected if the `currency` option does not match the `defaultCurrency`, otherwise `short` is selected. If either `currency` or `defaultCurrency` is not defined then `short` is selected.
- if `form:` is not given, then behaviour reverts to the legacy (deprecated) `formatCurrency()`, which is a convenience function that simply _auto-assigns_ the `as` option to `currency` and calls `formatNumber()`. Note that this will resemble `form: 'short'`, but will sometimes extend the symbol with extra information depending on the browser's implementation of `Intl.NumberFormat` and the locale in use. For example, `formatCurrency(1.25, {currency: 'CAD'})` may return `$ 1.25`, or it might return `CA$ 1.25`.
- if `form:` is not given, then `form: 'auto'` will be used by default.
- `unformatCurrency()`: converts a localized currency string to a currency string parseable by JavaScript. Example: `€ 1,25 => 1.25`

@@ -139,0 +139,0 @@ - `formatPercentage()`: formats a number as a percentage according to the locale. Convenience function that simply _auto-assigns_ the `as` option to `percent` and calls `formatNumber()`.

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