Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theme-classic): should use plurals for category items description #9851

Merged
merged 3 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 20 additions & 12 deletions packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
findFirstSidebarItemLink,
useDocById,
} from '@docusaurus/theme-common/internal';
import {usePluralForm} from '@docusaurus/theme-common';
import isInternalUrl from '@docusaurus/isInternalUrl';
import {translate} from '@docusaurus/Translate';

Expand All @@ -24,6 +25,23 @@ import type {

import styles from './styles.module.css';

function useCategoryItemsPlural() {
const {selectMessage} = usePluralForm();
return (count: number) =>
selectMessage(
count,
translate(
{
message: '{count} items',
id: 'theme.docs.DocCard.categoryDescription.plurals',
description:
'The default description for a category card in the generated index about how many items this category includes',
},
{count},
),
);
}

function CardContainer({
href,
children,
Expand Down Expand Up @@ -76,6 +94,7 @@ function CardCategory({
item: PropSidebarItemCategory;
}): JSX.Element | null {
const href = findFirstSidebarItemLink(item);
const categoryItemsPlural = useCategoryItemsPlural();

// Unexpected: categories that don't have a link have been filtered upfront
if (!href) {
Expand All @@ -87,18 +106,7 @@ function CardCategory({
href={href}
icon="🗃️"
title={item.label}
description={
item.description ??
translate(
{
message: '{count} items',
id: 'theme.docs.DocCard.categoryDescription',
description:
'The default description for a category card in the generated index about how many items this category includes',
},
{count: item.items.length},
)
}
description={item.description ?? categoryItemsPlural(item.items.length)}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "تعديل هذه الصفحة",
"theme.common.headingLinkTitle": "ارتباط مباشر بالعنوان {heading}",
"theme.common.skipToMainContent": "انتقل إلى المحتوى الرئيسي",
"theme.docs.DocCard.categoryDescription": "{count} مواد",
"theme.docs.DocCard.categoryDescription.plurals": "{count} مواد",
"theme.docs.breadcrumbs.home": "الرئيسية",
"theme.docs.breadcrumbs.navAriaLabel": "التنقل التفصيلي",
"theme.docs.paginator.navAriaLabel": "صفحة التوثيق",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
"theme.common.headingLinkTitle___DESCRIPTION": "Title for link to heading",
"theme.common.skipToMainContent": "Skip to main content",
"theme.common.skipToMainContent___DESCRIPTION": "The skip to content label used for accessibility, allowing to rapidly navigate to main content with keyboard tab/enter navigation",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription___DESCRIPTION": "The default description for a category card in the generated index about how many items this category includes",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals___DESCRIPTION": "The default description for a category card in the generated index about how many items this category includes",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.home___DESCRIPTION": "The ARIA label for the home page in the breadcrumbs",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "এই পেজটি এডিট করুন",
"theme.common.headingLinkTitle": "{heading} এর সঙ্গে সরাসরি লিংকড",
"theme.common.skipToMainContent": "স্কিপ করে মূল কন্টেন্ট এ যান",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "ডক্স পেজ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Upravit tuto stránku",
"theme.common.headingLinkTitle": "Přímý odkaz na {heading}",
"theme.common.skipToMainContent": "Přeskočit na hlavní obsah",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Stránka dokumentace",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Rediger denne side",
"theme.common.headingLinkTitle": "Direkte link til {heading}",
"theme.common.skipToMainContent": "Hop til hovedindhold",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Dokumentside",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Diese Seite bearbeiten",
"theme.common.headingLinkTitle": "Direkter Link zur {heading}",
"theme.common.skipToMainContent": "Zum Hauptinhalt springen",
"theme.docs.DocCard.categoryDescription": "{count} Einträge",
"theme.docs.DocCard.categoryDescription.plurals": "{count} Einträge",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Dokumentation Seiten",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Editar esta página",
"theme.common.headingLinkTitle": "Enlace directo al {heading}",
"theme.common.skipToMainContent": "Saltar al contenido principal",
"theme.docs.DocCard.categoryDescription": "{count} artículos",
"theme.docs.DocCard.categoryDescription.plurals": "{count} artículos",
"theme.docs.breadcrumbs.home": "Página de Inicio",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Página del documento",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "ویرایش مطالب این صفحه",
"theme.common.headingLinkTitle": "لینک مستقیم به {heading}",
"theme.common.skipToMainContent": "پرش به مطلب اصلی",
"theme.docs.DocCard.categoryDescription": "{count} مورد",
"theme.docs.DocCard.categoryDescription.plurals": "{count} مورد",
"theme.docs.breadcrumbs.home": "صفحه اصلی",
"theme.docs.breadcrumbs.navAriaLabel": "نشانگر صفحات",
"theme.docs.paginator.navAriaLabel": "صفحات مستندات",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "I-edit ang page",
"theme.common.headingLinkTitle": "Direktang link patungo sa {heading}",
"theme.common.skipToMainContent": "Lumaktaw patungo sa pangunahing content",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Docs Pages",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Éditer cette page",
"theme.common.headingLinkTitle": "Lien direct vers {heading}",
"theme.common.skipToMainContent": "Aller au contenu principal",
"theme.docs.DocCard.categoryDescription": "{count} éléments",
"theme.docs.DocCard.categoryDescription.plurals": "{count} éléments",
"theme.docs.breadcrumbs.home": "Page d'accueil",
"theme.docs.breadcrumbs.navAriaLabel": "Fil d'Ariane",
"theme.docs.paginator.navAriaLabel": "Pages de documentation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "ערוך דף זה",
"theme.common.headingLinkTitle": "קישור ישיר אל {heading}",
"theme.common.skipToMainContent": "דלג לתוכן הראשי",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "רשימת דוקומנטאציה",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "इस पेज को बदलें",
"theme.common.headingLinkTitle": "{heading} का सीधा लिंक",
"theme.common.skipToMainContent": "मुख्य कंटेंट तक स्किप करें",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "डॉक्स पेज",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Szerkesztés GitHub-on",
"theme.common.headingLinkTitle": "Közvetlen hivatkozás erre: {heading}",
"theme.common.skipToMainContent": "Ugrás a fő tartalomhoz",
"theme.docs.DocCard.categoryDescription": "{count} elemek",
"theme.docs.DocCard.categoryDescription.plurals": "{count} elemek",
"theme.docs.breadcrumbs.home": "Kezdőlap",
"theme.docs.breadcrumbs.navAriaLabel": "Navigációs sáv a jelenlegi oldalhoz",
"theme.docs.paginator.navAriaLabel": "Dokumentációs oldal",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Modifica questa pagina",
"theme.common.headingLinkTitle": "Link diretto a {heading}",
"theme.common.skipToMainContent": "Passa al contenuto principale",
"theme.docs.DocCard.categoryDescription": "{count} elementi",
"theme.docs.DocCard.categoryDescription.plurals": "{count} elementi",
"theme.docs.breadcrumbs.home": "Pagina principale",
"theme.docs.breadcrumbs.navAriaLabel": "Briciole di pane",
"theme.docs.paginator.navAriaLabel": "Pagina del documento",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "このページを編集",
"theme.common.headingLinkTitle": "{heading} への直接リンク",
"theme.common.skipToMainContent": "メインコンテンツまでスキップ",
"theme.docs.DocCard.categoryDescription": "{count}項目",
"theme.docs.DocCard.categoryDescription.plurals": "{count}項目",
"theme.docs.breadcrumbs.home": "ホームページ",
"theme.docs.breadcrumbs.navAriaLabel": "パンくずリストのナビゲーション",
"theme.docs.paginator.navAriaLabel": "ドキュメントページ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "페이지 편집",
"theme.common.headingLinkTitle": "{heading}에 대한 직접 링크",
"theme.common.skipToMainContent": "본문으로 건너뛰기",
"theme.docs.DocCard.categoryDescription": "{count} 항목",
"theme.docs.DocCard.categoryDescription.plurals": "{count} 항목",
"theme.docs.breadcrumbs.home": "홈",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "문서 페이지",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Rediger denne siden",
"theme.common.headingLinkTitle": "Direkte lenke til {heading}",
"theme.common.skipToMainContent": "Gå til hovedinnhold",
"theme.docs.DocCard.categoryDescription": "{count} artikler",
"theme.docs.DocCard.categoryDescription.plurals": "{count} artikler",
"theme.docs.breadcrumbs.home": "Hjemmeside",
"theme.docs.breadcrumbs.navAriaLabel": "Søkvei",
"theme.docs.paginator.navAriaLabel": "Dokumenter side",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Bewerk deze pagina",
"theme.common.headingLinkTitle": "Direct link naar {heading}",
"theme.common.skipToMainContent": "Ga naar hoofdinhoud",
"theme.docs.DocCard.categoryDescription": "{count} artikelen",
"theme.docs.DocCard.categoryDescription.plurals": "{count} artikelen",
"theme.docs.breadcrumbs.home": "Homepagina",
"theme.docs.breadcrumbs.navAriaLabel": "Broodkruimels",
"theme.docs.paginator.navAriaLabel": "Documentatie pagina",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Edytuj tę stronę",
"theme.common.headingLinkTitle": "Bezpośredni link do {heading}",
"theme.common.skipToMainContent": "Przejdź do głównej zawartości",
"theme.docs.DocCard.categoryDescription": "{count} elementów",
"theme.docs.DocCard.categoryDescription.plurals": "{count} elementów",
"theme.docs.breadcrumbs.home": "Strona główna",
"theme.docs.breadcrumbs.navAriaLabel": "Pasek nawigacji",
"theme.docs.paginator.navAriaLabel": "Strona dokumentacji",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Editar essa página",
"theme.common.headingLinkTitle": "Link direto para {heading}",
"theme.common.skipToMainContent": "Pular para o conteúdo principal",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Página Inicial",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Páginas de documentação",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Editar esta página",
"theme.common.headingLinkTitle": "Link direto para {heading}",
"theme.common.skipToMainContent": "Saltar para o conteúdo principal",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Páginas de documento",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"theme.blog.post.plurals": "{count} запись|{count} записи|{count} записей",
"theme.blog.post.readMore": "Читать дальше",
"theme.blog.post.readMoreLabel": "Подробнее о {title}",
"theme.blog.post.readingTime.plurals": "{readingTime} мин. чтения",
"theme.blog.post.readingTime.plurals": "{readingTime} мин. чтения|{readingTime} мин. чтения|{readingTime} мин. чтения",
"theme.blog.sidebar.navAriaLabel": "Навигация по последним постам в блоге",
"theme.blog.tagTitle": "{nPosts} с тегом \"{tagName}\"",
"theme.colorToggle.ariaLabel": "Переключение между темным и светлым режимом (сейчас используется {mode})",
Expand All @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Отредактировать эту страницу",
"theme.common.headingLinkTitle": "Прямая ссылка на {heading}",
"theme.common.skipToMainContent": "Перейти к основному содержимому",
"theme.docs.DocCard.categoryDescription": "{count} элемент|{count} элемента|{count} элементов",
"theme.docs.DocCard.categoryDescription.plurals": "{count} элемент|{count} элемента|{count} элементов",
"theme.docs.breadcrumbs.home": "Главная страница",
"theme.docs.breadcrumbs.navAriaLabel": "Навигационная цепочка текущей страницы",
"theme.docs.paginator.navAriaLabel": "Страница документа",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Uredi to stran",
"theme.common.headingLinkTitle": "Direktna povezava na {heading}",
"theme.common.skipToMainContent": "Preskoči na vsebino",
"theme.docs.DocCard.categoryDescription": "{count} vnosov",
"theme.docs.DocCard.categoryDescription.plurals": "{count} vnosov",
"theme.docs.breadcrumbs.home": "Domača stran",
"theme.docs.breadcrumbs.navAriaLabel": "Drobtine",
"theme.docs.paginator.navAriaLabel": "Strani z dokumenti",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Уреди ову страницу",
"theme.common.headingLinkTitle": "Веза до {heading}",
"theme.common.skipToMainContent": "Пређи на главни садржај",
"theme.docs.DocCard.categoryDescription": "{count} items",
"theme.docs.DocCard.categoryDescription.plurals": "{count} items",
"theme.docs.breadcrumbs.home": "Home page",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "странице докумената",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Redigera denna sida",
"theme.common.headingLinkTitle": "Direktlänk till {heading}",
"theme.common.skipToMainContent": "Hoppa till huvudinnehåll",
"theme.docs.DocCard.categoryDescription": "{count} artiklar",
"theme.docs.DocCard.categoryDescription.plurals": "{count} artiklar",
"theme.docs.breadcrumbs.home": "Hemsida",
"theme.docs.breadcrumbs.navAriaLabel": "Sökväg",
"theme.docs.paginator.navAriaLabel": "Dokumentsidor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Bu sayfayı düzenle",
"theme.common.headingLinkTitle": "{heading} doğrudan bağlantı",
"theme.common.skipToMainContent": "Ana içeriğe geç",
"theme.docs.DocCard.categoryDescription": "{count} öğe",
"theme.docs.DocCard.categoryDescription.plurals": "{count} öğe",
"theme.docs.breadcrumbs.home": "Ana sayfa",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Dokümanlar sayfası",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"theme.blog.post.plurals": "{count} запис|{count} записи|{count} записів",
"theme.blog.post.readMore": "Читати далі",
"theme.blog.post.readMoreLabel": "Докладніше про {title}",
"theme.blog.post.readingTime.plurals": "{readingTime} хв. читання",
"theme.blog.post.readingTime.plurals": "{readingTime} хв. читання|{readingTime} хв. читання|{readingTime} хв. читання",
"theme.blog.sidebar.navAriaLabel": "Навігація за останніми постами у блозі",
"theme.blog.tagTitle": "{nPosts} з тегом \"{tagName}\"",
"theme.colorToggle.ariaLabel": "Перемикання між темним та світлим режимом (зараз використовується {mode})",
Expand All @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Відредагувати цю сторінку",
"theme.common.headingLinkTitle": "Пряме посилання на {heading}",
"theme.common.skipToMainContent": "Перейти до основного вмісту",
"theme.docs.DocCard.categoryDescription": "{count} елемент|{count} елементи|{count} елементів",
"theme.docs.DocCard.categoryDescription.plurals": "{count} елемент|{count} елементи|{count} елементів",
"theme.docs.breadcrumbs.home": "Головна сторінка",
"theme.docs.breadcrumbs.navAriaLabel": "Навігаційний ланцюжок поточної сторінки",
"theme.docs.paginator.navAriaLabel": "сторінка документації",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "Sửa trang này",
"theme.common.headingLinkTitle": "Đường dẫn trực tiếp tới {heading}",
"theme.common.skipToMainContent": "Nhảy tới nội dung",
"theme.docs.DocCard.categoryDescription": "{count} mục",
"theme.docs.DocCard.categoryDescription.plurals": "{count} mục",
"theme.docs.breadcrumbs.home": "Trang chủ",
"theme.docs.breadcrumbs.navAriaLabel": "Breadcrumbs",
"theme.docs.paginator.navAriaLabel": "Trang tài liệu",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "编辑此页",
"theme.common.headingLinkTitle": "{heading}的直接链接",
"theme.common.skipToMainContent": "跳到主要内容",
"theme.docs.DocCard.categoryDescription": "{count} 个项目",
"theme.docs.DocCard.categoryDescription.plurals": "{count} 个项目",
"theme.docs.breadcrumbs.home": "主页面",
"theme.docs.breadcrumbs.navAriaLabel": "页面路径",
"theme.docs.paginator.navAriaLabel": "文件选项卡",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"theme.common.editThisPage": "編輯此頁",
"theme.common.headingLinkTitle": "{heading}的直接連結",
"theme.common.skipToMainContent": "跳至主要内容",
"theme.docs.DocCard.categoryDescription": "{count} 個項目",
"theme.docs.DocCard.categoryDescription.plurals": "{count} 個項目",
"theme.docs.breadcrumbs.home": "主頁面",
"theme.docs.breadcrumbs.navAriaLabel": "頁面路徑",
"theme.docs.paginator.navAriaLabel": "文件選項卡",
Expand Down