index.js 475 Bytes
Newer Older
邓晓峰's avatar
邓晓峰 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import { isBrowser } from '@ant-design/pro-utils';
import zhLocal from './zh-CN';
const locales = {
  'zh-CN': zhLocal
};

const getLanguage = () => {
  if (!isBrowser()) return 'zh-CN';
  const lang = window.localStorage.getItem('umi_locale');
  return lang || (window).g_locale || navigator.language;
};

export { getLanguage };

export default ()=> {
  const gLocale = getLanguage();
  if (locales[gLocale]) {
    return locales[gLocale];
  }
  return locales['zh-CN'];
};