forked from didi/mand-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c17be6
commit 2b0b6ab
Showing
14 changed files
with
160 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import defaultLang from './lang/zh-cn' | ||
|
||
let lang = defaultLang | ||
|
||
function template(str, option) { | ||
if (!str || !option) { | ||
return str | ||
} | ||
|
||
return str.replace(/\{(\w+)\}/g, (match, key) => { | ||
return option[key] | ||
}) | ||
} | ||
|
||
export const t = (path, option) => { | ||
let value | ||
const array = path.split('.') | ||
let current = lang | ||
for (let i = 0, j = array.length; i < j; i++) { | ||
const property = array[i] | ||
value = current[property] | ||
if (i === j - 1) { | ||
return template(value, option) | ||
} | ||
if (!value) { | ||
return '' | ||
} | ||
current = value | ||
} | ||
return '' | ||
} | ||
|
||
export const setLocale = l => { | ||
lang = l || lang | ||
} | ||
|
||
export default {setLocale, t} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
export default { | ||
// [\u4e00-\u9fa5] | ||
name: 'zh-cn', | ||
md: { | ||
'action-sheet': { | ||
cancel: '取消', | ||
}, | ||
captcha: { | ||
sendCaptcha: '发送验证码', | ||
countdown: '{$1}秒后重发' | ||
}, | ||
cashier: { | ||
payCash: '\u652f\u4ed8\u91d1\u989d\u0028\u5143\u0029', | ||
confirmPay: '\u786e\u5b9a\u652f\u4ed8', | ||
morePayWays: '\u66f4\u591a\u652f\u4ed8\u65b9\u5f0f', | ||
pay: '\u652f\u4ed8', | ||
payResultSearch: '\u652f\u4ed8\u7ed3\u679c\u67e5\u8be2\u4e2d\u002e\u002e\u002e', | ||
paySuccess: '\u652f\u4ed8\u6210\u529f', | ||
payFail: '\u652f\u4ed8\u5931\u8d25\uff0c\u8bf7\u7a0d\u540e\u91cd\u8bd5', | ||
confirm: '\u6211\u77e5\u9053\u4e86', | ||
}, | ||
'date-picker': { | ||
year: '年', | ||
month: '月', | ||
day: '日', | ||
hour: '时', | ||
minute: '分', | ||
}, | ||
'number-keyboard': { | ||
confirm: '确定', | ||
}, | ||
'picker': { | ||
confirm: '确认', | ||
cancel: '取消', | ||
}, | ||
'result-page': { | ||
networkError: '\u7f51\u7edc\u8fde\u63a5\u5f02\u5e38', | ||
noInformation: '\u6682\u65e0\u4fe1\u606f', | ||
lostWay: '\u60a8\u8981\u8bbf\u95ee\u7684\u9875\u9762\u5df2\u4e22\u5931', | ||
}, | ||
'scroll-view': { | ||
more: { | ||
loading: '更多加载中...', | ||
allLoaded: '全部已加载', | ||
}, | ||
refresh: { | ||
pullDownRefresh: '下拉刷新', | ||
freedRefresh: '释放刷新', | ||
refreshing: '刷新中...', | ||
}, | ||
}, | ||
'selector': { | ||
cancel: '取消', | ||
}, | ||
'tab-picker': { | ||
choose: '请选择', | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.