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

feature(www): Localize text through react-intl #21024

Closed
wants to merge 16 commits into from
Closed

feature(www): Localize text through react-intl #21024

wants to merge 16 commits into from

Conversation

tesseralis
Copy link
Contributor

@tesseralis tesseralis commented Jan 30, 2020

Description

Make text in various components localize-able using react-intl. For this PR, I focused on the components and pages that are visible in all gatsby pages (like the navigation) and most crucial to the docs (like the table of contents, sidebar "expand/collapse"). I didn't do components that we might want to disable for non-English languages, such as the feedback form and the email form.

Rationale

See this comment for why we're going with this library in particular.

Issues

  • react-intl is 48.2 kB. We need to figure out a way to only import the components we need or switch to a different library
  • Once we start loading text for pages, we need to find a way to only load critical keys and not load the page text until needed.

TODOs

  • Decide if we want to support nested keys
  • Translate more components
  • Write documentation for site maintainers and translators on how to translate strings
  • Decide if we're okay with the raw react-intl API or if we want to make more convenient wrappers

Related Issues

Fixes: #20803

@@ -0,0 +1,17 @@
docs.tableOfContents: Table of Contents
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to decide if we should support nested keys like gatsby-plugin-intl. The implementation shouldn't be too difficult. Regardless, it would be good to have some sort of namespacing to delineate different parts of the website (docs vs search vs feedback widget).

@tesseralis tesseralis marked this pull request as ready for review February 11, 2020 19:33
@tesseralis tesseralis requested a review from a team as a code owner February 11, 2020 19:33
@tesseralis tesseralis changed the title Localize text through react-intl feature(www): Localize text through react-intl Feb 11, 2020
],
},
},
// {
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you run into issues with the RSS feed or what's the context here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it broke because it tried to compile and couldn't find for the translated text in the blog page. We'd need to figure out how to fix this.

@LekoArts
Copy link
Contributor

react-intl is 48.2 kB. We need to figure out a way to only import the components we need or switch to a different library

Since I read up on LinguiJS yesterday and it has a smaller footprint. Would you be up for considering this instead of react-intl? It's certainly not a blocker, I'm just interested in seeing myself if we could use it instead.

Write documentation for site maintainers and translators on how to translate strings

Should this be a follow-up or part of this PR?


I looked through it and LGTM 👍 I like the solution for translations files and nested namespaces, that makes it easier to write!

@tesseralis
Copy link
Contributor Author

Since I read up on LinguiJS yesterday and it has a smaller footprint. Would you be up for considering this instead of react-intl? It's certainly not a blocker, I'm just interested in seeing myself if we could use it instead.

I’ve looked at lingui and it looks cool, especially the CLI. I’d want to play around with it and see what the workflow would be like for us and translators.

Should this be a follow-up or part of this PR?

Probably a follow-up. I’m still not sure what would be the right workflow (edit in the monorepo or move to translation repos) so i want to solidify that before I write docs for it

@tesseralis
Copy link
Contributor Author

Closed in favor of #21633

@tesseralis tesseralis closed this Feb 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants