Socket
Socket
Sign inDemoInstall

@lion/localize

Package Overview
Dependencies
7
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @lion/localize

The localization system helps to manage localization data split into locales and automate its loading


Version published
Weekly downloads
4.6K
increased by51.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Systems >> Localize >> Overview ||10

Is meant to translate text into multiple languages. In it's simplest form it is a function that returns the translated text for a namespace + key.

Features

  • Uses es modules
  • Formatting of numbers, amounts
  • Formatting of dates

Further examples and a more in depth description can be found at the Features Page.

Content

FeatureDescription
Translate TextLoad and translate text in multiple languages
Format NumbersFormat numbers in multiple languages
Format DatesFormat dates in multiple languages

Installation

npm i --save @lion/localize
import { localize } from '@lion/localize';

Example

The locale which will be loaded by default is accessed via the localize.locale.

The single source of truth for page's locale is <html lang="my-LOCALE">. At the same time the interaction should happen via localize.locale getter/setter to be able to notify and react to the change.

import { localize } from '@lion/localize.js';

localize.addEventListener('localeChanged', () => {
  // do smth when data is loaded for a new locale
});

// changes locale, syncs to `<html lang="es-ES">` and fires the event above
localize.locale = 'es-ES';

Keywords

FAQs

Last updated on 09 May 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc