Locale demo

Localization

English stays in the main bundle. Other messages are opt-in JSON or inline objects passed during initialization.

Back to demo gallery

Try it

Submit each empty form. Then enter an invalid email address and submit again to compare rule messages.

English default

No locale option is configured, so bundled English fallback text is used.

Imported JSON

The Spanish pack is imported from ./dist/locales/es.json and registered as es.

Inline messages

A small product-specific locale object is passed directly in the initialization options.

Developer notes

Locale lookup checks the explicit option first, then form or document language, then English. Field data messages and field-level message options still win over locale packs.

Imported JSON

import esMessages from "./dist/locales/es.json" with { type: "json" };

createFormValidator(form, {
  ...createDefaultPreset(),
  locale: "es",
  locales: { es: esMessages }
});

Inline JSON

createFormValidator(form, {
  ...createDefaultPreset(),
  locale: "product",
  locales: {
    product: {
      required: "{fieldLabel} is required.",
      email: "Use a valid work email address."
    }
  }
});