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

Add "Languages" navigation and article #6382

Merged
merged 12 commits into from
May 1, 2024

Conversation

smikitky
Copy link
Member

@smikitky smikitky commented Oct 25, 2023

This PR adds navigation from the main site (react.dev) to the individual language sites (<lang>.react.dev). It also provides instructions on how to contribute to the translation efforts.

Screenshot

This file will serve as the source of truth for all languages, and the file will be fetched within getStaticProps. The deployedLanguages variable, now extracted to a separate module (src/utils/deployedLanguages.ts), determines whether the translation has been completed for each language.

  • Added a new article titled "Translations" in the Community section.
  • Modified getStaticProps to conditionally fetch langs.json when the target article is "Translations". Here, I adopted the pattern used to implement the inline TOC to pass down the list of languages via a context. While one HTTP request is added per build, I believe the performance impact is negligible.
  • To invalidate MDX cache properly, I incorporated the language list and deployedLanguages to the cache key calculation.
  • Introduced a new MDX component called "LanguageList", which will read the language list from the context and renderes the list. The styling is minimal for now, but please let me know if this has to look closer to the legacy site.
  • Added a link to the new article in the TopNav. The SVG icon has been copied from the legacy site.

I hope this PR gets attention. Not being linked from the main site means that the translated versions won't have a high page rank, making it harder for people all over the world to discover the new docs in their language. They either don't even know that there are docs available in their language, or if they do, they wonder why they aren't linked from the main site.

Fixes: #5994

@smikitky smikitky changed the title Translations Add "Translations" navigation and article Oct 25, 2023
};
export type Languages = Array<LanguageItem>;

export const LanguagesContext = createContext<Languages | null>(null);
Copy link
Member Author

Choose a reason for hiding this comment

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

This follows the same pattern as TocContext.ts.

Comment on lines 21 to 22
// If you are a maintainer of a language fork,
// deployedTranslations has been moved to src/utils/deployedTranslations.ts.
Copy link
Member Author

Choose a reason for hiding this comment

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

This had to be extracted to a new module because it is now used by other components as well as cache key calculation.

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

Size changes

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

Five Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/404 81.24 KB (🟡 +562 B) 185.36 KB
/500 81.24 KB (🟡 +562 B) 185.36 KB
/[[...markdownPath]] 83.08 KB (🟡 +586 B) 187.2 KB
/errors 81.45 KB (🟡 +562 B) 185.57 KB
/errors/[errorCode] 81.43 KB (🟡 +562 B) 185.55 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

@smikitky smikitky marked this pull request as ready for review October 25, 2023 08:33
@smikitky smikitky changed the title Add "Translations" navigation and article Add "Languages" navigation and article Oct 25, 2023
@smikitky
Copy link
Member Author

smikitky commented Dec 11, 2023

@gaearon Could you please take a look at this or assign someone to do so? I understand that the React team is busy, but it shouldn't take half a year to add links to translations. Besides, at least in Japan, the legacy React documentation still happily sits at the top of Google search results. I suspect this is because the new site is not linked from react.dev yet...

@harish-sethuraman
Copy link
Collaborator

would be better if someone from team merges the PR. Possible that people are on holidays. cc: @mattcarrollcode

Copy link

vercel bot commented Apr 17, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
19-react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:29pm
react-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2024 4:29pm

@smikitky
Copy link
Member Author

smikitky commented Apr 17, 2024

@harish-sethuraman I resolved the conflict, so could you take a look?

I recently came across yet another Japanese SNS post saying, "I didn't know there was a Japanese version of the React docs!" And his surprise is justified. For a project as significant as this, it's hard to imagine that there may be an official translation that is complete but hasn't been linked from the original site for almost a year.

Also, in Japan at least, the old version of the React site still appears at the top of Google search results, and I suspect the lack of a visible link from the main site is one of the reasons.

@rickhanlonii
Copy link
Member

Sorry for the delay, this is awesome!!

On mobile, the header is getting pretty busy. What do you think about moving it to the bottom of the menu on mobile? Ideally we would also move the github link too:

Screenshot 2024-05-01 at 9 19 40 AM

src/content/community/translations.md Outdated Show resolved Hide resolved
src/content/community/translations.md Outdated Show resolved Hide resolved
src/content/community/translations.md Outdated Show resolved Hide resolved
src/content/community/translations.md Outdated Show resolved Hide resolved
src/content/community/translations.md Outdated Show resolved Hide resolved
src/content/community/translations.md Show resolved Hide resolved
src/utils/deployedTranslations.ts Outdated Show resolved Hide resolved
- deployedTranslations => finishedTranslations
- showTranslated => progress
- English fixes
@smikitky
Copy link
Member Author

smikitky commented May 1, 2024

On mobile, the header is getting pretty busy. What do you think about moving it to the bottom of the menu on mobile? Ideally we would also move the github link too

While I can add an icon to an existing header, adding a new area at the bottom of the screen seems difficult to me (I have never used Tailwind). Also, people usually expect to see a language icon somewhere at the top of the page. But maybe we can just reduce the gap between the icons on mobile?

@rickhanlonii
Copy link
Member

OK no worries, I can fix forward. Maybe we move the github link or something instead

@smikitky
Copy link
Member Author

smikitky commented May 1, 2024

Thank you, then I will leave the rest to you!

@Huxpro
Copy link
Member

Huxpro commented May 1, 2024

Yayyyy I'm so glad to see this merged

@smikitky
Copy link
Member Author

smikitky commented May 1, 2024

@rickhanlonii Thank you!

And...could you please take a look at this too? It's preventing us from working on the new blog posts: reactjs/translations.react.dev#315

Making a dummy commit may solve this problem.

@rickhanlonii
Copy link
Member

@Huxpro same!

@smikitky commented on the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can we add a language dropdown to the Header?
5 participants