How to use the umi/locale.getLocale function in umi

To help you get started, we’ve selected a few umi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github watertao / teemo / src / utils / request.js View on Github external
// append timeout option
  newOptions = {
    timeout: pconf.request.timeout,
    ...newOptions,
  };

  // append no cache headers
  newOptions.headers = {
    ...NOCACHE_HEADERS,
    ...newOptions.headers,
  };

  // append accept-language header
  newOptions.headers = {
    'Accept-Language': getLocale(),
    ...newOptions.headers,
  };

  return newOptions;
}
github umijs / umi-plugin-locale / examples / base / src / pages / index.js View on Github external
export default () => {
  console.log(getLocale(), formatMessage({
    id: 'test'
  }, {
    name: 'antd'
  }));
  return (
    <div>
      hello world. 
      <button> {
        setLocale('en-US');
      }}&gt;en-US</button>
      <button> {
        setLocale('zh-CN');
      }}&gt;zh-CN</button>
    </div>
  )
};
github VKSRC / Github-Monitor / client / src / components / GlobalHeader / RightContent.js View on Github external
changLang = () => {
    const locale = getLocale();
    if (!locale || locale === 'zh-CN') {
      setLocale('en-US');
    } else {
      setLocale('zh-CN');
    }
  };
github onpaik / umi-lib-paik / packages / umi-plugin-locale-paik / examples / base / src / pages / index.js View on Github external
const temp = () =&gt; {
  const locale =  getLocale();
  const style = {
    backgroundColor: 'red',
  }
  return (
    <div>
      
      <br><br>
      <button style="{locale"> {
          setLocale('zh-CN');
        }}
      &gt;
        zh-CN
      </button>
      </div>
github mpw0311 / antd-umi-sys / src / layouts / components / SelectLang / index.js View on Github external
render() {
    const { className } = this.props;
    const selectedLang = getLocale();
    const locales = ['zh-CN', 'en-US'];
    const languageLabels = {
      'zh-CN': '简体中文',
      'zh-TW': '繁体中文',
      'en-US': 'English',
      'pt-BR': 'Português',
    };
    const languageIcons = {
      'zh-CN': '🇨🇳',
      'zh-TW': '🇭🇰',
      'en-US': '🇬🇧',
      'pt-BR': '🇧🇷',
    };
    const langMenu = (
      <menu>
        {locales.map(locale =&gt; (</menu>
github m430 / antd-pro-toolkit / src / components / SelectLang / index.tsx View on Github external
render() {
    const { className } = this.props;
    const selectedLang = getLocale();
    const langMenu = (
      <menu>
        
          <span aria-label="简体中文" role="img">
            🇨🇳
          </span>{' '}
          简体中文
        
        
          <span aria-label="繁体中文" role="img">
            🇭🇰
          </span>{' '}
          繁体中文
        
        
          <span aria-label="English" role="img"></span></menu>
github gangtao / dataplay3 / client / src / components / SelectLang / index.js View on Github external
render() {
    const { className } = this.props;
    const selectedLang = getLocale();
    const locales = ['zh-CN', 'en-US'];
    const languageLabels = {
      'zh-CN': '简体中文',
      'en-US': 'English',
    };
    const languageIcons = {
      'zh-CN': '🇨🇳',
      'en-US': '🇬🇧',
    };
    const langMenu = (
      <menu>
        {locales.map(locale =&gt; (
          
            <span aria-label="{languageLabels[locale]}" role="img">
              {languageIcons[locale]}
            </span>{' '}</menu>