Internationalization (i18n)
robust-validator
supports 66 languages in error messages.
Setting locales
You should import languages that you plan to support like the following example.
ts
import { validate, setLocales, en, fr, de } from "robust-validator";
setLocales([en, fr, de]);
Default language
You can decide default language selection.
ts
import { validate, setLocales, setOptions, en } from "robust-validator";
setLocales(en);
// Setting the default language
setOptions({
language: "en",
});
Active language
You can override the active language by users' selection for every data validation.
ts
await validate(data, { email: "required" }, { language: "de" });
Supported Languages
Code (ISO 639-1) | Language Name |
---|---|
ar | Arabic |
az | Azerbaijani |
be | Belarusian |
bg | Bulgarian |
bs | Bosnian |
ca | Catalan |
cs | Czech |
cy | Welsh |
da | Danish |
de | German |
el | Greek |
en | English |
es | Spanish |
et | Estonian |
eu | Basque |
fa | Persian |
fi | Finnish |
fr | French |
hr | Croatian |
hu | Hungarian |
id | Indonesian |
it | Italian |
ja | Japanese |
ka | Georgian |
ko | Korean |
li | Limburgish |
lt | Lithuanian |
lv | Latvian |
mk | Macedonian |
mn | Mongolian |
ms | Malay |
no | Norwegian |
nl | Dutch |
pl | Polish |
pt | Portuguese |
ro | Romanian |
ru | Russian |
se | Northern Sami |
sl | Slovenian |
sq | Albanian |
sr | Serbian |
sv | Swedish |
tr | Turkish |
uk | Ukrainian |
vi | Vietnamese |
zh | Chinese |