<template>
  <el-dropdown class="international" @command="handleSetLanguage"  placement="left-start">
    <span style="color:#606266;">{{$t('ht.selectLang.switchLang')}}</span>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item :disabled="$i18n.locale==='zh-CN'" command="zh-CN">中文</el-dropdown-item>
      <el-dropdown-item :disabled="$i18n.locale==='zh-TW'" command="zh-TW">中文繁体</el-dropdown-item>
      <el-dropdown-item :disabled="$i18n.locale==='en-US'" command="en-US">English</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
</template>

<script>
export default {
  name:"lang-select",
  computed: {
    language() {
      return localStorage.getItem("lang")||"zh-CN"
    }
  },
  methods: {
    handleSetLanguage(lang) {
      this.$i18n.locale = lang
      this.$validator.locale = lang

      localStorage.setItem("lang",lang)
      this.$message({
        message: '切换成功',
        type: 'success'
      })
      
    }
  }
}
</script>