Skip to content

Use i18n for common strings #280

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

Open
avivkeller opened this issue May 26, 2025 · 14 comments
Open

Use i18n for common strings #280

avivkeller opened this issue May 26, 2025 · 14 comments
Assignees
Labels
enhancement New feature or request

Comments

@avivkeller
Copy link
Member

While we can't translate the docs themselves, we can translate some of our constant strings.

Now that i18n is publishable, we can add a --lang flag to the CLI to generate docs with different languages.

@avivkeller avivkeller added the enhancement New feature or request label May 26, 2025
@flakey5
Copy link
Member

flakey5 commented May 26, 2025

How would these be distributed in releases? Putting them into subfolders like https://nodejs.org/docs/latest/api/<locale>/buffer.html?

@AugustinMauroy
Copy link
Member

If I recall correctly, the TSC completely vetoed the translation.

@avivkeller
Copy link
Member Author

Can you link that? I thought they vetoed translating the docs themselves, (the files in core), not the strings we use to generate them (the files here).

While we can't provide fully translated docs, we can at least translate some of the commonly used phrases (I.e. "Source Code: ", "Added in: ", etc.)

@avivkeller avivkeller self-assigned this May 27, 2025
@AugustinMauroy
Copy link
Member

cc @ovflowd

@avivkeller avivkeller assigned avivkeller and unassigned avivkeller May 27, 2025
@avivkeller
Copy link
Member Author

I'll work on adding a --locale flag today.

@ovflowd
Copy link
Member

ovflowd commented May 28, 2025

The TSC vettoed translation for the API docs. Navigation cues (and other common strings) should be translateable. Unfortunately due to the nature of API docs, these need to be purely on the client-side. In other words the "content" should not be translated, but anything that is layout/component should be translateable.

Meaning:

  • Static generated JSON files part of the JS bundle
  • React does a client-side switch (and stores translation key on a local storage)
  • next-intl also works that way on a client-side-only mode; But since we don't use Next.js here, we gotta use use-intl (https://www.npmjs.com/package/use-intl) which is the underlying core of next-intl

@flakey5
Copy link
Member

flakey5 commented May 29, 2025

Just confirming- we can do this on the client side w/o requiring js to run in the client's browser, correct?

@ovflowd
Copy link
Member

ovflowd commented May 29, 2025

Just confirming- we can do this on the client side w/o requiring js to run in the client's browser, correct?

wdym? React is client side JavaScript running on the Client-Side browser.

@flakey5
Copy link
Member

flakey5 commented May 29, 2025

wdym? React is client side JavaScript running on the Client-Side browser.

Re nodejs/node#52343 (comment)

@ovflowd
Copy link
Member

ovflowd commented May 29, 2025

wdym? React is client side JavaScript running on the Client-Side browser.

Re nodejs/node#52343 (comment)

Ah yes, then it just goes to English :)

@ovflowd
Copy link
Member

ovflowd commented May 29, 2025

But without JS you will also not be able to open the history and other features. Rendering the docs will still work but interactible elements maybe not. I guess we can do the history one with pure CSS maybe.

@ovflowd
Copy link
Member

ovflowd commented May 29, 2025

Even the language seledctor could be pure CSS and just triggers elements with certain language to render based on class name.

@flakey5
Copy link
Member

flakey5 commented May 29, 2025

Sgtm - js is definitely needed for some of the features but I still wanna make sure it's not made necessary for the entire page

@avivkeller
Copy link
Member Author

avivkeller commented May 29, 2025

Right now (in the draft generator) it is, but I'm actively working on getting React's dehydration to work, allowing the page to render without JS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants