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

enhance(toc): localize "In this article" header #11303

Merged
merged 3 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: "この記事では",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdn/yari-content-ja Would you mind taking a look if this translation is correct?

PS: Please note that this is a one-off UI localization, and currently we do not accept any community PRs for UI localization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdn/yari-content-ja Do you have any comments about this translation? 🙏

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@caugner
I am noticed this now. I'm sorry for too late reply.
"この記事では" looks odd, and "この記事内" looks better.

ko: "목차",
"pt-BR": "Neste artigo",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdn/yari-content-pt-br Would you mind taking a look if this translation is correct?

PS: Please note that this is a one-off UI localization, and currently we do not accept any community PRs for UI localization.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdn/yari-content-pt-br Do you have any comments about this translation? 🙏

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