Skip to content

Commit

Permalink
Merge pull request zuiidea#939 from rrfaria/feature/pt-br
Browse files Browse the repository at this point in the history
added pt-br language and some improvements to language control to route mocks
  • Loading branch information
superlbr authored Feb 7, 2019
2 parents 67388b3 + 671da6b commit 8c10dcc
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 16 deletions.
77 changes: 66 additions & 11 deletions mock/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,37 @@ const database = [
id: '1',
icon: 'dashboard',
name: 'Dashboard',
zhName: '仪表盘',
zh: {
name: '仪表盘'
},
'pt-br': {
name: 'Dashboard'
},
route: '/dashboard',
},
{
id: '2',
breadcrumbParentId: '1',
name: 'Users',
zhName: '用户管理',
zh: {
name: '用户管理'
},
'pt-br': {
name: 'Usuário'
},
icon: 'user',
route: '/user',
},
{
id: '7',
breadcrumbParentId: '1',
name: 'Posts',
zhName: '文章管理',
zh: {
name: '用户管理'
},
'pt-br': {
name: 'Posts'
},
icon: 'shopping-cart',
route: '/post',
},
Expand All @@ -30,46 +45,76 @@ const database = [
menuParentId: '-1',
breadcrumbParentId: '2',
name: 'User Detail',
zhName: '用户详情',
zh: {
name: '用户详情'
},
'pt-br': {
name: 'Detalhes do usuário'
},
route: '/user/:id',
},
{
id: '3',
breadcrumbParentId: '1',
name: 'Request',
zhName: 'Request',
zh: {
name: 'Request'
},
'pt-br': {
name: 'Requisição'
},
icon: 'api',
route: '/request',
},
{
id: '4',
breadcrumbParentId: '1',
name: 'UI Element',
zhName: 'UI组件',
zh: {
name: 'UI组件'
},
'pt-br': {
name: 'Elementos UI'
},
icon: 'camera-o',
},
{
id: '45',
breadcrumbParentId: '4',
menuParentId: '4',
name: 'Editor',
zhName: 'Editor',
zh: {
name: 'Editor'
},
'pt-br': {
name: 'Editor'
},
icon: 'edit',
route: '/UIElement/editor',
},
{
id: '5',
breadcrumbParentId: '1',
name: 'Charts',
zhName: 'Charts',
zh: {
name: 'Charts'
},
'pt-br': {
name: 'Graficos'
},
icon: 'code-o',
},
{
id: '51',
breadcrumbParentId: '5',
menuParentId: '5',
name: 'ECharts',
zhName: 'ECharts',
zh: {
name: 'ECharts'
},
'pt-br': {
name: 'ECharts'
},
icon: 'line-chart',
route: '/chart/ECharts',
},
Expand All @@ -78,7 +123,12 @@ const database = [
breadcrumbParentId: '5',
menuParentId: '5',
name: 'HighCharts',
zhName: 'HighCharts',
zh: {
name: 'HighCharts'
},
'pt-br': {
name: 'HighCharts'
},
icon: 'bar-chart',
route: '/chart/highCharts',
},
Expand All @@ -87,7 +137,12 @@ const database = [
breadcrumbParentId: '5',
menuParentId: '5',
name: 'Rechartst',
zhName: 'Rechartst',
zh: {
name: 'Rechartst'
},
'pt-br': {
name: 'Rechartst'
},
icon: 'area-chart',
route: '/chart/Recharts',
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "antd-admin",
"version": "5.0.2",
"version": "5.0.3",
"private": true,
"description": "An admin dashboard application demo built upon Ant Design and UmiJS",
"dependencies": {
Expand Down
9 changes: 6 additions & 3 deletions src/layouts/PrimaryLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ class PrimaryLayout extends PureComponent {
const { onCollapseChange } = this

// Localized route name.

const lang = langFromPath(location.pathname);
const newRouteList =
langFromPath(location.pathname) === 'zh'
lang !== 'en'
? routeList.map(item => {
const { zhName, ...other } = item
const { name , ...other } = item
return {
...other,
name: zhName,
name: ((item[lang] || {}).name || name),
}
})
: routeList


// Find a route that matches the pathname.
const currentRoute = newRouteList.find(
_ => _.route && pathMatchRegexp(_.route, location.pathname)
Expand Down
54 changes: 54 additions & 0 deletions src/locales/pt-br/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"/dashboard": "/dashboard",
"Add Param": "Add Parametro",
"Address": "Endereço",
"Age": "Ano",
"Are you sure delete this record?": "Tem certeza de excluir este registro?",
"Author": "Autor",
"Avatar": "Avatar",
"Categories": "Categorias",
"Clear notifications": "limpar notificações",
"Comments": "Comentarios",
"Create": "Criar",
"Create User": "Criar Usuário",
"CreateTime": "CreateTime",
"Dark": "Escuro",
"Delete": "Deletar",
"Email": "Email",
"Female": "Feminino",
"Gender": "Genero",
"Hi,": "Olá,",
"Image": "Imagem",
"Light": "Claro",
"Male": "masculino",
"Name": "Nome",
"NickName": "NickName",
"Not Found": "Não Encontrado",
"Operation": "Operation",
"Params": "Parametros",
"Password": "Senha",
"Phone": "Fone",
"Pick an address": "Escolha um endereço",
"Please pick an address": "Por favor, escolha um endereço",
"Publised": "Publicado",
"Publish Date": "Data de publicação",
"Reset": "Reset",
"Search": "procurar",
"Search Name": "Search Name",
"Send": "Enviar",
"Sign in": "Sign in",
"Sign out": "Sign out",
"Switch Theme": "Trocar tema",
"Tags": "Tags",
"The input is not valid E-mail!": "Não é um E-mail valido!",
"The input is not valid phone!": "Não é um telefone Valido!",
"Title": "Titulo",
"Total {total} Items": "Total {total} Items",
"Unpublished": "Não publicado",
"Update": "Atualizar",
"Update User": "Atualizar Usuário",
"Username": "Usuário",
"Views": "visualizações",
"Visibility": "Visibilidade",
"You have viewed all notifications.": "Você visualizou todas as notificações."
}
7 changes: 6 additions & 1 deletion src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ module.exports = {
i18n: {
/* Countrys flags: https://www.flaticon.com/packs/countrys-flags */
languages: [
{
key: 'pt-br',
title: 'Português',
flag: '/brazil.svg',
},
{
key: 'en',
title: 'English',
Expand All @@ -29,6 +34,6 @@ module.exports = {
flag: '/china.svg',
},
],
defaultLanguage: 'en',
defaultLanguage: 'pt-br',
},
}

0 comments on commit 8c10dcc

Please sign in to comment.