Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cibernox/precompile-intl-runtime
Runtime helpers to be used in translations precompiled by babel-plugin-precompile-intl
https://github.com/cibernox/precompile-intl-runtime
Last synced: about 2 months ago
JSON representation
Runtime helpers to be used in translations precompiled by babel-plugin-precompile-intl
- Host: GitHub
- URL: https://github.com/cibernox/precompile-intl-runtime
- Owner: cibernox
- Created: 2020-01-20T18:38:45.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-01T13:11:05.000Z (11 months ago)
- Last Synced: 2024-10-18T07:58:16.655Z (3 months ago)
- Language: TypeScript
- Size: 760 KB
- Stars: 12
- Watchers: 3
- Forks: 15
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: Changelog.md
Awesome Lists containing this project
README
# precompile-intl-runtime
This library is a framework-agnostic internationalization library that leverages the [Intl](https
API available in all modern browsers and in Node.js for pluralization and formatting numbers, dates and times.It is designed with a granular functional API that can easily be treeshaken by module bundlers. If your app doesn't format
dates or numbers, or use plurals with offsets, it won't include the code for those features.And even if you use every single feature, the payload of the entire library is less than 2kb after minification and compression.
### Precompilation
Although this library can be used on its own to localize numbers, dates and times, it is very likely that you
want to have internationalized texts in your app.This library **does not** handle message formatting, instead it pairs with [babel-plugin-precompile-intl](https
a babel plugin that compiles messages in the [ICU message format](https
is the defacto standard for internalization and has implementations in almost every programming language, to super fast functions that use
the functions in this package for the runtime part.### Installation
Just run `npm install --save-dev precompile-intl-runtime` and make sure your bundler (like rollup, webpack or parcel) can import
functions from it.### Public API
WIP
- `init`
- `locale`
- `dictionary`
- `locales`
- `addMessages`
- `format`, `t`, `_`
- `formatDate`
- `formatNumber`
- `formatTime`
- `json`
- `getDateFormatter`
- `getNumberFormatter`
- `getTimeFormatter`