mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-22 22:36:06 +08:00
39 lines
901 B
TypeScript
39 lines
901 B
TypeScript
const baseUrl = window.__ENV__QlBaseUrl || '/';
|
|
import { setLocale } from '@umijs/max';
|
|
import intl from 'react-intl-universal';
|
|
|
|
export function rootContainer(container: any) {
|
|
const locales = {
|
|
'en': require('./locales/en-US.json'),
|
|
'zh': require('./locales/zh-CN.json'),
|
|
};
|
|
let currentLocale = intl.determineLocale({
|
|
urlLocaleKey: 'lang',
|
|
cookieLocaleKey: 'lang',
|
|
localStorageLocaleKey: 'lang',
|
|
}).slice(0, 2);
|
|
|
|
if (!currentLocale || !Object.keys(locales).includes(currentLocale)) {
|
|
currentLocale = 'zh';
|
|
}
|
|
|
|
intl.init({ currentLocale, locales });
|
|
setLocale(currentLocale === 'zh' ? 'zh-CN' : 'en-US');
|
|
return container;
|
|
}
|
|
|
|
export function modifyClientRenderOpts(memo: any) {
|
|
return {
|
|
...memo,
|
|
publicPath: baseUrl,
|
|
basename: baseUrl,
|
|
};
|
|
}
|
|
|
|
export function modifyContextOpts(memo: any) {
|
|
return {
|
|
...memo,
|
|
basename: baseUrl,
|
|
};
|
|
}
|