Merge branch 'master' of http://git.luyuan.tk/luyuan/beelink into zj

This commit is contained in:
asd
2020-10-19 15:59:53 +08:00
5 changed files with 296 additions and 166 deletions

View File

@@ -10,9 +10,12 @@ import { defineComponent } from 'vue';
import router from './router';
import store from './store';
import { getValue } from './utils/common';
import { provideI18n } from "@/utils/i18n"
import i18ninit from "@/i18n/init"
export default defineComponent({
setup(){
provideI18n(i18ninit);
if(getValue('token')){
store.commit("login", true)
store.dispatch("setUserInfo");

9
src/i18n/init.ts Normal file
View File

@@ -0,0 +1,9 @@
import zh from "./zh"
export default {
locale: "zh", //默认语言
messages:{
zh
}
}

28
src/i18n/zh.ts Normal file
View File

@@ -0,0 +1,28 @@
export default {
zhiboguanli: "直播管理",
shipinguanli: "视频管理",
dingyuezheguanli: "订阅者管理",
gerenzhongxin: "个人中心",
rili: "日历",
quanbuzhibo: "全部直播",
weikaishi: "未开始",
yijieshu: "已结束",
zhibosousuo: "请输入想要搜索的直播标题",
haiweikaishi: "还未开始",
yijueshi: "已结束",
jinruzhibo: "进入直播",
quanbushipin: "全部视频",
shenhezhong: "审核中",
weitongguo: "未通过",
yifabu: "已发布",
shipinsousuo: "请输入想要搜索的直播标题",
wodedingyuezhe: "我的订阅者",
xingming: "姓名",
suozaiguojia: "所在国家",
nianling: "年龄",
xueshengmuyu: "学生母语",
xingqudian: "兴趣点",
yuyandengji: "语言等级",
canyupingtaishichang: "参与平台直播总时长",
sousuoxuesheng: "请输入想要搜索的学生姓名"
}

35
src/utils/i18n.ts Normal file
View File

@@ -0,0 +1,35 @@
import { inject, provide, ref } from 'vue';
interface Language {
[key :string]: string
}
interface Config {
locale: string;
messages: {[key: string]: Language}
}
const createI18n = (config: Config) => ({
locale: ref(config.locale),
messages: config.messages,
$t(key: string) {
return this.messages[this.locale.value][key];
},
$s(){
return this.locale.value
}
});
const i18nSymbol = Symbol();
export function provideI18n(i18nConfig: Config) {
const i18n = createI18n(i18nConfig);
provide(i18nSymbol, i18n);
}
export function useI18n() {
const i18n = inject(i18nSymbol);
if (!i18n) throw new Error("No i18n provided!!!");
return i18n;
}