-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implement react i18next #9261
Implement react i18next #9261
Conversation
6cc04d0
to
e3c74c2
Compare
1c5ba6a
to
2c5ad4f
Compare
6f6cbf2
to
40e1bf9
Compare
@@ -243,7 +243,7 @@ export const query = graphql` | |||
locales: allLocale( | |||
filter: { | |||
language: { in: $languagesToFetch } | |||
ns: { in: ["src-templates-docs", "components", "common"] } | |||
ns: { in: ["page-developers-docs", "common"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the namespaces have the same name as the files under src/intl
.
@@ -189,8 +189,6 @@ const StaticPage = ({ | |||
const { editContentUrl } = siteData.siteMetadata || {} | |||
const absoluteEditPath = `${editContentUrl}${relativePath}` | |||
|
|||
const slug = mdx.fields?.slug || "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This slug
is incorrrect. This slug
is always the /en/
version. To fix this, now we are getting it from the pageContext
.
40e1bf9
to
71f234d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice one! This really improves load times from some testing. Noticed a couple things. Happy to sync up and talk about this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, approving since dev will be merged into this branch that will include #9537
@pettinarip @corwintines reviewed light / dark themes, mobile layouts and 2 different languages. Mostly looks goods, only few things down here: |
Thanks @konopkja for the review 💪🏼
tldr, I'll fix those missing translations & update the branch. |
This PR implements react-i18next and creates & loads the locales in a different way than #8866 to avoid having memory consumption problems.
Description
Preview deploy: https://ethereumorgwebsitei18nrework.gatsbyjs.io/en/
In short, instead of
mergeTranslations
in one big file, all the json files undersrc/intl
are loaded as they are, keeping the same namespaces. Then, on each page, we query only the necessary namespace that that page needs.To do this efficiently, we had to reorder some translations from one namespace to another. Basically to avoid loading an entire namespace just for 1 translation. For example, adding new strings on
common.json
is very expensive since that file is loaded on all the pages we have (at the moment 12k pages), so I tried my best to reduce that file to the minimum.Other things done in this PR:
createLocales
script was completely redone. Checkdocs/locale-process.md
for more informationmergeTranslations
script is not more needed and it was deletedunusedTranslations
script addedreorgIntlFiles
script addedyarn.lock
was regenerated with latest packages versions (this one mitigates a wall of warnings we had on dev env)Note: for ease to review purposes, I didn't run the
reorgIntl
script yet. I'll include that on a different PR. What that script is going to do is to apply the same reorgs I did onsrc/intl/en
to all the other languages.Note2: stress tests were executed here #9455