Skip to content

Internationalization

Validation messages and the SweetAlert2 confirm button come from dictionaries bundled in the library. formsub picks a dictionary from <html lang="...">, then falls back to English.

html
<html lang="en">
<html lang="sr">

Built-in English keys

KeyDefault
invalid_emailInvalid email address
required_fieldThis field is required
okOK

Add a language

Extend src/strings.json in this repository and rebuild:

json
{
  "en": {
    "invalid_email": "Invalid email address",
    "required_field": "This field is required",
    "ok": "OK"
  },
  "sr": {
    "invalid_email": "Neispravna email adresa",
    "required_field": "Ovo polje je obavezno",
    "ok": "U redu"
  }
}

There is no runtime API to pass custom strings from newForm. New languages ship with the library build.

Server messages

formsub does not translate response.message or server errors. Return copy in the user’s language from your API (Accept-Language, a locale field, etc.).

Math captcha (“Invalid captcha”) and network-error fallbacks are English-only today.

Released under the MIT License.