Directory

i18n-format - Vaadin Add-on Directory

Text Formatter with CLDR Plural rules and Gender support for I18N i18n-format - Vaadin Add-on Directory
**[ This description is mirrored from README.md at [github.com/t2ym/i18n-format](https://github.com//t2ym/i18n-format/blob/4.0.0/README.md) on 2019-05-22 ]** [![Build Status](https://travis-ci.org/t2ym/i18n-format.svg?branch=master)](https://travis-ci.org/t2ym/i18n-format) [![Coverage Status](https://coveralls.io/repos/github/t2ym/i18n-format/badge.svg?branch=master&build=39)](https://coveralls.io/github/t2ym/i18n-format?branch=master) [![npm version](https://badge.fury.io/js/i18n-format.svg)](https://badge.fury.io/js/i18n-format) [![Published on webcomponents.org](https://img.shields.io/badge/webcomponents.org-published-blue.svg)](https://www.webcomponents.org/element/t2ym/i18n-format) ## `` Text formatter with [Unicode CLDR plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules) and choices (like gender) support. [Demo](https://t2ym.github.io/i18n-format/components/i18n-format/demo/) and [API Docs](https://www.webcomponents.org/element/t2ym/i18n-format/elements/i18n-format) ### Install ``` npm install i18n-format ``` ### Import ```javascript import "i18n-format/i18n-format.js"; ``` ### Usage #### Simple Template Format ```html

{1} element is effective for UI localization with {2}. i18n-format parameters

``` This renders as follows: ```html

i18n-format element is effective for UI localization with parameters.

``` #### Compound Template Format An appropriate template in `json-data` is selected by plural categories, gender, etc. ```html

{ "0": "You ({3}) gave no gifts.", "1": { "male": "You ({3}) gave him ({4}) {5}.", "female": "You ({3}) gave her ({4}) {5}.", "other": "You ({3}) gave them ({4}) {5}." }, "one": { "male": "You ({3}) gave him ({4}) and one other person {5}.", "female": "You ({3}) gave her ({4}) and one other person {5}.", "other": "You ({3}) gave them ({4}) and one other person {5}." }, "other": "You ({3}) gave them ({4}) and {1} other people gifts." } {{recipients.length}} {{recipients.0.gender}} {{sender.name}} {{recipients.0.name}} a gift

``` With these values for the parameters, the template path `.one.female` is selected from ``. | Parameters | Values | |:--------------------|:---------| | lang | 'en' | | recipients.length | 2 | | recipients.0.gender | 'female' | | sender.name | 'James' | | recipients.0.name | 'Alice' | So this example renders as follows: ```html

You (James) gave her (Alice) and one other person a gift.

``` [``](https://www.webcomponents.org/element/t2ym/i18n-number) specifies plural categories for [CLDR plural rules](http://cldr.unicode.org/index/cldr-spec/plural-rules). ### Demo #### Prerequisite for Building and Serving Demo ```sh npm install -g polymer-cli ``` #### On-the-fly Build ```sh # Serve at http://localhost:8080/components/i18n-format/demo/ polymer serve --npm --module-resolution=node -p 8080 ``` #### Static Builds - Build ```sh polymer build ``` - Targets | target | browser | minify | bundled | |:-----:|:-------:|:------:|:-------:| |build/esm-unbundled|es6,modules|no|no| |build/esm-bundled |es6,modules|yes|yes| |build/es6-bundled |es6 |yes|yes| |build/es5-bundled |es5 |yes|yes| - Serve ```sh # Serve at http://localhost:8080/ cd build/{esm-unbundled|esm-bundled|es6-bundled|es5-bundled} python -m SimpleHTTPServer 8080 # or any HTTP(S) server ``` ### License [BSD-2-Clause](https://github.com/t2ym/i18n-format/blob/master/LICENSE.md)
View on NPM
View on GitHub
License

i18n-format version 0.1.0
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.1.2

i18n-format version 0.1.1
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.1.2

i18n-format version 0.1.2
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.1.2

i18n-format version 0.1.3
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.1.2

i18n-format version 0.1.4
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#~0.1.4

i18n-format version 0.1.5
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.2.0

i18n-format version 0.1.6
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.2.1

i18n-format version 0.1.7
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.2.1

i18n-format version 0.1.8
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.2.1

i18n-format version 0.1.9
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^0.2.4

i18n-format version 1.0.0
### Dependencies * polymer#^1.2.0 * make-plural#^3.0.3 * i18n-number#^1.0.0

i18n-format version 2.0.0
### Dependencies * polymer#Polymer/polymer#1.9 - 2 * make-plural#^3.0.3 * i18n-number#1 - 2

i18n-format version 3.0.0-pre.2
### Dependencies * @polymer/polymer#^3.0.0 * i18n-number#^3.0.0-pre.3 * make-plural#^4.3.0

i18n-format version 3.0.0-pre.3
### Dependencies

i18n-format version 3.0.0-pre.4
### Dependencies

i18n-format version 3.0.0-pre.5
### Dependencies

i18n-format version 3.0.0-pre.6
### Dependencies

i18n-format version 3.0.0-pre.7
### Dependencies

i18n-format version 3.0.0-pre.8
### Dependencies

i18n-format version 3.0.0-pre.9
### Dependencies

i18n-format version 3.0.0-pre.10
### Dependencies

i18n-format version 3.0.0-pre.11
### Dependencies

i18n-format version 3.0.0-pre.12
### Dependencies

i18n-format version 3.0.0
### Dependencies

i18n-format version 2.0.1
### Dependencies * polymer#Polymer/polymer#1.9 - 2 * make-plural#^3.0.3 * i18n-number#1 - 2

i18n-format version 3.0.1
### Dependencies

i18n-format version 4.0.0-pre.1
### Dependencies

i18n-format version 4.0.0-pre.2
### Dependencies

i18n-format version 4.0.0-pre.3
### Dependencies

i18n-format version 4.0.0-pre.4
### Dependencies

i18n-format version 4.0.0-pre.5
### Dependencies

i18n-format version 4.0.0-pre.6
### Dependencies

i18n-format version 4.0.0-pre.7
### Dependencies

i18n-format version 4.0.0-pre.8
### Dependencies

i18n-format version 4.0.0-pre.10
### Dependencies

i18n-format version 4.0.0-pre.9
### Dependencies

i18n-format version 4.0.0-pre.11
### Dependencies

i18n-format version 4.0.0-pre.12
### Dependencies

i18n-format version 4.0.0-pre.13
### Dependencies

i18n-format version 4.0.0
### Dependencies