@formkit/i18n

Introduction

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.

Functions

createI18nPlugin()

Create a new internationalization plugin for FormKit.

Signature

Parameters

Returns

FormKitPlugin

date()

Given a string or a date, return a nice human-readable version.

Signature

Parameters

  • date — A string or a date.

Returns

string

list()

Creates an oxford-comma separated list of items.

Signature

Parameters

  • items — the items to list out.
  • conjunction — in the list "x, y, and z", "and" is the conjunction. Defaults to "or".

Returns

string

order()

Orders two variables from smallest to largest.

Signature

Parameters

  • first — The first number or string.
  • second — The second number or string.

Returns

[smaller: number | string, larger: number | string]

sentence()

Given a string, convert it to sentence case.

Signature

Parameters

  • str — The string to sentence case.

Returns

string

TypeScript

FormKitLocale

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.

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.

FormKitLocaleRegistry

The locale registry is just a key-value pair of locale indexes ('ar', 'en', 'it', etc.) to their respective locales.