Skip to content

Runtime helpers to be used in translations precompiled by babel-plugin-precompile-intl

Notifications You must be signed in to change notification settings

cibernox/precompile-intl-runtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Aug 9, 2023
83c7d0e · Aug 9, 2023
Oct 3, 2021
Aug 7, 2023
Aug 7, 2023
Mar 15, 2023
Feb 18, 2022
Jan 20, 2020
Oct 17, 2022
Aug 20, 2021
Aug 7, 2023
Aug 7, 2023
Aug 9, 2023
Aug 9, 2023
Aug 9, 2023
Jul 19, 2020
Jul 19, 2020

Repository files navigation

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

About

Runtime helpers to be used in translations precompiled by babel-plugin-precompile-intl

Resources

Stars

Watchers

Forks

Packages

No packages published