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, informtPageEnUs } from './InformPage'; import { AboutPageText, aboutPageEnUs, aboutPageZhCn } from './AboutPage'; import { TicketListText, ticketListEnUs, ticketListZhCn } from './TicketList'; interface TextRecord { pageFooter: PageFooterText; mainPage: MainPageText; userPage: UserPageText; tabBar: TabBarText; reportPage: ReportPageText; informPage: InformPageText; aboutPage: AboutPageText; ticketList: TicketListText; } const textZhCn: TextRecord = { pageFooter: pageFooterZhCn, mainPage: mainPageZhCn, userPage: userPageZhCn, tabBar: tabBarZhCn, reportPage: reportPageZhCn, informPage: informPageZhCn, aboutPage: aboutPageZhCn, ticketList: ticketListZhCn, }; const textEnUs: TextRecord = { pageFooter: pageFooterEnUs, mainPage: mainPageEnUs, userPage: userPageEnUs, tabBar: tabBarEnUs, reportPage: reportPageEnUs, informPage: informtPageEnUs, aboutPage: aboutPageEnUs, ticketList: ticketListEnUs, }; // 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;