-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Translate UI text #19102
Comments
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
I took the liberty of researching a couple of translation libraries and their associated gatsby plugins, since we have some instances of rich text (for example here and here) that could benefit from a dedicated i18n library. Results have been... mixed so far, so I figure I'd write down my thoughts on the matter for now. react-i18nextIt's not very declarative. You initialize it by calling a bunch of functions on global constants instead of passing a value to a provider. Their rich text formatting is kind of wonky: you do it by surrounding stuff you want to format in numbered XML tags (e.g. gatsby-plugin-i18nextIt's not a very well-maintained plugin and doesn't have clear instructions on how to use it. It uses an old version that doesn't have hooks, and it has a lot of forks that purport to have hotfixes, which doesn't bode well for its maintenance status. It does do something interesting though: it's able to store key-value pairs in GraphQL without having to [request all the keys] by creating a child node of the language files that store the data as stringified JSON, which the plugin then parses later. This is something we might consider doing. react-intlSo far I like it better than the gatsby-plugin-intlAHHHH. This plugin almost has everything we need. It creates pages for each locale for you, has a localized
I think the best thing would be if I can get |
Summary
Extract all English text in components to YAML translation files.
Motivation
We need to factor out English text into yaml files so that we can translate them.
Implementation
gatsby-config
a) pull in this content directly via GraphQL or
b) use an i18n library like react-intl or react-i18next and provide all the translations via a context provider.
Details
I think the best way to go about this given the considerations above is to put UI text in a top-level directory in the monorepo, with files (or subdirectories if they get too large) for each section.
Each file should be a list of key-value pairs (e.g navigation.yaml):
We should source this top-level directory in
gatsby-config
. We can then source this YAML in the components that need them using GraphQL.When we have translated versions or move packages to their own repository, we may want to consider using an i18n library that uses a context provider and hook up all the translations at the top-level, similarly to how theme-ui works.
Core Components
These components should be handled first, since they appear on (nearly) every page in Gatsby or pages in the "core docs" to translate
feedback-widget.js- we're not going to show this in non-English sites since we have no way to process it right nowThese components also appear on multiple pages:
Open Questions
Should we treat things like navigation specially? e.g. the list of navigation items or the currently existing sidebar yaml file.What i18n library should we use?The text was updated successfully, but these errors were encountered: