Socket
Socket
Sign inDemoInstall

@lion/localize

Package Overview
Dependencies
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lion/localize - npm Package Compare versions

Comparing version 0.22.0 to 0.23.0

8

docs/overview.md

@@ -12,3 +12,3 @@ # Systems >> Localize >> Overview ||10

Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/features.md).
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/features.md).

@@ -19,5 +19,5 @@ ## Content

| ---------------------------------------- | --------------------------------------------- |
| [Translate Text](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages |
| [Format Numbers](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages |
| [Format Dates](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/dates.md) | Format dates in multiple languages |
| [Translate Text](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages |
| [Format Numbers](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages |
| [Format Dates](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/dates.md) | Format dates in multiple languages |

@@ -24,0 +24,0 @@ ## Installation

{
"name": "@lion/localize",
"version": "0.22.0",
"version": "0.23.0",
"description": "The localization system helps to manage localization data split into locales and automate its loading",

@@ -37,4 +37,4 @@ "license": "MIT",

"@bundled-es-modules/message-format": "6.0.4",
"@lion/core": "0.20.0",
"singleton-manager": "1.4.3"
"@lion/core": "^0.21.0",
"singleton-manager": "^1.4.3"
},

@@ -41,0 +41,0 @@ "keywords": [

@@ -12,3 +12,3 @@ # Systems >> Localize >> Overview ||10

Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/features.md).
Further examples and a more in depth description can be found at the [Features Page](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/features.md).

@@ -19,5 +19,5 @@ ## Content

| ---------------------------------------- | --------------------------------------------- |
| [Translate Text](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages |
| [Format Numbers](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages |
| [Format Dates](https://github.com/ing-bank/lion/blob/745c809ce06b2dce0ee4e47749ce2b5ca23bd769/docs/docs/systems/localize/dates.md) | Format dates in multiple languages |
| [Translate Text](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/text.md) | Load and translate text in multiple languages |
| [Format Numbers](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/numbers.md) | Format numbers in multiple languages |
| [Format Dates](https://github.com/ing-bank/lion/blob/7c52c12bfb025c98f93b5f0be984cedd3028a20a/docs/docs/systems/localize/dates.md) | Format dates in multiple languages |

@@ -24,0 +24,0 @@ ## Installation

@@ -9,3 +9,3 @@ /** @typedef {import('../../types/LocalizeMixinTypes').DatePostProcessor} DatePostProcessor */

*/
export function formatDate(date: Date, options?: import("../../types/LocalizeMixinTypes.js").FormatDateOptions | undefined): string;
export type DatePostProcessor = typeof import("../../types/LocalizeMixinTypes.js").DatePostProcessorImplementation;
export function formatDate(date: Date, options?: import("../../types/LocalizeMixinTypes").FormatDateOptions | undefined): string;
export type DatePostProcessor = import('../../types/LocalizeMixinTypes').DatePostProcessor;

@@ -5,8 +5,8 @@ /**

* @param {string} [options.locale] locale
* @param {string} [options.style=long] long, short or narrow
* @param {"long" | "numeric" | "2-digit" | "short" | "narrow"} [options.style=long] long, short or narrow
* @returns {string[]} like: ['January', 'February', ...etc].
*/
export function getMonthNames({ locale, style }?: {
locale?: string;
style?: string;
locale?: string | undefined;
style?: "short" | "long" | "narrow" | "numeric" | "2-digit" | undefined;
} | undefined): string[];

@@ -11,6 +11,6 @@ import { normalizeIntlDate } from './utils/normalizeIntlDate.js';

* @param {string} [options.locale] locale
* @param {string} [options.style=long] long, short or narrow
* @param {"long" | "numeric" | "2-digit" | "short" | "narrow"} [options.style=long] long, short or narrow
* @returns {string[]} like: ['January', 'February', ...etc].
*/
export function getMonthNames({ locale, style = 'long' } = {}) {
export function getMonthNames({ locale = 'en-GB', style = 'long' } = {}) {
let months = monthsLocaleCache[locale] && monthsLocaleCache[locale][style];

@@ -17,0 +17,0 @@

@@ -10,5 +10,5 @@ /**

export function getWeekdayNames({ locale, style, firstDayOfWeek }?: {
locale?: string;
style?: string;
firstDayOfWeek?: number;
locale?: string | undefined;
style?: string | undefined;
firstDayOfWeek?: number | undefined;
} | undefined): string[];

@@ -25,3 +25,5 @@ import { normalizeIntlDate } from './utils/normalizeIntlDate.js';

['long', 'short', 'narrow'].forEach(style => {
/** @type {Array<"long" | "short" | "narrow">} style */
const styles = ['long', 'short', 'narrow'];
styles.forEach(style => {
weekdays = weekdayNamesCache[locale][style];

@@ -52,3 +54,3 @@ const formatter = new Intl.DateTimeFormat(locale, {

*/
export function getWeekdayNames({ locale, style = 'long', firstDayOfWeek = 0 } = {}) {
export function getWeekdayNames({ locale = 'en-GB', style = 'long', firstDayOfWeek = 0 } = {}) {
const weekdays = getCachedWeekdayNames(locale)[style];

@@ -55,0 +57,0 @@ const orderedWeekdays = [];

@@ -9,2 +9,2 @@ /**

*/
export function normalizeIntlDate(str: string, locale?: string | undefined, { weekday, year, month, day }?: import("../../../types/LocalizeMixinTypes").FormatDateOptions | undefined): string;
export function normalizeIntlDate(str: string, locale?: string | undefined, { weekday, year, month, day }?: import("@lion/localize/types/LocalizeMixinTypes").FormatDateOptions | undefined): string;

@@ -126,3 +126,3 @@ /**

loadNamespaces(namespaces: NamespaceObject[], { locale }?: {
locale?: string;
locale?: string | undefined;
} | undefined): Promise<Object>;

@@ -136,3 +136,3 @@ /**

loadNamespace(namespaceObj: NamespaceObject, { locale }?: {
locale?: string;
locale?: string | undefined;
} | undefined): Promise<Object | void>;

@@ -149,3 +149,3 @@ /**

} | undefined, opts?: {
locale?: string;
locale?: string | undefined;
} | undefined): string;

@@ -275,4 +275,4 @@ /** @protected */

}
export type NamespaceObject = string | import("../types/LocalizeMixinTypes.js").StringToFunctionMap;
export type DatePostProcessor = typeof import("../types/LocalizeMixinTypes.js").DatePostProcessorImplementation;
export type NumberPostProcessor = typeof import("../types/LocalizeMixinTypes.js").NumberPostProcessorImplementation;
export type NamespaceObject = import('../types/LocalizeMixinTypes').NamespaceObject;
export type DatePostProcessor = import('../types/LocalizeMixinTypes').DatePostProcessor;
export type NumberPostProcessor = import('../types/LocalizeMixinTypes').NumberPostProcessor;

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

export type LocalizeMixin = typeof import("../types/LocalizeMixinTypes.js").LocalizeMixinImplementation;
export const LocalizeMixin: typeof import("../types/LocalizeMixinTypes.js").LocalizeMixinImplementation;
export type DirectiveResult = import("@lion/core").DirectiveResult<import("@lion/core/node_modules/lit-html/directive").DirectiveClass>;
export type LocalizeMixin = import('../types/LocalizeMixinTypes').LocalizeMixin;
export const LocalizeMixin: typeof import("../types/LocalizeMixinTypes").LocalizeMixinImplementation;
export type DirectiveResult = import('@lion/core').DirectiveResult;

@@ -12,4 +12,6 @@ import { dedupeMixin, until, nothing } from '@lion/core';

* @type {LocalizeMixin}
* @param {import('@open-wc/dedupe-mixin').Constructor<import('@lion/core').LitElement>} superclass
*/
const LocalizeMixinImplementation = superclass =>
// @ts-ignore https://github.com/microsoft/TypeScript/issues/36821#issuecomment-588375051
class LocalizeMixin extends superclass {

@@ -16,0 +18,0 @@ /**

@@ -11,11 +11,11 @@ /** @typedef {import('../../types/LocalizeMixinTypes').NumberPostProcessor} NumberPostProcessor */

*/
export function formatNumber(number: number, options?: import("../../types/LocalizeMixinTypes.js").FormatNumberOptions | undefined): string;
export type NumberPostProcessor = typeof import("../../types/LocalizeMixinTypes.js").NumberPostProcessorImplementation;
export function formatNumber(number: number, options?: import("../../types/LocalizeMixinTypes").FormatNumberOptions | undefined): string;
export type NumberPostProcessor = import('../../types/LocalizeMixinTypes').NumberPostProcessor;
/**
* Formats a number based on locale and options. It uses Intl for the formatting.
*/
export type FormatNumberPart = import("../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../types/LocalizeMixinTypes').FormatNumberPart;
/**
* Formats a number based on locale and options. It uses Intl for the formatting.
*/
export type FormatOptions = import("../../types/LocalizeMixinTypes.js").FormatNumberOptions;
export type FormatOptions = import('@lion/localize/types/LocalizeMixinTypes').FormatNumberOptions;

@@ -18,6 +18,6 @@ /**

*/
export function formatNumberToParts(number: number, options?: import("../../types/LocalizeMixinTypes.js").FormatNumberOptions | undefined): string | FormatNumberPart[];
export function formatNumberToParts(number: number, options?: import("../../types/LocalizeMixinTypes").FormatNumberOptions | undefined): string | FormatNumberPart[];
/**
* Splits a number up in parts for integer, fraction, group, literal, decimal and currency.
*/
export type FormatNumberPart = import("../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -9,6 +9,6 @@ /**

*/
export function getCurrencyName(currencyIso: string, options?: import("../../types/LocalizeMixinTypes.js").FormatNumberOptions | undefined): string;
export function getCurrencyName(currencyIso: string, options?: import("../../types/LocalizeMixinTypes").FormatNumberOptions | undefined): string;
/**
* Based on number, returns currency name like 'US dollar'
*/
export type FormatNumberPart = import("../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -10,2 +10,2 @@ /**

export function getFractionDigits(currency?: string | undefined): number;
export type FormatNumberPart = import("../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -13,2 +13,2 @@ /**

*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -12,2 +12,2 @@ /**

*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -13,2 +13,2 @@ /**

*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -12,2 +12,2 @@ /**

*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -13,2 +13,2 @@ /**

*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -10,2 +10,2 @@ /**

export function forceSpaceInsteadOfZeroForGroup(formattedParts: FormatNumberPart[]): FormatNumberPart[];
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -8,2 +8,2 @@ /**

export function forceTryCurrencyCode(formattedParts: FormatNumberPart[], { currency, currencyDisplay }?: import("../../../../types/LocalizeMixinTypes").FormatNumberOptions | undefined): FormatNumberPart[];
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -8,2 +8,2 @@ /**

export function forceYenSymbol(formattedParts: FormatNumberPart[], { currency, currencyDisplay }?: import("../../../../types/LocalizeMixinTypes").FormatNumberOptions | undefined): FormatNumberPart[];
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -10,6 +10,6 @@ /**

*/
export function normalizeIntl(formattedParts: FormatNumberPart[], options: import("../../../../types/LocalizeMixinTypes.js").FormatNumberOptions | undefined, _locale: string): FormatNumberPart[];
export function normalizeIntl(formattedParts: FormatNumberPart[], options: import("../../../../types/LocalizeMixinTypes").FormatNumberOptions | undefined, _locale: string): FormatNumberPart[];
/**
* Normalizes function "formatNumberToParts"
*/
export type FormatNumberPart = import("../../../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../../../types/LocalizeMixinTypes').FormatNumberPart;

@@ -1,1 +0,1 @@

export {};
export type FormatDateOptions = import('../../types/LocalizeMixinTypes').FormatDateOptions;

@@ -42,2 +42,6 @@ import { expect } from '@open-wc/testing';

/**
* @typedef {import('../../types/LocalizeMixinTypes').FormatDateOptions} FormatDateOptions
*/
describe('formatDate', () => {

@@ -68,2 +72,3 @@ beforeEach(() => {

const testDate = new Date('2012/05/21');
/** @type {FormatDateOptions} */
const options = {

@@ -88,2 +93,3 @@ weekday: 'long',

it('displays Hungarian dates correctly', async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -105,2 +111,3 @@ weekday: 'long',

it('displays Bulgarian dates correctly', async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -125,2 +132,3 @@ weekday: 'long',

it('displays US dates correctly', async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -145,2 +153,3 @@ weekday: 'long',

it('handles locales in options', async () => {
/** @type {FormatDateOptions} */
let options = {

@@ -204,2 +213,3 @@ weekday: 'long',

it(`handles options without year for locale: ${locale}`, async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -218,2 +228,3 @@ weekday: 'long',

it('handles options without month', async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -229,2 +240,3 @@ weekday: 'long',

it('handles options without day', async () => {
/** @type {FormatDateOptions} */
const options = {

@@ -268,2 +280,3 @@ weekday: 'long',

/** @type {FormatDateOptions} */
const options = {

@@ -289,2 +302,3 @@ weekday: 'long',

const testDate = new Date('2012/05/21');
/** @type {FormatDateOptions} */
const options = {

@@ -320,2 +334,3 @@ weekday: 'long',

/** @type {FormatDateOptions} */
const options = {

@@ -322,0 +337,0 @@ weekday: 'long',

@@ -299,3 +299,3 @@ import { expect, oneEvent, aTimeout } from '@open-wc/testing';

expect(e).to.be.instanceof(Error);
expect(e.message).to.equal(
expect(/** @type {Error} */ (e).message).to.equal(
'Data for namespace "my-component" and locale "en-GB" could not be loaded. ' +

@@ -360,3 +360,3 @@ 'Make sure you have data for locale "en-GB" (and/or generic language "en").',

expect(e).to.be.instanceof(Error);
expect(e.message).to.equal(
expect(/** @type {Error} */ (e).message).to.equal(
'Data for namespace "my-component" and current locale "nl-NL" or fallback locale "en-GB" could not be loaded. ' +

@@ -363,0 +363,0 @@ 'Make sure you have data either for locale "nl-NL" (and/or generic language "nl") or for fallback "en-GB" (and/or "en").',

@@ -1,1 +0,1 @@

export type LocalizeMixinHost = typeof import("../types/LocalizeMixinTypes.js").LocalizeMixinImplementation;
export type LocalizeMixinHost = import('../types/LocalizeMixinTypes').LocalizeMixin;

@@ -1,1 +0,1 @@

export type FormatNumberPart = import("../../types/LocalizeMixinTypes.js").FormatNumberPart;
export type FormatNumberPart = import('../../types/LocalizeMixinTypes').FormatNumberPart;
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