LoginSignup
9
6

More than 5 years have passed since last update.

ElementUIを日本語で使う方法をまとめてみた.

Last updated at Posted at 2018-12-07

この記事では.

最近vueでお仕事をしていて,コンポーネントライブラリ?にElementUIも使っています.
基本的に日本語にする方法はググればでるけど,オンデマンドな場合(ボタンのみ読み込む場合)は見つからなかったからまとめておく.

ElementUI

多分中国製のライブラリ,デフォルトが中国語だから..
詳しくは↓
http://element.eleme.io/#/en-US

日本語にする方法

全て読み込む場合
import Vue from 'vue'
import ElementUI from 'element-ui'
import locale from 'element-ui/lib/locale/lang/ja'

Vue.use(ElementUI, { locale })

こいつは調べると結構でてくる.

とある日異変が..

pullしていろいろテストしてたら,テーブルのデータ無し時.???なんて読むの???
image.png
とりあえず,gitLogをたどると軽量化のためにオンデマンドな読み込みに変わっていた.

オンデマンドで読み込む場合
import Vue from 'vue'
import {Table, TableColumn} from 'element-ui'
import locale from 'element-ui/lib/locale/lang/ja'

Vue.use(Table, { locale })
Vue.use(TableColumn, { locale })

元の記載に沿って上記のようになっていた.
公式docを読むとポイ記載があったので書き直すと動いた.

正解
import Vue from 'vue'
import { Button, TableColumn} from 'element-ui'
import lang from 'element-ui/lib/locale/lang/ja'
import locale from 'element-ui/lib/locale'

// configure language
locale.use(lang)

// import components
Vue.use(Table)
Vue.use(TableColumn)

詳しくは↓
http://element.eleme.io/#/en-US/component/i18n#internationalization

9
6
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
9
6