Function: loadValidationMessages()
loadValidationMessages(
language):Promise<Record<string,string> |undefined>
Load the built-in validation error messages of a language, the ones of its closest built-in language (builtInValidationLanguage()). They are loaded on demand, so an application only loads the languages it uses; they are not registered: pass them to registerValidationMessages().
Parameters
language
string
A language tag, like fr or zh-Hant.
Returns
Promise<Record<string, string> | undefined>
A copy of the message templates by error code (for en, the default messages), or undefined for a language without built-in messages.
Example
typescript
import {loadValidationMessages, registerValidationMessages} from 'lakutata'
for (const language of ['fr', 'zh-CN']) {
const messages: Record<string, string> | undefined = await loadValidationMessages(language)
if (messages) registerValidationMessages(language, messages)
}