From f1913f7b180b52e14acfb25e37677543562e869e Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Fri, 5 Jul 2019 22:16:54 +0800 Subject: [PATCH 1/2] add pt_BR locale-provider in layout --- src/layouts/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/layouts/index.js b/src/layouts/index.js index 26ba8b1..8d075dd 100644 --- a/src/layouts/index.js +++ b/src/layouts/index.js @@ -5,12 +5,14 @@ import { I18nProvider } from '@lingui/react' import { langFromPath, defaultLanguage } from 'utils' import zh_CN from 'antd/lib/locale-provider/zh_CN' import en_US from 'antd/lib/locale-provider/en_US' +import pt_BR from 'antd/lib/locale-provider/pt_BR' import BaseLayout from './BaseLayout' const languages = { zh: zh_CN, en: en_US, + 'pt-br': pt_BR, } @withRouter From 5daa2a9548e8692945cfdeb8fc127667c7fc6db4 Mon Sep 17 00:00:00 2001 From: Baorong Li Date: Fri, 5 Jul 2019 22:26:29 +0800 Subject: [PATCH 2/2] add moment locale setting --- src/utils/index.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/utils/index.js b/src/utils/index.js index 1ea50c8..3bac7db 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -2,6 +2,8 @@ import { cloneDeep, isString, flow, curry } from 'lodash' import umiRouter from 'umi/router' import pathToRegexp from 'path-to-regexp' import { i18n } from './config' +import moment from 'moment' +import 'moment/locale/zh-cn' export classnames from 'classnames' export config from './config' @@ -245,6 +247,7 @@ export function getLocale() { export function setLocale(language) { if (getLocale() !== language) { + moment.locale(language === 'zh' ? 'zh-cn' : language) umiRouter.push({ pathname: `/${language}${deLangPrefix(window.location.pathname)}`, search: window.location.search,