Package Exports
- @phensley/cldr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@phensley/cldr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
cldr-engine
Internationalization in Typescript with Unicode CLDR, batteries included
Links
- Documentation on the library API and usage.
- CodeSandbox example can be used to experiment, report bugs, etc.
- Demonstration app provides an example using React and Redux. (source code)
Install
Install the NPM package:
npm install --save @phensley/cldrUsing Yarn:
yarn add @phensley/cldrPacakge Naming
Packages with the cldr-* prefix represent pieces of the larger library and are designed to work together. The @phensley/cldr package pulls in the full functionality of the library.
Packages without the cldr-* prefix can be used in an application individually without pulling in the larger core library.
You can use any of the packages independent of the rest of the library:
@phensley/decimal@phensley/language-tag@phensley/locale@phensley/locale-matcher@phensley/messageformat@phensley/plurals@phensley/timezone@phensley/unit-converter
Features
- Implementation folows the CLDR specification supporting CLDR version 36.0.0
- 370 modern locales
- Compact resource packs containing all scripts and regions for a given language
- Language tag parsing, locale resolution, and distance-based enhanced language matching for improved locale fallback
- Fast, compact, and extensible ICU message formatting
- Both string and parts formatting for flexible markup styling
- Date time, date interval, and relative time formatting
- Full TZDB and CLDR timezone support covering the full range of TZDB untils, resolving deprecated timezone identifiers and aliases
- Gregorian, ISO-8601, Japanese, Persian and Buddhist calendars.
- Date formatting using flexible skeleton-based pattern matching
- Date addition, date subtraction, date differencing and "field of visual difference" calculation
- Cardinal and ordinal pluralization rules
- Decimal numbers, currencies, units, and unit sequence formatting, with 157 different units
- Arbitrary precision decimal math
- Display names for languages, scripts, regions, currencies, units, calendar fields, etc
- List formatting, measurement system, character order, and line order information
- Optional Unit conversion package to convert quantities between CLDR units
Goals
- Support a broad set of CLDR features in the browser "out of the box".
- Support all scripts and regions for a language in a single compact resource pack.
- Resolve the CLDR data size and dimensionality problems.
- In the case of English: ~40MB of JSON for 105 locales is compressed to a 194KB resource pack (44KB gzip), a factor of approx. 200:1 uncompressed, 1000:1 with gzip compression.
- No additional library dependencies required.
- No custom extraction of CLDR data or precompilation of formatters required.
- Correctness and consistency across browsers and Javascript runtime environments.
- Provide type-safety, reducing programming errors.
- No familiarity with CLDR structure is required for developers to use this library.
- High performance.
- Arbitrary precision decimal math, to achieve the same accuracy in the browser as on the server.
License
Copyright 2018-present Patrick Hensley
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.Affiliation
This project is not affiliated with the Unicode Inc. or the Unicode CLDR project.