@hua-labs/i18n-formatters
v2.0.5
Published
HUA Labs - Date, Number, and Currency formatting utilities for i18n
Downloads
908
Maintainers
Readme
@hua-labs/i18n-formatters
Locale-aware formatting utilities that integrate with @hua-labs/i18n-core. Provides React hooks and standalone functions for dates, numbers, and currencies with full Korean/English/Japanese support.
Features
- Date formatting — Custom patterns, relative time, timezone support
- Number formatting — Locale-aware grouping, compact notation (1K, 1M), percentages
- Currency formatting — Symbol positioning, decimal control, 6 currencies (KRW, USD, EUR, GBP, JPY, CNY)
- React hooks — useDateFormatter, useNumberFormatter, useCurrencyFormatter
- Tree-shakeable — Subpath exports for date, number, currency independently
Installation
pnpm add @hua-labs/i18n-formattersPeer dependencies: react >=19.0.0
Quick Start
import { useDateFormatter } from '@hua-labs/i18n-formatters/date';
import { useCurrencyFormatter } from '@hua-labs/i18n-formatters/currency';
function PriceCard({ date, amount }: { date: Date; amount: number }) {
const { formatRelativeTime } = useDateFormatter();
const { formatCurrency } = useCurrencyFormatter();
return (
<div>
<span>{formatRelativeTime(date)}</span>
<span>{formatCurrency(amount)}</span>
</div>
);
}
API
| Export | Type | Description |
|--------|------|-------------|
| useDateFormatter | hook | Date formatting hook — formatDate, formatRelativeTime, monthNames, dayNames |
| formatDate | function | |
| formatDateTime | function | |
| formatRelativeTime | function | |
| applyTimezoneOffset | function | |
| getKoreanDate | function | |
| getKoreanDateString | function | |
| parseDateAsTimezone | function | |
| convertToTimezone | function | |
| KST_OFFSET | component | |
| useNumberFormatter | hook | Number formatting hook — formatNumber, formatPercent, formatCompact |
| formatNumber | function | |
| formatCompact | function | |
| formatPercent | function | |
| useCurrencyFormatter | hook | Currency formatting hook — formatCurrency with 6 currency support |
| formatCurrency | function | |
| getDefaultCurrency | function | |
| getCurrencyDecimals | function | |
| LANGUAGE_TO_CURRENCY | component | |
| CURRENCY_DECIMALS | component | |
| DateFormatterOptions | type | |
| TimezoneConfig | type | |
| RelativeTimeOptions | type | |
| DateFormatterReturn | type | |
| NumberFormatterOptions | type | |
| PercentFormatterOptions | type | |
| NumberFormatterReturn | type | |
| CurrencyFormatterOptions | type | |
| CurrencyFormatterReturn | type | |
Documentation
Related Packages
License
MIT — HUA Labs
