git clone https://github.com/EuphoriaCHN/English_Dict.git
cd ./English_Dict
npm config set registry https://registry.npm.taobao.org/
npm install -g yarn
yarn deps
yarn dev
yarn i18n
Edit /scripts/i18n/index.js
to add new language:
// Line 9
const LANGS = ['zh-CN', 'en-US', /* New language */];
Edit /client/src/components/LanguageSelector/index.tsx
to ensure ensure the normal display of the frontend.
// Line 19
const languages: { [k: string]: string } = React.useMemo(() => ({
'zh-cn': '简体中文',
'en-us': 'English',
/* New language */
}), []);
Finally, run i18n
scripts again to generate i18n static locale:
yarn i18n
Frontend project used MomentJS Webpack Plugin for optimizing. More details see /client/.umirc.ts
chainWebpack configurations:
chainWebpack(chain) {
chain.plugin('moment-js-webpack-plugin').use(new MomentLocalesPlugin({
localesToKeep: ['en', 'zh-cn']
}));
}
Stay tuned...