Blame view

src/views/demo/feat/i18n/index.vue 1023 Bytes
陈文彬 authored
1
2
3
4
5
6
<template>
  <div class="p-4">
    <Alert message="国际化方式,没有进行全局国际化,有需要可以自行处理。" type="info" />
    <Divider />
    国际化信息: {{ t('hello') }}
    <Divider />
vben authored
7
    <a-button :type="localeRef === 'zhCN' ? 'primary' : 'default'" @click="localeRef = 'zhCN'">
陈文彬 authored
8
9
      中文
    </a-button>
vben authored
10
    <a-button :type="localeRef === 'en' ? 'primary' : 'default'" @click="localeRef = 'en'">
陈文彬 authored
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
      英文
    </a-button>
    <Divider />
  </div>
</template>
<script lang="ts">
  import { defineComponent } from 'vue';
  import { Alert, Divider } from 'ant-design-vue';

  import { useI18n } from '/@/hooks/web/useI18n';
  export default defineComponent({
    components: { Alert, Divider },
    setup() {
      const { t, localeRef } = useI18n({
        locale: 'zhCN',
        messages: {
          en: {
            hello: 'hello',
          },
          zhCN: {
            hello: '你好',
          },
        },
      });
      return { localeRef, t };
    },
  });
</script>