Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @ization/core

@ization/core

ization core that manages all plugins

Install

Install this package and other required packages:

npm install @ization/core lodash

Configure

Import the main module of this package into your app module using IzCoreModule.withLocales static method and define locales to be used by this package:

@NgModule({
  imports: [
    ...
    IzCoreModule.withLocales([
      {localeCode: 'en'},
      ...
    ]),
    ...
  ],
  ...
})
export class AppModule {}

This package does nothing interesting on its own. The actual functionality is provided by plugins. See their docs for more info.

Use

IzCoreService Service

This service handles locales and their preference. Supported locales are sorted in this way:

  1. User's preferred locale – User can have one locale configured to be the most preferred
  2. Locales preferred by user's browser
  3. Other supported locales

getPreferredLocaleCode() method

Returns locale code of user's preferred locale or undefined if none is selected.

preferLocaleCode(localeCode) method

Sets locale code as user's preferred locale and saves it for future use.

clearLocaleCodePreference() method

Clears any saved user's preferred locale.

getLocalePreferenceChanged() method

Returns an Observable that emits (with no value) each time user's preference changes.

getLocaleCodesInOrderOfPreference() method

Returns an Observable that emits an array of locale codes each time user's preference changes.

getLocaleDefinitionsInOrderOfPreference() method

Returns an Observable that emits an array of locale definitions, including any plugin overrides, each time user's preference changes.

Develop

Build

Run npm run build:core to build the package into the dist/core/ directory.

Unit tests

Run npm run test:core to execute the unit tests.

Linter

Run npm run lint:core to run linter on all code, including spec files.

Index

Injection Tokens

IzLocaleDefinitions

IzLocaleDefinitions: IzLocaleDefinition[]

Type for injection token that is used to provide locale configuration for this module and its plugins

IzPluginLinks

IzPluginLinks: IzPluginLink[]

Type for injection token used by plugins to subscribe to this module via IzPluginLink

IzLocaleDefinitions

IzLocaleDefinitions: InjectionToken<IzLocaleDefinitions>

Injection token that is used to provide locale configuration for this module and its plugins

IzPluginLinks

IzPluginLinks: InjectionToken<IzPluginLinks>

Injection token used by plugins to subscribe to this module via IzPluginLink

This token is used for a multiprovider so it must be used with multi: true.

Other

Flavored

Flavored<T, F>: T & { _type?: F }

Wrapper for primitives to be able to distinguish between two different purposes

Type parameters

  • T

  • F: string

IzLocaleCode

IzLocaleCode: Flavored<string, "IzLocaleCode">

Locale code

todo

Add support for Intl.Locale as well after https://github.com/microsoft/TypeScript/issues/37326 gets resolved.

Generated using TypeDoc