docs: translate category for specification

This commit is contained in:
Benjy Cui 2016-09-26 11:08:27 +08:00
parent 4bf80a2e26
commit b43d40d47b
19 changed files with 38 additions and 22 deletions

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 2
title: Alignment
---

View File

@ -1,5 +1,7 @@
---
category: 设计基础
category:
zh-CN: 设计基础
en-US: Design Fundamental
order: 2
title:
zh-CN: 色彩

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 3
title: Contrast
---

View File

@ -1,5 +1,7 @@
---
category: 十大原则
category:
zh-CN: 十大原则
en-US: Principles
order: 5
title:
zh-CN: 直截了当

View File

@ -1,5 +1,7 @@
---
category: 设计基础
category:
zh-CN: 设计基础
en-US: Design Fundamental
order: 0
title:
zh-CN: 字体

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 8
title: Provide an Invitation
---

View File

@ -1,6 +1,8 @@
---
template: component
category: 设计基础
category:
zh-CN: 设计基础
en-US: Design Fundamental
order: 4
cols: 1
title:

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 6
title: Keep it Lightweight
---

View File

@ -1,5 +1,7 @@
---
category: 设计基础
category:
zh-CN: 设计基础
en-US: Design Fundamental
order: 5
title:
zh-CN: 组件动画

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 0
title: Introduction
---

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 1
title: Proximity
---

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 10
title: React Immediately
---

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 4
title: Repetition
---

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 6
title: Stay on the Page
---

View File

@ -1,5 +1,5 @@
---
category: 十大原则
category: Principles
order: 9
title: Use Transition
---

View File

@ -1,5 +1,7 @@
---
category: 设计基础
category:
zh-CN: 设计基础
en-US: Design Fundamental
order: 1
title:
zh-CN: 排版

View File

@ -2,10 +2,10 @@ const contentTmpl = './template/Content/index';
module.exports = {
categoryOrder: {
组件: 0,
十大原则: 0,
Principles: 0,
设计基础: 1,
动画: 2,
'Design Fundamental': 1,
},
typeOrder: {
Basic: 0,

View File

@ -31,7 +31,9 @@ export default class MainContent extends React.Component {
}
if (prevModule !== this.currentModule) {
const moduleData = this.getModuleData(nextProps);
const shouldOpenKeys = Object.keys(utils.getMenuItems(moduleData));
const shouldOpenKeys = Object.keys(utils.getMenuItems(
moduleData, this.context.intl.locale
));
this.setState({ openKeys: shouldOpenKeys });
}
}
@ -128,7 +130,9 @@ export default class MainContent extends React.Component {
getMenuItems() {
const moduleData = this.getModuleData(this.props);
const menuItems = utils.getMenuItems(moduleData);
const menuItems = utils.getMenuItems(
moduleData, this.context.intl.locale
);
const topLevel = this.generateSubMenuItems(menuItems.topLevel);
const subMenu = Object.keys(menuItems).filter(this.isNotTopLevel)
.sort((a, b) => config.categoryOrder[a] - config.categoryOrder[b])

View File

@ -1,10 +1,10 @@
export function getMenuItems(moduleData) {
export function getMenuItems(moduleData, locale) {
const menuMeta = moduleData.map(item => item.meta);
const menuItems = {};
menuMeta.sort(
(a, b) => (a.order || 0) - (b.order || 0)
).forEach((meta) => {
const category = meta.category || 'topLevel';
const category = (meta.category && meta.category[locale]) || meta.category || 'topLevel';
if (!menuItems[category]) {
menuItems[category] = {};
}