i18n
2022-12-15 本文已影响0人
IT匠心说
let $i18n = {
en: {
'注册': 'Register',
'交易': 'Exchange',
'回款': 'Rewards',
'平台': 'App',
'网址': 'Link'
}
}
let $tt = function (value) {
let translation;
try {
translation = $i18n[locale][value];
} finally {
return translation || value;
}
}
this.state = {
locale: 'en',
localeName: '英文'
}
<img src={`/img/banner_01_${locale}.png`} />
<div>{$tt(`注册`)}</div>