Skip to content

Commit d61ffd8

Browse files
7342 edit this translation (#7389)
* use translation * feat: translate "Edit this page", linking appropriately based on locale
1 parent 8fc5765 commit d61ffd8

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

apps/site/components/withMetaBar.tsx

+15-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { useFormatter } from 'next-intl';
3+
import { useFormatter, useLocale, useTranslations } from 'next-intl';
44
import type { FC } from 'react';
55

66
import MetaBar from '@/components/Containers/MetaBar';
@@ -10,6 +10,8 @@ import WithAvatarGroup from '@/components/withAvatarGroup';
1010
import { useClientContext } from '@/hooks/react-client';
1111
import useMediaQuery from '@/hooks/react-client/useMediaQuery';
1212
import { DEFAULT_DATE_FORMAT } from '@/next.calendar.constants.mjs';
13+
import { TRANSLATION_URL } from '@/next.constants.mjs';
14+
import { defaultLocale } from '@/next.locales.mjs';
1315
import { getGitHubBlobUrl } from '@/util/gitHubUtils';
1416

1517
const WithMetaBar: FC = () => {
@@ -22,6 +24,9 @@ const WithMetaBar: FC = () => {
2224
const usernames =
2325
frontmatter.authors?.split(',').map(author => author.trim()) ?? [];
2426

27+
const t = useTranslations();
28+
const locale = useLocale();
29+
2530
// Since we cannot show the same number of avatars in Mobile / Tablet
2631
// resolution as we do on desktop and there is overflow, we are adjusting
2732
// the number of avatars manually for the resolutions below
@@ -47,7 +52,15 @@ const WithMetaBar: FC = () => {
4752
'components.metabar.contribute': (
4853
<>
4954
<GitHub className="fill-neutral-700 dark:fill-neutral-100" />
50-
<Link href={getGitHubBlobUrl(filename)}>Edit this page</Link>
55+
<Link
56+
href={
57+
locale === defaultLocale.code
58+
? getGitHubBlobUrl(filename)
59+
: TRANSLATION_URL
60+
}
61+
>
62+
{t('components.metabar.contributeText')}
63+
</Link>
5164
</>
5265
),
5366
}}

apps/site/next.constants.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -187,3 +187,9 @@ export const ORAMA_CLOUD_API_KEY =
187187
* Note: This has no NEXT_PUBLIC prefix as it should not be exposed to the Browser.
188188
*/
189189
export const GITHUB_API_KEY = process.env.NEXT_GITHUB_API_KEY || '';
190+
191+
/**
192+
* The resource we point people to when discussing internationalization efforts.
193+
*/
194+
export const TRANSLATION_URL =
195+
'https://github.com/nodejs/nodejs.org/blob/main/TRANSLATION.md#how-to-translate';

0 commit comments

Comments
 (0)