From 3a5c8d8c9e5db8c541501fe74c03e8a31fe606a1 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 12 Jun 2024 14:36:21 +0200 Subject: [PATCH 1/2] enhance(toc): localize "In this article" header --- client/src/document/organisms/toc/index.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client/src/document/organisms/toc/index.tsx b/client/src/document/organisms/toc/index.tsx index dd2f7bb1dec2..2364af6da52f 100644 --- a/client/src/document/organisms/toc/index.tsx +++ b/client/src/document/organisms/toc/index.tsx @@ -5,8 +5,23 @@ import { Toc } from "../../../../../libs/types/document"; import { useFirstVisibleElement } from "../../hooks"; import { useGleanClick } from "../../../telemetry/glean-context"; import { TOC_CLICK } from "../../../telemetry/constants"; +import { useLocale } from "../../../hooks"; +import { DEFAULT_LOCALE } from "../../../../../libs/constants"; + +const DEFAULT_TITLE = { + "en-US": "In this article", + es: "En este artículo", + fr: "Dans cet article", + ja: "この記事では", + ko: "이 문서에서는", + "pt-BR": "Neste artigo", + ru: "В этой статье", + "zh-CN": "在本文中", + "zh-TW": "在本文中", +}; export function TOC({ toc, title }: { toc: Toc[]; title?: string }) { + const locale = useLocale(); const [currentViewedTocItem, setCurrentViewedTocItem] = useState(""); const observedElements = React.useCallback(() => { @@ -45,7 +60,7 @@ export function TOC({ toc, title }: { toc: Toc[]; title?: string }) {

- {title || "In this article"} + {title || DEFAULT_TITLE[locale] || DEFAULT_TITLE[DEFAULT_LOCALE]}