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 from '@tarojs/taro';
|
||||||
import 'taro-ui/dist/style/index.scss';
|
import 'taro-ui/dist/style/index.scss';
|
||||||
import './index.scss';
|
import './index.scss';
|
||||||
|
import pt from '@/plain-text';
|
||||||
|
|
||||||
const navList: Array<Taro.TabBarItem> = [
|
const navList: Array<Taro.TabBarItem> = [
|
||||||
{
|
{
|
||||||
pagePath: '/pages/index/index',
|
pagePath: '/pages/index/index',
|
||||||
text: '主页',
|
text: pt.get().tabBar.indexText,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: '/pages/repair/repair',
|
pagePath: '/pages/repair/repair',
|
||||||
text: '维修',
|
text: pt.get().tabBar.repairText,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
pagePath: '/pages/user/user',
|
pagePath: '/pages/user/user',
|
||||||
text: '我的',
|
text: pt.get().tabBar.userText,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -24,15 +25,15 @@ export default class Index extends Component {
|
||||||
selected: 0,
|
selected: 0,
|
||||||
tabList: [
|
tabList: [
|
||||||
{
|
{
|
||||||
title: '主页',
|
title: pt.get().tabBar.indexText,
|
||||||
iconType: 'home',
|
iconType: 'home',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '维修',
|
title: pt.get().tabBar.repairText,
|
||||||
iconType: 'settings',
|
iconType: 'settings',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '我的',
|
title: pt.get().tabBar.userText,
|
||||||
iconType: 'user',
|
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 { PageFooterText, pageFooterZhCn, pageFooterEnUs } from './PageFooter';
|
||||||
import { MainPageText, mainPageZhCn, mainPageEnUs } from './MainPage';
|
import { MainPageText, mainPageZhCn, mainPageEnUs } from './MainPage';
|
||||||
import { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
|
import { UserPageText, userPageZhCn, userPageEnUs } from './UserPage';
|
||||||
|
import { TabBarText, tabBarEnUs, tabBarZhCn } from './TabBar';
|
||||||
|
|
||||||
interface TextRecord {
|
interface TextRecord {
|
||||||
pageFooter: PageFooterText;
|
pageFooter: PageFooterText;
|
||||||
mainPage: MainPageText;
|
mainPage: MainPageText;
|
||||||
userPage: UserPageText;
|
userPage: UserPageText;
|
||||||
|
tabBar: TabBarText;
|
||||||
}
|
}
|
||||||
|
|
||||||
const textZhCn: TextRecord = {
|
const textZhCn: TextRecord = {
|
||||||
pageFooter: pageFooterZhCn,
|
pageFooter: pageFooterZhCn,
|
||||||
mainPage: mainPageZhCn,
|
mainPage: mainPageZhCn,
|
||||||
userPage: userPageZhCn,
|
userPage: userPageZhCn,
|
||||||
|
tabBar: tabBarZhCn,
|
||||||
};
|
};
|
||||||
|
|
||||||
const textEnUs: TextRecord = {
|
const textEnUs: TextRecord = {
|
||||||
pageFooter: pageFooterEnUs,
|
pageFooter: pageFooterEnUs,
|
||||||
mainPage: mainPageEnUs,
|
mainPage: mainPageEnUs,
|
||||||
userPage: userPageEnUs,
|
userPage: userPageEnUs,
|
||||||
|
tabBar: tabBarEnUs,
|
||||||
};
|
};
|
||||||
|
|
||||||
// type Lang = 'zh_CN' | 'en_US' | ...;
|
// type Lang = 'zh_CN' | 'en_US' | ...;
|
||||||
type Lang = 'zh_CN' | 'en_US';
|
export type Lang = 'zh_CN' | 'en_US';
|
||||||
|
|
||||||
class PlainText {
|
class PlainText {
|
||||||
private readonly textZhCn: TextRecord;
|
private readonly textZhCn: TextRecord;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue