hodcroftlab / covariants

Real-time updates and information about key SARS-CoV-2 variants, plus the scripts that generate this information.
https://covariants.org/
GNU Affero General Public License v3.0
316 stars 112 forks source link

Localization of this website #311

Closed tonyqus closed 2 years ago

tonyqus commented 2 years ago

I'd like to check if you accepts translation contribution of this website. I'm from Shanghai, China. I think the website is really useful for Chinese people since we are still in serious pandamic season.

emmahodcroft commented 2 years ago

Hi @tonyqus ! Thank you for reaching out and for your offer. At the moment we don't have any way to support translations, but I'm chatting with the team about whether this is something we could support. I'll try to get back to you! It would certainly be great to make CoVariants more accessible to more people!

emmahodcroft commented 2 years ago

At the moment I'm not sure we have the support available that we could make this happen - unfortunately it would require splitting out all the text areas on the website into separate files & then having these pulled in based on the language. While it would be great to support in theory, I don't think this is something our tiny team (3 people, part time) could support right now.

However, one can always translate the website in Chrome or using Google Translate!

tonyqus commented 1 year ago

I totally understand that you are a small team and you don't have time to support the localization.

I analyze your code and figure out that you are using next.js, which can support i18n (localization) easily. And I did some experiment and make it work on my local with some urls like localhost:3000/zh-CN/faq to support Chinese.

The current situation in China is a bit complex. The government starts giving up zero-covid policy and a lot of people here still believe Omicron is very dangerous due to the previous news from Chinese media and some fake medical experts. They do need a website like what you did to understand the fact of Omicron. Our official cdc website doesn't provide this kind of information.

The question is do you accept PR so that I can help you make localizaiton for Chinese happen?

tonyqus commented 1 year ago

The menu is localized in Chinese image

The major translation content is located in content folder. I can successfully load zh-CN.md file when the url routing changes to /zh-CN/xxx image

ivan-aksamentov commented 1 year ago

Hi @tonyqus,

It's not hard to add the technical implementation. Covariants is currently undergoing a rewrite and I've already added i18next and react-i18next to the new version. But it will take a little while before all other issues are resolved there. Might not get ready while it's needed in China.

We wouldn't use Next.js's i18n for that. We currently use SSG (next export) to make deployment simpler and cheaper, but Next.js i18n requires a server, so that would not work. Neither it is necessary - the same can be done client-side.

But the technical implementation is the easy part. The hard path is who will do the initial translation and then to maintain the translated versions in sync with English version when Emma changes the content. There might be more harm than good in outdated "official" content (which project maintainers are not able to understand or fix)

If you volunteer for the initial translation, then feel free to make a PR.

Regarding your screenshot of the file tree: imagine 10 languages all in one directory - it will be a disaster. It's probably better to separate languages into directories.

ivan-aksamentov commented 1 year ago

I made a first draft in https://github.com/hodcroftlab/covariants/pull/364

tonyqus commented 1 year ago

Nice to know that. Yeah, I'm willing to provide the translation in Chinese.

Which branch shall I fork to submit this translation? Or Shall I do it after you merge #364?

ivan-aksamentov commented 1 year ago

@tonyqus You can create a branch stemming from the branch feat/i18n (the branch of the PR https://github.com/hodcroftlab/covariants/pull/364) and then submit a PR from it to feat/i18n.

The markdown content will go to web/src/content/zh. It's a large amount of work, so only a portion of files can be provided for gradual translation. If you have a spare moment, you might also review the strings in web/src/i18n/resources/zh/common.json (the current ones are the automatic translation using AWS Translate).

emmahodcroft commented 1 year ago

Hi @tonyqus - just in case it's useful I made a list of all the files that would need to be manually translated in the PR @ivan-aksamentov made above.

You don't have to translate all of them -- any without translations will fallback to English. But it would probably be good to translate the Home page, and for example, perhaps the most recently relevant variants (if you think that's what might be useful).

There's no rush on our end but we'd be happy to try to incorporate anything you can manage.

tonyqus commented 1 year ago

Hi, I think I've made it work on my box.

image

I'll start translating the pages.

tonyqus commented 1 year ago

image It looks page heading are hard-coded. Can we make it possile to translate it?

ivan-aksamentov commented 1 year ago

@tonyqus I added this string to translation

If you notice any more hardcoded strings, feel free to surround them by the t() function like this:

import { useTranslationSafe } from 'src/helpers/useTranslationSafe'

const { t } = useTranslationSafe()
t('Frequently asked questions')
ivan-aksamentov commented 1 year ago

@tonyqus I don't know if the list by @emmahodcroft is of any importance. It links to master branch, which is not how things are organized on feat/i18n branch anymore, and the order of the list seems alphabetic.

Instead, you can just look at the directory web/src/content/en on the branch and all necessary English files are gathered there already. All you need is to replicate the same file and directory structure, but with translated content, and put it to web/src/content/${language}, where ${language} is zh in your case, as you correctly show on your screenshot.

You can translate incrementally. First I would focus on the most relevant pages for China. Which does not seem to be how Emma's list is organized. I would consider pages for Omicron and Delta variants, and Home page to be the most important. But I am not expert here, so feel free to chose whichever you think are important.

Once you feel the most relevant info is there, we can release the partial translation so that users can take advantage of it, and the rest of the work can continue incrementally afterwards.

emmahodcroft commented 1 year ago

Apologies for not using the locations of the files listed here, I had forgotten that they would be in a different place!

For order, I'd suggest (from highest priority):

However, this is just guidance and I'm happy for you to adjust the order if you think other things are more important or of more interest.

tonyqus commented 1 year ago

image

Two missing phrases in big title

tonyqus commented 1 year ago

373

tonyqus commented 1 year ago

image

missing phrase

emmahodcroft commented 1 year ago

Hi @tonyqus, thanks for spotting these ! @ivan-aksamentov is on holiday this week, but hopefully he can fix these couple more phrases when he's back!

ivan-aksamentov commented 1 year ago

I added these 2 strings and a couple more: d91b49a (#364) (and committed that into https://github.com/hodcroftlab/covariants/pull/364)

ivan-aksamentov commented 1 year ago

I also merged master branch into the i18n branch.

@tonyqus Note that there is 1 new variant caried from master branch:

and these 3 files had edits:

I am not sure what's the best and most reliable strategy to compare the edits in the English version and how to keep the translations in-sync. It's a very time-consuming task and requires knowledge of languages.