locale-utils
v0.1.0
Published
A lightweight utility for handling locales and common formatting tasks.
Maintainers
Readme
locale-utils
A lightweight utility for handling locales and common formatting tasks.
locale-utils provides a small set of helpers for normalizing locale identifiers and formatting numbers, currency, and dates using the built-in Intl APIs.
Why this project exists
Locale handling is a small but recurring source of inconsistency in applications.
One part of a system may expect canonical locale values. Another may need currency formatting. A third may need date formatting for display.
This package provides a minimal, consistent utility layer for common locale-related tasks without introducing a full internationalization framework.
What is included
- Locale normalization.
- Locale part extraction.
- Number formatting.
- Currency formatting.
- Date formatting.
- Supported locale checks.
Install
npm install locale-utilsExample
import {
normalizeLocale,
formatNumber,
formatCurrency,
formatDate
} from 'locale-utils';
const locale = normalizeLocale('en-ca');
const number = formatNumber(1234567.89, locale);
const price = formatCurrency(19.99, locale, 'CAD');
const date = formatDate('2026-03-28T12:00:00Z', locale, {
dateStyle: 'long'
});
console.log({ locale, number, price, date });Design Principles
This project is intentionally minimal.
It focuses on a narrow set of locale and formatting helpers that can be reused across applications. It does not attempt to replace full i18n libraries or translation systems.
License
MIT
