Skip to content

Ability for custom i18n language moduleΒ #1386

@hyunbinseo

Description

@hyunbinseo

I would like to customize the Current KR (soon to be KO) i18n completely.

However, there doesn't seem to be a way provide a custom language translation.

import * as v from 'valibot';

// Import every translation for a specific language
import '@valibot/i18n/kr'; // since I don't want this

v.setGlobalConfig({ lang: 'kr' }); // I am setting kr as the global

// and setting specific error messages in the Language type
v.setSpecificMessage(v.minLength, (issue) => `Invalid length: ...`, 'en');

Is there a way for me to achieve this? A workaround would be fine.

You can use an objects or arrays to define your translations and then use JS code to dynamically call setSpecificMessage but this might break tree shaking.

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions