From 072b8b7fd7b87ac05afbe80215231e447447d890 Mon Sep 17 00:00:00 2001 From: hexxa Date: Wed, 25 Aug 2021 18:47:53 +0800 Subject: [PATCH] feat(ui): add i18n support --- src/client/web/src/i18n/en_US.ts | 8 ++++++++ src/client/web/src/i18n/msger.ts | 27 +++++++++++++++++++++++++++ src/client/web/src/i18n/zh_CN.ts | 8 ++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/client/web/src/i18n/en_US.ts create mode 100644 src/client/web/src/i18n/msger.ts create mode 100644 src/client/web/src/i18n/zh_CN.ts diff --git a/src/client/web/src/i18n/en_US.ts b/src/client/web/src/i18n/en_US.ts new file mode 100644 index 0000000..033f48d --- /dev/null +++ b/src/client/web/src/i18n/en_US.ts @@ -0,0 +1,8 @@ +import { Map } from "immutable"; + +const adContent = ` +If you have any question, you can submit an issue in the github repo. But owner may be out of the office in the weekend 😎.`; + +export const msgs: Map = Map({ + "loader.top.about": "关于", +}); \ No newline at end of file diff --git a/src/client/web/src/i18n/msger.ts b/src/client/web/src/i18n/msger.ts new file mode 100644 index 0000000..9e27600 --- /dev/null +++ b/src/client/web/src/i18n/msger.ts @@ -0,0 +1,27 @@ +import { Map } from "immutable"; + +import { msgs as enMsgs } from "./en_US"; +import { msgs as cnMsgs } from "./zh_CN"; + +export class Msger { + private msgs: Map; + constructor(msgs: Map) { + this.msgs = msgs; + } + getMsg(key: string): string { + return this.msgs.get(key, ""); + } +} + +export class MsgPackage { + static getPkg(key: string): Map { + switch (key) { + case "en-US": + return Map(enMsgs); + case "zh-CN": + return Map(cnMsgs); + default: + return Map(enMsgs); + } + } +} diff --git a/src/client/web/src/i18n/zh_CN.ts b/src/client/web/src/i18n/zh_CN.ts new file mode 100644 index 0000000..94f4f29 --- /dev/null +++ b/src/client/web/src/i18n/zh_CN.ts @@ -0,0 +1,8 @@ +import { Map } from "immutable"; + +const adContent = ` +发现bug等, 可至下方github库提交issue, 不过周末可能不上班😎.`; + +export const msgs: Map = Map({ + "loader.top.about": "关于", +}); \ No newline at end of file