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?

RegleをVue I18nでi18n対応する

0
Last updated at Posted at 2026-12-04

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

Regle

Vuelidateの後継

機能

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

ルール毎に関数を用意しています。

インストール

pnpm i @regle-rules/i18n

ロケール・ファイル

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

言語 エラー・メッセージ
英語 Regleのデフォルトそのまま
日本語 適当な訳文を用意

実装例

import { defineRegleConfig } from '@regle/core'
import { useI18n } from 'vue-i18n'

import { required } from '@regle-rules/i18n'

export const { useRegle: useRegleI18n } = defineRegleConfig({
  rules: () => {
    const i18n = useI18n()
    return {
      required: required(i18n),
    }
  },
})

useRegleをuseRegleI18nに置き換えます。

実装プロジェクト

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?