Skip to content

Commit

Permalink
fix: add dos sidebar category translate #141
Browse files Browse the repository at this point in the history
  • Loading branch information
shuashuai committed Feb 29, 2024
1 parent 9ba0fb8 commit 60fefee
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
9 changes: 9 additions & 0 deletions i18n/zh-CN/code.json
Original file line number Diff line number Diff line change
Expand Up @@ -574,5 +574,14 @@
},
"plugins.instruction.join": {
"message": "加入我们的社区"
},
"docs.sidebar.tutorialSidebar.category.Getting Started": {
"message": "入门"
},
"docs.sidebar.tutorialSidebar.category.User Guides": {
"message": "用户指南"
},
"docs.sidebar.tutorialSidebar.category.Developer Guides": {
"message": "开发者指南"
}
}
4 changes: 2 additions & 2 deletions i18n/zh-CN/docusaurus-plugin-content-docs/current.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"message": "贡献",
"description": "The label for category Contributing in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.link.Getting Started": {
"sidebar.tutorialSidebar.category.Getting Started": {
"message": "入门",
"description": "The label for link Getting Started in sidebar tutorialSidebar, linking to #"
"description": "The label for category Contents Management in sidebar tutorialSidebar"
},
"sidebar.tutorialSidebar.link.Recipes": {
"message": "教程",
Expand Down
9 changes: 8 additions & 1 deletion src/theme/DocSidebarItem/Category/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function CollapseButton({
categoryLabel: string;
onClick: ComponentProps<'button'>['onClick'];
}) {
console.log('categoryLabel', categoryLabel);
return (
<button
aria-label={
Expand Down Expand Up @@ -156,6 +157,8 @@ export default function DocSidebarItemCategory({
}
}, [collapsible, expandedItem, index, setCollapsed, autoCollapseCategories]);

console.log('collapsed', item);

return (
<li
className={clsx(
Expand Down Expand Up @@ -196,7 +199,11 @@ export default function DocSidebarItemCategory({
aria-expanded={collapsible ? !collapsed : undefined}
href={collapsible ? hrefWithSSRFallback ?? '#' : hrefWithSSRFallback}
{...props}>
{label}
{translate({
id: `docs.sidebar.tutorialSidebar.category.${label}`,
message: label,
},
{label: label},)}
</Link>
{href && collapsible && (
<CollapseButton
Expand Down

0 comments on commit 60fefee

Please sign in to comment.