-
Notifications
You must be signed in to change notification settings - Fork 28
Add i18n and l10n with lingui and babel #772
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
base: main
Are you sure you want to change the base?
Conversation
|
@goanpeca is attempting to deploy a commit to the xarray Team on Vercel. A member of the Team first needs to authorize it. |
aadbd9f to
405cf9f
Compare
|
For context, here's some initial discussion around this topic: pydata/xarray#9094 |
|
The PR has now selected all localizable strings. I added a simple dropdown but I need some help in getting it to actually change the language. |
|
Hi @andersy005 :) Wanted to know what we could do to help move this forward Thanks! |
|
thank you for your patience, @goanpeca! very cool to see this addition to the site! let's remove the RSS feed files (atom.xml, rss.json, rss.xml) from git. these aren't meant to be pushed. @jhamman, i no longer have permissions to approve the vercel deployment. do you mind authorizing it so we can check how it looks in staging? after that, we can merge to prod. |
|
Hi @andersy005 thanks! Will make the changes and ping you :) |
I made the updates @andersy005 ! Thanks 🚀 cc @jhamman 🙈 |
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.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Thanks @jhamman , there seems to be some issue but I cannot access the logs, any pointers to debug this? Thanks |
|
Here are the logs: |
@jhamman, can we bump the node version in our vercel settings? |
|
Hi @jhamman and @andersy005, wanted to ask if the vercel configuration could be updated 😄 ? Thanks! 🚀 |
|
I've bumped our node version to @andersy005 - do you have bandwidth this week to help unblock here? |
|
Hi, We've moved to netlfiy and now use node version |
|
I can help push this forward - thanks for the ping! I am traveling at the moment but can take a look probably around Nov 10. Does that work? |
sounds great! I've left a note on my calendar to check back then. Excited to to work to get this in. |
|
Thanks for the ping! I'm currently working on the rebase, will ping you once I have it solved. Cheers! |
|
Ok! I think I got it but I can't push to this PR - @goanpeca would you mind giving me access to your fork so I can finish this up? Thanks a bunch! 😄 |
Done @melissawm ! |
✅ Deploy Preview for xarraydev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
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.
Pull Request Overview
This PR adds internationalization (i18n) and localization (l10n) infrastructure to the xarray website using Lingui and Babel. The site is currently translated into Portuguese (Brazilian) and Spanish, with the framework in place for additional languages.
Key changes:
- Integration of Lingui for message extraction and translation management
- Addition of language switcher component for users to select their preferred language
- Conversion of static strings to translatable strings using the
tmacro throughout the codebase
Reviewed Changes
Copilot reviewed 35 out of 37 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Added Lingui packages (@lingui/cli, @lingui/core, @lingui/react, @lingui/loader, @lingui/babel-plugin-lingui-macro) and updated various dependencies |
| src/i18n.ts | Created i18n initialization logic and catalog loading functionality |
| src/pages/_app.js | Wrapped app with I18nProvider and added translation loading via useLinguiInit |
| src/locales/pt/messages.po | Added Portuguese (Brazilian) translations |
| src/locales/es/messages.po | Added Spanish translations |
| src/pages/index.js | Added getStaticProps for translation loading and wrapped strings with t macro |
| src/pages/team.js | Wrapped translatable strings with t macro |
| src/pages/dashboard.js | Wrapped translatable strings with t macro |
| src/data/projects.js | Converted from static export to function returning translated data |
| src/data/menu-items.js | Converted from static export to function returning translated data |
| src/data/footer-items.js | Converted from static export to function returning translated data |
| src/data/features.js | Converted from static export to function returning translated data |
| src/components/sponsors.js | Wrapped translatable strings with t macro |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/components/layout.js
Outdated
| */ | ||
| const { t } = useLingui() | ||
| const router = useRouter() | ||
| const { pathname, asPath, query } = router |
Copilot
AI
Nov 19, 2025
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.
Unused variable asPath.
| const { pathname, asPath, query } = router | |
| const { pathname, query } = router |
src/components/layout.js
Outdated
| */ | ||
| const { t } = useLingui() | ||
| const router = useRouter() | ||
| const { pathname, asPath, query } = router |
Copilot
AI
Nov 19, 2025
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.
Unused variable query.
| const { pathname, asPath, query } = router |
src/pages/dashboard.js
Outdated
| @@ -1,12 +1,14 @@ | |||
| import { IssueTracker, ProjectMetrics } from '@/components/dashboard' | |||
| import { Layout } from '@/components/layout' | |||
| import { Trans, useLingui } from '@lingui/react/macro' | |||
Copilot
AI
Nov 19, 2025
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.
Unused import Trans.
|
Thank you @goanpeca ❤️ ❤️ I will take a look at the copilot review and try to address it shortly. |
ianhi
left a comment
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 seems to have broken the display of blog articles. The listing of them is still fine (although only avaiable in english) but the actual articles are giving me a 500 error:
https://deploy-preview-772--xarraydev.netlify.app/es/blog/xarray-napari-plan
that happens with or without the language code in the url
|
Also, what would be the steps after this PR for someone who wanted to make a change to the wording on the site. Would they only need to change the english version in the code, or do they also need to do things on the translation website and update the We should include the documentation of how to do so in the README |
|
Hmmm let me check - I did test the blog locally and it worked, but it may be something else. |
|
One more thing. On this PR, but not on main, |
Co-authored-by: Copilot <[email protected]>
for more information, see https://pre-commit.ci
|
Ok - I tried solving the npm issues and I can confirm it builds without error for me with both npm and yarn. The blog also works fine for me locally, although I did see it fail on the netlify deployment. Not sure what's going on there... This PR doesn't touch the blog at all so I will have to think about how to debug this. I also realized it looks like I requested a copilot review but I in fact didn't (not explicitly, anyways) so I tried addressing the issues (which were mostly fair) but not sure if there's anything else I can do there. I will work on some documentation but right now we have it all set up so that translations will not come through this repo at all. All the translation work happens on scientific-python.crowdin.com (see https://github.com/Scientific-Python-Translations/xarray-translations), and gets synced through one PR from the scientificpythontranslations bot when new translations are created. We have some documentation here but I'm happy to add a note explaining it all to your docs as well. Cheers! |
Hello, folks!
This PR adds a language switcher and some logic to deal with multiple languages on the xarray website. Using lingui and babel.
Currently, as part of the Scientific Python grant, we have the site 100% translated into Portuguese (Brazilian) and Spanish. Other languages may follow soon - having the infrastructure set up will hopefully help us recruit new translators 😄
We have been working on the automation process for the sync between crowdin and the websites and can help answer any questions you might have.
This PR is a proof of concept and we are happy to adapt to any specific format or needs you might have here. Feedback is appreciated.
Thanks!
Desktop
Mobile
Moving forward
Ensure all translatable strings are wrapped up in the
tmacro. Yarn build will extract and compile the translations stringsand the rest of the work will happen automatically on https://github.com/Scientific-Python-Translations/xarray-translations and crowding with the volunteer contributors.
For components and pages
For data: convert the object to a function so the
tmacro can work.