Add i18n and l10n with lingui and babel#772
Add i18n and l10n with lingui and babel#772goanpeca wants to merge 36 commits intoxarray-contrib:mainfrom
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 🙈 |
|
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. |
|
I looked into the broken blog pages in a loop with claude. it came to this conclusion: The root cause is that This worked locally because of how
On Netlify (or any direct URL access), there's no prior page visit to initialize lingui. The static page tries to call The fix is to add import { loadCatalog } from '../../i18n'
export async function getStaticProps({ params, locale }) {
const translation = await loadCatalog(locale)
// ... existing code ...
return { props: { /* ...existing props..., */ translation } }
} |
✅ Deploy Preview for xarraydev ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
I think pretty much there! Thanks for the direction @ianhi - I did it slightly differently just because even with those changes the blog was still trying to serve localized versions of the posts, which I don't think we want anyway. For disclosure, I did use some AI assistance to figure out some of the errors I didn't know how to fix, but I have reviewed and modified the code myself. |
|
thank you for sticking with this @melissawm ! fixing these weird kinds of errors is the worst. a great use for AI code assistance. I appreciate the clear statement re usage. Its looking great. Just a few more small issues. The language picker is still available on teh blog. if you click it the content stays fine, but header gets broken: in pt the header css might need changeing because a word got longer. not really sure if there is a nice solution here: not everything is translated. is this because no one translated it, or because it didn't get integrated into the translation site? |
|
Thanks @ianhi ! I removed the switcher from the blog pages and adjusted the fit on the header - let me know if this is an acceptable solution. Potentially, if translated content is too large we could have problems. I don't really think it'll happen though. |
|
About the missing translations: Although our dashboard says the site is 100% translated, I believe this work was completed after this initial PR was created. This means after it is merged, we may need a new sync with the crowdin hook. |
ianhi
left a comment
There was a problem hiding this comment.
Amazing stuff thank you! I checked through the depths of the javascript with claude and found a few minor issues (e.g. the metpy isn't translated because the t is on the wrong side of the backtick. But I think we should fix in a follow up after seeing how sync the new crowdin etc.
|
Awesome! Once this is merged, I'll make sure to follow up with any fixes that are necessary. Thank you so much for your patience! |



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.