From 3d23e2c470c090ff4f37abe4c6abe73e390febbd Mon Sep 17 00:00:00 2001 From: Claas Augner <495429+caugner@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:10:19 +0200 Subject: [PATCH] enhance(toc): localize "In this article" header (#11303) Note: Currently, we do not accept any community PRs for UI localization. Co-authored-by: 1ilsang <1ilsang@naver.com> --- 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..2e36be93dbfb 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]}