The official FormKit internationalization (i18n) plugin. This package contains the locales and the plugin that integrates FormKit with these locales. Read the internationalization documentation for usage instructions.
Create a new internationalization plugin for FormKit.
createI18nPlugin(registry: FormKitLocaleRegistry): FormKitPlugin;
registry
— The registry of FormKitLocales.Given a string or a date, return a nice human-readable version.
date(date: string | Date): string;
date
— A string or a date.string
Creates an oxford-comma separated list of items.
list(items: string[], conjunction?: string): string;
items
— the items to list out.conjunction
optional — in the list "x, y, and z", "and" is the conjunction. Defaults to "or".string
Orders two variables from smallest to largest.
order(first: string | number, second: string | number): [smaller: number | string, larger: number | string];
first
— The first number or string.second
— The second number or string.[smaller: number | string, larger: number | string]
Given a string, convert it to sentence case.
sentence(str: string): string;
str
— The string to sentence case.string
A locale is just a collection of locale message registries, they are keyed by the type (like a namespace) ex: "validation" or "ui". Plugin authors can declare their own types too.
interface FormKitLocale {
[index: string]: FormKitLocaleMessages;
ui: FormKitLocaleMessages;
}
A registry of locale messages — this is simply a keyed/value object with string keys (message name) and either string values (for simple returns) or functions that receive a context object.
interface FormKitLocaleMessages {
[index: string]: string | ((...args: any[]) => string);
}
The locale registry is just a key-value pair of locale indexes ('ar', 'en', 'it', etc.) to their respective locales.
interface FormKitLocaleRegistry {
[index: string]: FormKitLocale;
}