Skip to content

Commit

Permalink
enhance(toc): localize "In this article" header (#11303)
Browse files Browse the repository at this point in the history
Note: Currently, we do not accept any community PRs for UI localization.

Co-authored-by: 1ilsang <1ilsang@naver.com>
  • Loading branch information
caugner and 1ilsang authored Jul 9, 2024
1 parent 702afab commit 439736b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion client/src/document/organisms/toc/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -45,7 +60,7 @@ export function TOC({ toc, title }: { toc: Toc[]; title?: string }) {
<section className="document-toc">
<header>
<h2 className="document-toc-heading">
{title || "In this article"}
{title || DEFAULT_TITLE[locale] || DEFAULT_TITLE[DEFAULT_LOCALE]}
</h2>
</header>
<ul className="document-toc-list">
Expand Down

0 comments on commit 439736b

Please sign in to comment.