Skip to content

国际化

Tu View Plus 组件默认使用英文,如果你希望使用其他语言,你可以参考下面的方案。

全局配置

Tu view Plus 提供了全局配置国际化的配置。

typescript
import TuViewPlus from 'tu-view-plus'
import { enUs } from 'tu-view-plus/locale/index.mjs';

app.use(TuViewPlus, {
  locale: enUs,
})
import TuViewPlus from 'tu-view-plus'
import { enUs } from 'tu-view-plus/locale/index.mjs';

app.use(TuViewPlus, {
  locale: enUs,
})

组件配置

Tu View Plus 还提供了一个 Vue 组件 ConfigProvider 用于全局配置国际化的设置。

html
<template>
  <tu-config-provider :locale="locale">
    <app />
  </tu-config-provider>
</template>

<script>
  import { defineComponent } from 'vue'
  import { TuConfigProvider } from 'tu-view-plus'
  import { enUs } from 'tu-view-plus/locale/index.mjs';

  export default defineComponent({
    components: {
      TuConfigProvider,
    },
    setup() {
      return {
        locale: enUs,
      }
    },
  })
</script>
<template>
  <tu-config-provider :locale="locale">
    <app />
  </tu-config-provider>
</template>

<script>
  import { defineComponent } from 'vue'
  import { TuConfigProvider } from 'tu-view-plus'
  import { enUs } from 'tu-view-plus/locale/index.mjs';

  export default defineComponent({
    components: {
      TuConfigProvider,
    },
    setup() {
      return {
        locale: enUs,
      }
    },
  })
</script>