From b43d40d47b512afb186970a7b0c2d3d92c99fb53 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Mon, 26 Sep 2016 11:08:27 +0800 Subject: [PATCH] docs: translate category for specification --- docs/spec/alignment.en-US.md | 2 +- docs/spec/colors.md | 4 +++- docs/spec/contrast.en-US.md | 2 +- docs/spec/direct.md | 4 +++- docs/spec/font.md | 4 +++- docs/spec/invitation.en-US.md | 2 +- docs/spec/layout/index.md | 4 +++- docs/spec/lightweight.en-US.md | 2 +- docs/spec/motion.md | 4 +++- docs/spec/principle.en-US.md | 2 +- docs/spec/proximity.en-US.md | 2 +- docs/spec/reaction.en-US.md | 2 +- docs/spec/repetition.en-US.md | 2 +- docs/spec/stay.en-US.md | 2 +- docs/spec/transition.en-US.md | 2 +- docs/spec/typography.md | 4 +++- site/theme/index.js | 4 ++-- site/theme/template/Content/MainContent.jsx | 8 ++++++-- site/theme/template/utils.jsx | 4 ++-- 19 files changed, 38 insertions(+), 22 deletions(-) diff --git a/docs/spec/alignment.en-US.md b/docs/spec/alignment.en-US.md index ba10bf01ec..53c79e46bf 100644 --- a/docs/spec/alignment.en-US.md +++ b/docs/spec/alignment.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 2 title: Alignment --- diff --git a/docs/spec/colors.md b/docs/spec/colors.md index eb49f722d9..2496b311fe 100644 --- a/docs/spec/colors.md +++ b/docs/spec/colors.md @@ -1,5 +1,7 @@ --- -category: 设计基础 +category: + zh-CN: 设计基础 + en-US: Design Fundamental order: 2 title: zh-CN: 色彩 diff --git a/docs/spec/contrast.en-US.md b/docs/spec/contrast.en-US.md index 3051d88249..2633f737de 100644 --- a/docs/spec/contrast.en-US.md +++ b/docs/spec/contrast.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 3 title: Contrast --- diff --git a/docs/spec/direct.md b/docs/spec/direct.md index a3fa91a951..f009d0bb46 100644 --- a/docs/spec/direct.md +++ b/docs/spec/direct.md @@ -1,5 +1,7 @@ --- -category: 十大原则 +category: + zh-CN: 十大原则 + en-US: Principles order: 5 title: zh-CN: 直截了当 diff --git a/docs/spec/font.md b/docs/spec/font.md index b74ec5f237..bb7974998f 100644 --- a/docs/spec/font.md +++ b/docs/spec/font.md @@ -1,5 +1,7 @@ --- -category: 设计基础 +category: + zh-CN: 设计基础 + en-US: Design Fundamental order: 0 title: zh-CN: 字体 diff --git a/docs/spec/invitation.en-US.md b/docs/spec/invitation.en-US.md index 093bbc9957..85b8f0cdf3 100644 --- a/docs/spec/invitation.en-US.md +++ b/docs/spec/invitation.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 8 title: Provide an Invitation --- diff --git a/docs/spec/layout/index.md b/docs/spec/layout/index.md index c2215c30d9..dd88f055c1 100644 --- a/docs/spec/layout/index.md +++ b/docs/spec/layout/index.md @@ -1,6 +1,8 @@ --- template: component -category: 设计基础 +category: + zh-CN: 设计基础 + en-US: Design Fundamental order: 4 cols: 1 title: diff --git a/docs/spec/lightweight.en-US.md b/docs/spec/lightweight.en-US.md index 223a89a15e..e2430427ac 100644 --- a/docs/spec/lightweight.en-US.md +++ b/docs/spec/lightweight.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 6 title: Keep it Lightweight --- diff --git a/docs/spec/motion.md b/docs/spec/motion.md index 78df289144..5fa06ad2fa 100644 --- a/docs/spec/motion.md +++ b/docs/spec/motion.md @@ -1,5 +1,7 @@ --- -category: 设计基础 +category: + zh-CN: 设计基础 + en-US: Design Fundamental order: 5 title: zh-CN: 组件动画 diff --git a/docs/spec/principle.en-US.md b/docs/spec/principle.en-US.md index 5330850b5a..ca2856c94f 100644 --- a/docs/spec/principle.en-US.md +++ b/docs/spec/principle.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 0 title: Introduction --- diff --git a/docs/spec/proximity.en-US.md b/docs/spec/proximity.en-US.md index f8929117c1..0d5173d48e 100644 --- a/docs/spec/proximity.en-US.md +++ b/docs/spec/proximity.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 1 title: Proximity --- diff --git a/docs/spec/reaction.en-US.md b/docs/spec/reaction.en-US.md index f7a44bdc50..00e781d5dd 100644 --- a/docs/spec/reaction.en-US.md +++ b/docs/spec/reaction.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 10 title: React Immediately --- diff --git a/docs/spec/repetition.en-US.md b/docs/spec/repetition.en-US.md index 56283f09cb..cbcc9e4dbb 100644 --- a/docs/spec/repetition.en-US.md +++ b/docs/spec/repetition.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 4 title: Repetition --- diff --git a/docs/spec/stay.en-US.md b/docs/spec/stay.en-US.md index be8105a2bb..ef03da06b0 100644 --- a/docs/spec/stay.en-US.md +++ b/docs/spec/stay.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 6 title: Stay on the Page --- diff --git a/docs/spec/transition.en-US.md b/docs/spec/transition.en-US.md index dc7f6259ac..16299eae81 100644 --- a/docs/spec/transition.en-US.md +++ b/docs/spec/transition.en-US.md @@ -1,5 +1,5 @@ --- -category: 十大原则 +category: Principles order: 9 title: Use Transition --- diff --git a/docs/spec/typography.md b/docs/spec/typography.md index f6ea94f2a7..c9fa6d58bc 100644 --- a/docs/spec/typography.md +++ b/docs/spec/typography.md @@ -1,5 +1,7 @@ --- -category: 设计基础 +category: + zh-CN: 设计基础 + en-US: Design Fundamental order: 1 title: zh-CN: 排版 diff --git a/site/theme/index.js b/site/theme/index.js index 66de73d90c..696a19c3fb 100644 --- a/site/theme/index.js +++ b/site/theme/index.js @@ -2,10 +2,10 @@ const contentTmpl = './template/Content/index'; module.exports = { categoryOrder: { - 组件: 0, 十大原则: 0, + Principles: 0, 设计基础: 1, - 动画: 2, + 'Design Fundamental': 1, }, typeOrder: { Basic: 0, diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index 475fdc4704..c17a67c318 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -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]) diff --git a/site/theme/template/utils.jsx b/site/theme/template/utils.jsx index 09945ce487..e4c40842b8 100644 --- a/site/theme/template/utils.jsx +++ b/site/theme/template/utils.jsx @@ -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] = {}; }