0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ValibotをVue I18nでi18n対応する

0
Last updated at Posted at 2026-12-04

Valibot のビルトイン・アクションetcのエラー・メッセージを汎用的にi18n対応するために、ライブラリを作ったので、紹介します。

Valibot

機能

Vue I18nを利用してi18n対応しています。

アクションetc毎の関数と設定用コンポーザブルを用意しています。

インストール

pnpm i @valibot-i18n/vue

ロケール・ファイル

現在、日本語と英語に対応、JS/TSとJSONで用意しています。

言語 エラー・メッセージ
英語 適当な英文を用意
日本語 適当な訳文を用意

実装例

import { useI18n } from 'vue-i18n'

import { useValibotConfig } from '@valibot-i18n/vue'
import { maxLength, schemaMessage } from '@valibot-i18n/vue'

export const useValibotI18n = () => {
  const i18n = useI18n()
  const { locale } = i18n

  const { setup } = useValibotConfig({ lang: locale.value })

  setup(() => {
    schemaMessage(i18n)
    maxLength(i18n)
  })
}
import { useValibotConfig } from '...'

useValibotConfig()

実装プロジェクト

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?