UNPKG

@nanostores/i18n

Version:

A tiny (≈600 bytes) i18n library for React/Preact/Vue/Svelte

18 lines (16 loc) 450 B
import { computed } from 'nanostores' export function formatter(locale) { return computed(locale, code => { return { number(num, opts) { return new Intl.NumberFormat(code, opts).format(num) }, relativeTime(num, unit, opts) { return new Intl.RelativeTimeFormat(code, opts).format(num, unit) }, time(date, opts) { return new Intl.DateTimeFormat(code, opts).format(date) } } }) }