Skip to content

Commit 1bbd815

Browse files
nilkhankariMikeMcC399bmuenzenmeyerAugustinMauroy
authored
fix: Added translation for snippet in package manager in download (#6907)
* fix: Added translation for snippet in package manager in download * Addressed comments from code review Co-authored-by: Mike McCready <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]> Signed-off-by: Nilesh Khankari <[email protected]> * refactor: updated misspelled word version * chore: remove resolved todo Signed-off-by: Augustin Mauroy <[email protected]> --------- Signed-off-by: Nilesh Khankari <[email protected]> Signed-off-by: Augustin Mauroy <[email protected]> Co-authored-by: Mike McCready <[email protected]> Co-authored-by: Brian Muenzenmeyer <[email protected]> Co-authored-by: Augustin Mauroy <[email protected]>
1 parent f553623 commit 1bbd815

3 files changed

Lines changed: 76 additions & 52 deletions

File tree

apps/site/components/Downloads/Release/ReleaseCodeBox.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ const ReleaseCodeBox: FC = () => {
2020
const t = useTranslations();
2121

2222
useEffect(() => {
23-
const updatedCode = getNodeDownloadSnippet(release, os)[platform];
23+
const updatedCode = getNodeDownloadSnippet(release, os, t)[platform];
2424
// Docker and NVM support downloading tags/versions by their full release number
2525
// but usually we should recommend users to download "major" versions
26-
// since our Downlooad Buttons get the latest minor of a major, it does make sense
26+
// since our Download Buttons get the latest minor of a major, it does make sense
2727
// to request installation of a major via a package manager
2828
memoizedShiki
2929
.then(shiki => highlightToHtml(shiki)(updatedCode, 'bash'))

apps/site/i18n/locales/en.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,26 @@
292292
"codeBox": {
293293
"systemManagerWarning": "is not a Node.js package manager. Please ensure you already have {packageManager} installed.",
294294
"communityWarning": "Package managers and their installation scripts are not maintained by the Node.js project.",
295-
"communityWarningReport": "If you encounter issues, please reach out to the package manager's maintainers."
295+
"communityWarningReport": "If you encounter issues, please reach out to the package manager's maintainers.",
296+
"installsNvm": "installs nvm (Node Version Manager)",
297+
"downloadAndInstallNodejsRestartTerminal": "download and install Node.js (you may need to restart the terminal)",
298+
"verifiesRightNodejsVersion": "verifies the right Node.js version is in the environment",
299+
"verifiesRightNpmVersion": "verifies the right npm version is in the environment",
300+
"shouldPrint": "should print `{version}`",
301+
"installsFnm": "installs fnm (Fast Node Manager)",
302+
"downloadAndInstallNodejs": "download and install Node.js",
303+
"noteWithColon": "NOTE:",
304+
"dockerIsNotNodejsPackageManager": "Docker is not a Node.js package manager.",
305+
"PleaseEndureAlreadyInstallOnSystem": "Please ensure it is already installed on your system.",
306+
"dockerInstructions": "Follow official instructions at https://docs.docker.com/desktop/",
307+
"dockerImagesLink": "Docker images are provided officially at https://github.com/nodejs/docker-node/",
308+
"pullsNodejsDockerImage": "pulls the Node.js Docker image",
309+
"homebrewIsNotNodejsPackageManager": "Homebrew is not a Node.js package manager.",
310+
"homebrewInstructions": "Follow official instructions at https://brew.sh/",
311+
"homebrewSupportsIntallingMajorNodejsVersion": "Homebrew only supports installing major Node.js versions and might not support the latest Node.js version from the {version} release line.",
312+
"chocolateyIsNotNodejsPackageManager": "Chocolatey is not a Node.js package manager.",
313+
"chocolateyInstructions": "Follow official instructions at https://chocolatey.org/",
314+
"chocolateyNotMaintanedByNodejs": "Chocolatey is not officially maintained by the Node.js project and might not support the {version} version of Node.js"
296315
}
297316
}
298317
}

apps/site/util/getNodeDownloadSnippet.ts

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import dedent from 'dedent';
2+
import type { TranslationValues } from 'next-intl';
23

34
import type { NodeRelease } from '@/types';
45
import type { PackageManager } from '@/types/release';
56
import type { UserOS } from '@/types/userOS';
67

7-
// @TODO: These snippets should be extracted to i18n (?)
8-
export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
8+
export const getNodeDownloadSnippet = (
9+
release: NodeRelease,
10+
os: UserOS,
11+
t: (key: string, values?: TranslationValues) => string
12+
) => {
913
const snippets: Record<PackageManager, string> = {
1014
NVM: '',
1115
FNM: '',
@@ -16,94 +20,95 @@ export const getNodeDownloadSnippet = (release: NodeRelease, os: UserOS) => {
1620

1721
if (os === 'WIN' || os === 'MAC' || os === 'LINUX') {
1822
snippets.DOCKER = dedent`
19-
# NOTE:
20-
# Docker is not a Node.js package manager. Please ensure it is already installed
21-
# on your system. Follow official instructions at https://docs.docker.com/desktop/
22-
# Docker images are provided officially at https://github.com/nodejs/docker-node/
23+
# ${t('layouts.download.codeBox.noteWithColon')}
24+
# ${t('layouts.download.codeBox.dockerIsNotNodejsPackageManager')}
25+
# ${t('layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem')}
26+
# ${t('layouts.download.codeBox.dockerInstructions')}
27+
# ${t('layouts.download.codeBox.dockerImagesLink')}
2328
24-
# pulls the Node.js Docker image
29+
# ${t('layouts.download.codeBox.pullsNodejsDockerImage')}
2530
docker pull node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'}
2631
27-
# verifies the right Node.js version is in the environment
28-
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} node -v # should print \`${release.versionWithPrefix}\`
32+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
33+
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.versionWithPrefix })}
2934
30-
# verifies the right NPM version is in the environment
31-
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} npm -v # should print \`${release.npm}\``;
35+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
36+
docker run node:${release.major}-${release.major >= 4 ? 'alpine' : 'slim'} npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
3237
}
3338

3439
if (os === 'MAC' || os === 'LINUX') {
3540
snippets.NVM = dedent`
36-
# installs nvm (Node Version Manager)
41+
# ${t('layouts.download.codeBox.installsNvm')}
3742
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
3843
39-
# download and install Node.js (you may need to restart the terminal)
44+
# ${t('layouts.download.codeBox.downloadAndInstallNodejsRestartTerminal')}
4045
nvm install ${release.major}
4146
42-
# verifies the right Node.js version is in the environment
43-
node -v # should print \`${release.versionWithPrefix}\`
47+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
48+
node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.versionWithPrefix })}
4449
45-
# verifies the right NPM version is in the environment
46-
npm -v # should print \`${release.npm}\``;
50+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
51+
npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
4752

4853
snippets.FNM = dedent`
49-
# installs fnm (Fast Node Manager)
54+
# ${t('layouts.download.codeBox.installsFnm')}
5055
curl -fsSL https://fnm.vercel.app/install | bash
5156
52-
# download and install Node.js
57+
# ${t('layouts.download.codeBox.downloadAndInstallNodejs')}
5358
fnm use --install-if-missing ${release.major}
5459
55-
# verifies the right Node.js version is in the environment
56-
node -v # should print \`${release.versionWithPrefix}\`
60+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
61+
node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.versionWithPrefix })}
5762
58-
# verifies the right NPM version is in the environment
59-
npm -v # should print \`${release.npm}\``;
63+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
64+
npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
6065

6166
snippets.BREW = dedent`
62-
# NOTE:
63-
# Homebrew is not a Node.js package manager. Please ensure it is already installed
64-
# on your system. Follow official instructions at https://brew.sh/
65-
# Homebrew only supports installing major Node.js versions and might not support
66-
# the latest Node.js version from the ${release.major} release line.
67+
# ${t('layouts.download.codeBox.noteWithColon')}
68+
# ${t('layouts.download.codeBox.homebrewIsNotNodejsPackageManager')}
69+
# ${t('layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem')}
70+
# ${t('layouts.download.codeBox.homebrewInstructions')}
71+
# ${t('layouts.download.codeBox.homebrewSupportsIntallingMajorNodejsVersion', { version: release.major })}
6772
68-
# download and install Node.js
73+
# ${t('layouts.download.codeBox.downloadAndInstallNodejs')}
6974
brew install node@${release.major}
7075
71-
# verifies the right Node.js version is in the environment
72-
node -v # should print \`${release.versionWithPrefix}\`
76+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
77+
node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.versionWithPrefix })}
7378
74-
# verifies the right NPM version is in the environment
75-
npm -v # should print \`${release.npm}\``;
79+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
80+
npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
7681
}
7782

7883
if (os === 'WIN') {
7984
snippets.FNM = dedent`
80-
# installs fnm (Fast Node Manager)
85+
# ${t('layouts.download.codeBox.installsFnm')}
8186
winget install Schniz.fnm
8287
83-
# download and install Node.js
88+
# ${t('layouts.download.codeBox.downloadAndInstallNodejs')}
8489
fnm use --install-if-missing ${release.major}
8590
86-
# verifies the right Node.js version is in the environment
87-
node -v # should print \`${release.versionWithPrefix}\`
91+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
92+
node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.versionWithPrefix })}
8893
89-
# verifies the right NPM version is in the environment
90-
npm -v # should print \`${release.npm}\``;
94+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
95+
npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
9196

9297
snippets.CHOCO = dedent`
93-
# NOTE:
94-
# Chocolatey is not a Node.js package manager. Please ensure it is already installed
95-
# on your system. Follow official instructions at https://chocolatey.org/
96-
# Chocolatey is not officially maintained by the Node.js project and might not
97-
# support the ${release.versionWithPrefix} version of Node.js
98+
# ${t('layouts.download.codeBox.noteWithColon')}
99+
# ${t('layouts.download.codeBox.chocolateyIsNotNodejsPackageManager')}
100+
# ${t('layouts.download.codeBox.PleaseEndureAlreadyInstallOnSystem')}
101+
# ${t('layouts.download.codeBox.chocolateyInstructions')}
102+
# ${t('layouts.download.codeBox.chocolateyNotMaintanedByNodejs', { version: release.versionWithPrefix })}
98103
99-
# download and install Node.js
104+
# ${t('layouts.download.codeBox.downloadAndInstallNodejs')}
100105
choco install nodejs${release.isLts ? '-lts' : ''} --version="${release.version}"
101106
102-
# verifies the right Node.js version is in the environment
103-
node -v # should print \`${release.major}\`
107+
# ${t('layouts.download.codeBox.verifiesRightNodejsVersion')}
108+
node -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.major })}
104109
105-
# verifies the right NPM version is in the environment
106-
npm -v # should print \`${release.npm}\``;
110+
# ${t('layouts.download.codeBox.verifiesRightNpmVersion')}
111+
npm -v # ${t('layouts.download.codeBox.shouldPrint', { version: release.npm })}`;
107112
}
108113

109114
return snippets;

0 commit comments

Comments
 (0)