@tencentcloud/roomkit-web-vue3
Version:
<h1 align="center"> TUIRoomKit</h1> Conference (TUIRoomKit) is a product suitable for multi-person audio and video conversation scenarios such as business meetings, webinars, and online education. By integrating this product, you can add room management,
52 lines (51 loc) • 1.36 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { getLanguage } from "../utils/common.mjs";
import ZH from "./zh-CN.mjs";
import EN from "./en-US.mjs";
import { ref } from "vue";
const locale = ref("");
class TUIKitI18n {
constructor(options) {
__publicField(this, "messages");
__publicField(this, "global");
this.messages = options.messages;
locale.value = options.locale;
this.global = {};
this.global.locale = locale;
this.global.t = this.t.bind(this);
}
getNamed(option) {
return (key) => option[key] || key;
}
t(key, option) {
const message = this.messages[locale.value];
if (!message[key]) {
return key;
}
if (typeof message[key] === "function") {
const named = this.getNamed(option || {});
return message[key]({ named });
}
return message[key];
}
install() {
}
}
const i18n = new TUIKitI18n({
locale: getLanguage() || "zh-CN",
messages: {
"zh-CN": ZH,
"en-US": EN
}
});
function useI18n() {
return {
t: i18n.global.t.bind(i18n)
};
}
export {
i18n as default,
useI18n
};