EVA-Notify/src/plain-text/index.ts

130 lines
3.5 KiB
TypeScript

import { PageFooterText, pageFooterZhCn, pageFooterEnUs } from './PageFooter';
import { MainPageText, mainPageZhCn, mainPageEnUs } from './MainPage';
import { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
import { ReportPageText, reportPageEnUs, reportPageZhCn } from './ReportPage';
import { InformPageText, informPageZhCn, informPageEnUs } from './InformPage';
import { AboutPageText, aboutPageEnUs, aboutPageZhCn } from './AboutPage';
import { ButtonText, buttonEnUs, buttonZhCn } from './Button';
import { MemberPageText, memberPageEnUs, memberPageZhCn } from './MemberPage';
import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList';
import { NavBarTitle, navBarTitleEnUs, navBarTitleZhCn } from './NavBarTitle';
import { RepairPageText, repairPageEnUs, repairPageZhCn } from './RepairPage';
import {
TicketDetailText,
ticketDetailEnUs,
ticketDetailZhCn,
} from './TicketDetail';
import { CommonText, commonTextEnUs, commonTextZhCn } from './common';
import { TipsText, tipsEnUs, tipsZhCn } from './Tips';
import { ModalText, modalEnUs, modalZhCn } from './Modal';
import { ToastText, toastEnUs, toastZhCn } from './Toast';
import {
ActIndicatorText,
actIndicatorEnUs,
actIndicatorZhCn,
} from './ActIndicator';
import { NotFoundText, notFound } from './404';
interface TextRecord {
common: CommonText;
pageFooter: PageFooterText;
mainPage: MainPageText;
userPage: UserPageText;
tabBar: TabBarText;
reportPage: ReportPageText;
informPage: InformPageText;
aboutPage: AboutPageText;
button: ButtonText;
memberPage: MemberPageText;
ticketList: TicketListText;
navBar: NavBarTitle;
repairPage: RepairPageText;
ticketDetail: TicketDetailText;
tips: TipsText;
modal: ModalText;
toast: ToastText;
actIndicator: ActIndicatorText;
notFound: NotFoundText;
}
const textZhCn: TextRecord = {
common: commonTextZhCn,
pageFooter: pageFooterZhCn,
mainPage: mainPageZhCn,
userPage: userPageZhCn,
tabBar: tabBarZhCn,
reportPage: reportPageZhCn,
informPage: informPageZhCn,
aboutPage: aboutPageZhCn,
button: buttonZhCn,
memberPage: memberPageZhCn,
ticketList: ticketListZhCn,
navBar: navBarTitleZhCn,
repairPage: repairPageZhCn,
ticketDetail: ticketDetailZhCn,
tips: tipsZhCn,
modal: modalZhCn,
toast: toastZhCn,
actIndicator: actIndicatorZhCn,
notFound: notFound,
};
const textEnUs: TextRecord = {
common: commonTextEnUs,
pageFooter: pageFooterEnUs,
mainPage: mainPageEnUs,
userPage: userPageEnUs,
tabBar: tabBarEnUs,
reportPage: reportPageEnUs,
informPage: informPageEnUs,
aboutPage: aboutPageEnUs,
button: buttonEnUs,
memberPage: memberPageEnUs,
ticketList: ticketListEnUs,
navBar: navBarTitleEnUs,
repairPage: repairPageEnUs,
ticketDetail: ticketDetailEnUs,
tips: tipsEnUs,
modal: modalEnUs,
toast: toastEnUs,
actIndicator: actIndicatorEnUs,
notFound: notFound,
};
// type Lang = 'zh_CN' | 'en_US' | ...;
export type Lang = 'zh_CN' | 'en_US';
class PlainText {
private readonly textZhCn: TextRecord;
private readonly textEnUs: TextRecord;
private lang: Lang;
constructor() {
this.textZhCn = textZhCn;
this.textEnUs = textEnUs;
this.lang = 'zh_CN';
}
setLang(lang: Lang) {
this.lang = lang;
}
get(): TextRecord {
if (this.lang == 'zh_CN') {
return this.textZhCn;
} else if (this.lang == 'en_US') {
return this.textEnUs;
}
return this.textZhCn;
}
getCurLang(): Lang {
return this.lang;
}
}
const pt = new PlainText();
export default pt;