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

akili-localization

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akili-localization

Localiztion service for Akili framework

  • 1.2.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

akili-localization npm version

Localization service for Akili framework.

Example

import Akili from 'akili';
import localization from 'akili-localization';

const dictionaryEN = {
  hello: "world",
  languages: {
    en: "english",
    ru: "russian"
  },
  how: "from %% to %%",
  when "at {{ time }} o'clock"
};

const dictionaryRU = {
  hello: "привет"
};

localization.define({
  defaultLocale: "en",
  currentLocale: "ru"
});

localization.addDict("en-US", dictionaryEN);
localization.addDict("ru", dictionaryRU);

document.addEventListener('DOMContentLoaded', () => {
  Akili.init().catch((err) => console.error(err));
});
<div>${ translate('hello') }</div>
<div>${ translate('languages.en') }</div>
<div>${ translate('how', [1, 10]) }</div>
<div>${ translate('when', { time: 5 }) }</div>
<div>${ date(new Date('1995-12-17T03:24:00')) }</div>
<div>${ currency(1250000.99, 'USD') }</div>
<div>${ number(1250000.99) }</div>

After the compilation:

<div>привет</div>
<div>english</div>
<div>from 1 to 10<div>
<div>at 5 o'clock</div>
<div>17.12.1995</div>
<div>1 250 000,99 $</div>
<div>1 250 000,99</div>

You can change the default or current locale any time you want and all expressions in templates will be updated.
The service based on localizationjs.

.define() method take localizationjs options, create an instance of the library class and put it on locale property in the service object. In addition, the service has all the same methods as localizationjs.

localization.setDefaultLocale('es');
localization.setCurrentLocale('fr');
localization.hasTranslation('hello');

// ...

If you load the component as a script, you will have Akili.services.localization to get it.

Keywords

FAQs

Package last updated on 05 Feb 2022

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc