add localization for tab-bar
parent
6cbd6685bc
commit
d995c6ed43
|
|
@ -3,19 +3,20 @@ import { AtTabBar } from 'taro-ui';
|
|||
import Taro from '@tarojs/taro';
|
||||
import 'taro-ui/dist/style/index.scss';
|
||||
import './index.scss';
|
||||
import pt from '@/plain-text';
|
||||
|
||||
const navList: Array<Taro.TabBarItem> = [
|
||||
{
|
||||
pagePath: '/pages/index/index',
|
||||
text: '主页',
|
||||
text: pt.get().tabBar.indexText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/repair/repair',
|
||||
text: '维修',
|
||||
text: pt.get().tabBar.repairText,
|
||||
},
|
||||
{
|
||||
pagePath: '/pages/user/user',
|
||||
text: '我的',
|
||||
text: pt.get().tabBar.userText,
|
||||
},
|
||||
];
|
||||
|
||||
|
|
@ -24,15 +25,15 @@ export default class Index extends Component {
|
|||
selected: 0,
|
||||
tabList: [
|
||||
{
|
||||
title: '主页',
|
||||
title: pt.get().tabBar.indexText,
|
||||
iconType: 'home',
|
||||
},
|
||||
{
|
||||
title: '维修',
|
||||
title: pt.get().tabBar.repairText,
|
||||
iconType: 'settings',
|
||||
},
|
||||
{
|
||||
title: '我的',
|
||||
title: pt.get().tabBar.userText,
|
||||
iconType: 'user',
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
export interface TabBarText {
|
||||
indexText: string;
|
||||
repairText: string;
|
||||
userText: string;
|
||||
}
|
||||
|
||||
export const tabBarZhCn: TabBarText = {
|
||||
indexText: '主页',
|
||||
repairText: '维修',
|
||||
userText: '我的',
|
||||
};
|
||||
|
||||
export const tabBarEnUs: TabBarText = {
|
||||
indexText: 'Home',
|
||||
repairText: 'Repair',
|
||||
userText: 'Account',
|
||||
};
|
||||
|
|
@ -1,27 +1,31 @@
|
|||
import { PageFooterText, pageFooterZhCn, pageFooterEnUs } from './PageFooter';
|
||||
import { MainPageText, mainPageZhCn, mainPageEnUs } from './MainPage';
|
||||
import { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
|
||||
import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
|
||||
|
||||
interface TextRecord {
|
||||
pageFooter: PageFooterText;
|
||||
mainPage: MainPageText;
|
||||
userPage: UserPageText;
|
||||
tabBar: TabBarText;
|
||||
}
|
||||
|
||||
const textZhCn: TextRecord = {
|
||||
pageFooter: pageFooterZhCn,
|
||||
mainPage: mainPageZhCn,
|
||||
userPage: userPageZhCn,
|
||||
tabBar: tabBarZhCn,
|
||||
};
|
||||
|
||||
const textEnUs: TextRecord = {
|
||||
pageFooter: pageFooterEnUs,
|
||||
mainPage: mainPageEnUs,
|
||||
userPage: userPageEnUs,
|
||||
tabBar: tabBarEnUs,
|
||||
};
|
||||
|
||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||
type Lang = 'zh_CN' | 'en_US';
|
||||
export type Lang = 'zh_CN' | 'en_US';
|
||||
|
||||
class PlainText {
|
||||
private readonly textZhCn: TextRecord;
|
||||
|
|
|
|||
Loading…
Reference in New Issue