1.8.2 • Published 6 months ago

modapp-l10n v1.8.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 months ago

view on npm

ModApp Localization

Localization utility implementing modapp's LocaleString interface, using modapp's eventBus.

Installation

With npm:

npm install modapp-l10n --save

With yarn:

yarn add modapp-l10n

Usage

import l10n from 'modapp-l10n';

// Translate a string calling l10n.t method.
alert(l10n.t('example.translateString', "Translating a string"));

// Create a localized string object by calling the l10n.l method,
// delaying the translation.
let str1 = l10n.l('example.delayedTranslation', "Using delayed translation");
// Translate the localized string object when it is time
// to render it on screen.
alert(l10n.t(str1));

// Translate a string with placeholders
alert(l10n.t('example.usingPlaceholder', "Using {count} placeholder(s)", {count: 1}));

// Create localized string object with placeholders
let str2 = l10n.l('example.morePlaceholders', "Using {count} more placeholder(s)");
// Translate the localized string object with params
alert(l10n.t(str2, {count: 2}));

// Create localized string with placeholders and default parameters
let str3 = l10n.l('example.defaultParams', "This {name} contains {count} placeholders", {name: "locale string", count: 2});
// Overriding default parameters
alert(l10n.t(str3, {name: "translation"}));

// Using variadic parameters instead of named.
alert(l10n.t('example.variadicParameters', "{0} of {1} parameters.", "An example", "variadic"));

Documentation

Markdown documentation

Disclaimer

This package is not complete, but works as a placeholder until the real implementation is finalized. Source code using this package will be prepared for localization.

Once the implementation is finished, this package will of course support loading of locales, and using the ICU Message Format for placeholders.

1.8.2

6 months ago

1.8.1

10 months ago

1.8.0

2 years ago

1.7.0

3 years ago

1.3.0

6 years ago

1.2.2

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago