2.0.1 • Published 4 years ago

f-locale v2.0.1

Weekly downloads
89
License
MIT
Repository
github
Last release
4 years ago

f-locale

Localization helper for f-promise

f-locale is a companion package for f-promise. It provides a small helper to manage localized messages.

Installation

npm install --save f-locale

Usage

Resources must be placed in JSON files inside a resources subdirectory of the current directory:

source-folder/
    resources/
        module1-en.json
        module1-fr.json
        ...
        module2-en.json
        module2-fr.json
        ...
    module1.ts
    module2.ts

The JSON files contain a simple object hash:

{
    "simple": "a simple message",
    "complex": "a more complex message with {{0}} and {{1}} args"
}

f-locale uses handlebars formatting directives.

Basic usage:

import { locale } from 'f-locale';
const resources = locale.resources(module);

// setting the locale
locale.current = 'fr';
// loading a simple message
console.log(resources.message('simple'));
// formating a parameterized message
cconsole.log(resources.format('complex', 'hello', 5));

License

MIT.

2.0.1

4 years ago

2.0.0

5 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago