expo-intl-formatter
v0.1.1
Published
A simple wrapper around the Intl API to format dates, numbers and currencies in Expo projects.
Maintainers
Readme
Expo Intl Formatter
This repository provides utility functions to format numbers into compact representations (e.g., "1.2k", "1,2 k") based on a specified language code. It supports dynamically selecting the appropriate locale for the provided language code and allows customization of the maximum number of fractional digits displayed.
Features
- Format numbers in a compact style (e.g., 1234.567 becomes "1.2k" or "1,2 k").
- Dynamically determine the locale from a language code (e.g., "fr" maps to French locales like "fr_FR").
- Customize the maximum number of fractional digits.
- Fallback to
en_USif the language code is not recognized.
Functions
formatNumber(number: number, languageCode: string): string
Description: Formats a number into a compact style representation using the specified language code and maximum fractional digits.
Parameters:
number: Thenumbervalue to be formatted.languageCode: Astringrepresenting the language code (e.g., "en" for English, "fr" for French).
Returns:
- A
stringrepresenting the compactly formatted number in the appropriate locale.
