UNPKG

@inlang/paraglide-js

Version:

[![Inlang-ecosystem compatibility badge](https://cdn.jsdelivr.net/gh/opral/monorepo@main/inlang/assets/md-badges/inlang.svg)](https://inlang.com)

45 lines (42 loc) 1.2 kB
/** * Re: CUSTOMIZING THE REGISTRY * * We want to enable anyone (designer, developer, translator) to * specify options for functions. That requires design work in * the inlang SDK. * * For now, Paraglide ships a custom solution with INTL functions. */ /** * Creates the Registry file */ export function createRegistry() { return ` /** * @param {import("./runtime.js").Locale} locale * @param {unknown} input * @param {Intl.PluralRulesOptions} [options] * @returns {string} */ export function plural(locale, input, options) { return new Intl.PluralRules(locale, options).select(Number(input)) }; /** * @param {import("./runtime.js").Locale} locale * @param {unknown} input * @param {Intl.NumberFormatOptions} [options] * @returns {string} */ export function number(locale, input, options) { return new Intl.NumberFormat(locale, options).format(Number(input)) }; /** * @param {import("./runtime.js").Locale} locale * @param {unknown} input * @param {Intl.DateTimeFormatOptions} [options] * @returns {string} */ export function datetime(locale, input, options) { return new Intl.DateTimeFormat(locale, options).format(new Date(/** @type {string} */ (input))) };`; }