Skip to content

Commit f93394b

Browse files
authored
docs(used): zh/en language switch support (#3720)
1 parent 85c4d6f commit f93394b

1 file changed

Lines changed: 43 additions & 12 deletions

File tree

site/pages/used.vue

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
<td-doc-content ref="tdDocContent" platform="mobile" page-status="hidden">
33
<td-doc-header platform="mobile" slot="doc-header" ref="tdDocHeader"></td-doc-header>
44
<div class="content">
5-
<h3>上线项目案例</h3>
6-
<p>目前已上线 400+ 个小程序,部分小程序二维码如下。如果你也在使用 TDesign 搭建你的小程序,也欢迎添加你的项目: <a
7-
href="https://github.com/Tencent/tdesign-miniprogram/discussions/1094" target="_blank">添加项目</a></p>
5+
<h3>{{ $t('subtitle') }}</h3>
6+
<p>
7+
{{ $t('desc') }}
8+
<a href="https://github.com/Tencent/tdesign-miniprogram/discussions/1094" target="_blank">{{ $t('addBtn') }}</a>
9+
</p>
810

911
<div class="projects">
1012
<div v-for="p in projects" :key="p.name" class="card">
@@ -14,15 +16,15 @@
1416
<template v-else>{{ p.name }}</template>
1517
</div>
1618
<ul class="card__tags">
17-
<li class="card__tag" v-for="t in p.tags">{{ t }}</li>
19+
<li class="card__tag" v-for="t in p.tags" :key="t">{{ t }}</li>
1820
</ul>
1921
</div>
2022
<div class="card__imgs">
2123
<div class="card__preview">
22-
<img :src="p.preview[0]" :alt="p.name + '预览图'">
24+
<img :src="p.preview[0]" :alt="p.name + 'preview'" />
2325
</div>
2426
<div class="card__qrcode">
25-
<img :src="p.qrcode" :alt="p.name + '二维码'">
27+
<img :src="p.qrcode" :alt="p.name + 'qrcode'" />
2628
</div>
2729
</div>
2830
</div>
@@ -32,25 +34,54 @@
3234
</template>
3335

3436
<script lang="ts">
35-
import projects from '../data/projects'
37+
import projects from '../data/projects';
38+
39+
const docs = {
40+
zh: {
41+
title: '谁在用',
42+
subtitle: '上线项目案例',
43+
desc: '目前已上线 400+ 个小程序,部分小程序二维码如下。如果你也在使用 TDesign 搭建你的小程序,也欢迎添加你的项目:',
44+
addBtn: '添加项目',
45+
},
46+
en: {
47+
title: 'USED',
48+
subtitle: 'Online cases',
49+
desc: 'Currently, more than 400 mini-programs have been launched. The QR codes of some mini-programs are as follows. If you are also using TDesign to build your mini-program, you are also welcome to add your project.',
50+
addBtn: 'Add',
51+
},
52+
};
3653
3754
export default {
3855
data() {
3956
return {
4057
projects,
41-
}
58+
};
4259
},
60+
61+
computed: {
62+
currentLang() {
63+
return this.$route?.meta?.lang || 'zh'; // 默认中文
64+
},
65+
},
66+
67+
methods: {
68+
$t(key: string) {
69+
return docs[this.currentLang][key];
70+
},
71+
},
72+
4373
mounted() {
4474
const { tdDocContent, tdDocHeader, tdDocTabs } = this.$refs;
4575
4676
this.$emit('loaded', () => {
4777
tdDocHeader.docInfo = {
48-
title: '谁在用', desc: ''
49-
}
78+
title: this.$t('title'),
79+
desc: '',
80+
};
5081
tdDocContent.pageStatus = 'show';
5182
});
52-
}
53-
}
83+
},
84+
};
5485
</script>
5586

5687
<style lang="less" scoped>

0 commit comments

Comments
 (0)