neherlab / covid19_scenarios

Models of COVID-19 outbreak trajectories and hospital demand
https://covid19-scenarios.org
MIT License
1.36k stars 354 forks source link

Internationalization #56

Open mserranom opened 4 years ago

mserranom commented 4 years ago

It would be really useful to support translations to other languages.

https://react.i18next.com/ is a reasonable option given the current tech stack

a-metta commented 4 years ago

what languages are you thinking?

mserranom commented 4 years ago

spanish at least

rapzo commented 4 years ago

I might pick this one up. And I can do the portuguese version, since we definitely need help as well!

lukepighetti commented 4 years ago

English & Spanish at a bare minimum, imo, but make it easy for people to contribute languages. And I would recommend having people do a google translate smoke test to make sure people aren't putting in messed up information if you cannot get multiple native speakers to sign off on it.

charlie632 commented 4 years ago

I can help translating to spanish and/or helping with i18Next. Let me know if you are working on this @rapzo

rapzo commented 4 years ago

Doing the setup right now. Once i get it working i'll push to my fork and will open to whomever willing to stretch a hand!

charlie632 commented 4 years ago

Great!

ErikSchierboom commented 4 years ago

I can help with the Dutch translation!

gcollard commented 4 years ago

I'll help with the French translation

samarv commented 4 years ago

I can help with hindi!

goktugerce commented 4 years ago

I can help with the Turkish translation.

t0byman commented 4 years ago

I can help with the Dutch translation!

Kerel! Hulp nodig!?

gleiderr commented 4 years ago

I can help with portuguese

Nebadon1 commented 4 years ago

Spanish if you need more people

ivan-aksamentov commented 4 years ago

That's fantastic, folks!

I've merged this PR from @rapzo https://github.com/neherlab/covid19_scenarios/pull/62/

TODO:

Issues on the horizon:

I guess it's okay for some of the rarely read and especially difficult to translate stuff to be in English for now.

What are some of the i18n services among popular now? We can hook something up to crowdsource this effort and so that translators don't have to bother with editing JSON files

Cant wait to see this going forward!

besrabasant commented 4 years ago

I will too help in Hindi.

FireLizard commented 4 years ago

I can help with the German translation.

hannesgr commented 4 years ago

I can help with the Swedish translation

rapzo commented 4 years ago

I'm gonna work on extracting all strings from components. It's a long one... But once the english is complete it will be easier to add new stuff. But if anyone is already at it please open a WIP PR so we don't overlap each other.

hannesgr commented 4 years ago

I've just started, so I'll add a WIP PR.

hannesgr commented 4 years ago

76

Emmanuel-R8 commented 4 years ago

I'll help with the French translation

Ditto

hannesgr commented 4 years ago

All right, I've tried to identify all translatable strings.

I made a complete PR Here #85. Didn't translate the About page though, not sure about how to go about that one?

ivan-aksamentov commented 4 years ago

Glorious work folks! We've got some conflicting PRs. I merged #70 and #85 can hopefully be rebased on top of it. Feel free to self-organize in the chat:

Image for the link to join the chat

Questions:

TODO (added to the list above):

hannesgr commented 4 years ago

We've got some conflicting PRs. I merged #70 and #85 can hopefully be rebased on top of it. Feel free to self-organize in the chat:

I've rebased #85

  • Do we have to replace all spaces in strings with dashes? I'd be glad if you say no, because our scientists would hate the idea :)

I updated #85 so we use spaces instead of dashes :)

Samer-Abdulaziz commented 4 years ago

I can help adding Arabic language and add some data for the middle east countries

lukepighetti commented 4 years ago

@sameerasaad do we need full RTL lang support to support Arabic?

FireLizard commented 4 years ago

Some errors occur due to missing translations of json files in ./src/assets/data/. For example when choosing the preset scenario "Country - no mitigation" it shows Error: population scenario "Deutschland" not found.

Maybe we can exclude these translation in the first place.

ivan-aksamentov commented 4 years ago

See also: @FireLizard 's PR with German translation: #77

ivan-aksamentov commented 4 years ago

@FireLizard , yeah it looks like we are translating too much.

These JSON files are generated from the external data and are not going to be translated. So Deutschland should be made back Germany before we fetch data by this key.

hannesgr commented 4 years ago

I think the best solution maybe is to exclude external data as @FireLizard mentioned, but still translate the epidemiological scenario presets (as they are not generated from external data).

I made a draft PR if you that sounds like an OK solution: #145

ivan-aksamentov commented 4 years ago

@hannesgr @FireLizard okay, I merged both and it seems to be working. Thanks a lot! Feel free to amend if anything else is missing there.

ivan-aksamentov commented 4 years ago

@hannesgr

For dropdowns we currently have a value and a label. For string-valued dropdowns these are the same. For numbers we just stringify the number I think to get a value. And for months we have a mapping of a number (0..11) to the name of the month.

https://github.com/neherlab/covid19_scenarios/blob/776503f9e77aefcb496074250aa80f6712063204/src/components/Form/FormDropdown.tsx#L6-L9

What is the best way to include countries and months dropdowns into i18n?

ivan-aksamentov commented 4 years ago

Folks, in our current implementation, how to distinguish between different flavors of languages? For example, we've got a translation from Brasil https://github.com/neherlab/covid19_scenarios/pull/165, which may or may not be the same as the Portuguese one, same for Spanish. Also would be nice to be prepared for different dialects of Chinese etc.

RTL situation is unclear.

Don't hesitate to pick the remaining TODOs https://github.com/neherlab/covid19_scenarios/issues/56#issuecomment-601990919 and to add your favorite languages!

Forcing a cc, sorry :) @besrabasant @charlie632 @Emmanuel-R8 @ErikSchierboom @FireLizard @gcollard @gleiderr @goktugerce @hannesgr @lukepighetti @mserranom @n0f3 @Nebadon1 @rapzo @samarv @sameerasaad @t0byman

hannesgr commented 4 years ago

@hannesgr

For dropdowns we currently have a value and a label. For string-valued dropdowns these are the same. For numbers we just stringify the number I think to get a value. And for months we have a mapping of a number (0..11) to the name of the month.

https://github.com/neherlab/covid19_scenarios/blob/776503f9e77aefcb496074250aa80f6712063204/src/components/Form/FormDropdown.tsx#L6-L9

What is the best way to include countries and months dropdowns into i18n?

I think for translating month names, the easiest solution might be to change the locale of moment https://momentjs.com/docs/#/i18n/changing-locale/. Could be done in the same callback where we set the i18next language https://github.com/neherlab/covid19_scenarios/blob/master/src/components/LanguageSwitcher/index.tsx.

I can look into it and take a look at translating country names

whiver commented 4 years ago

Hi all, Is there already something existing to extract the new translation keys from the code and merge them in the translation files? (like i18next-scanner) I'm looking at the French translation and it looks like there is a lot of missing strings, but hard to find which ones.

A "Translation" section in the readme would definitely help ramping up! ☺

whiver commented 4 years ago

As mentioned in #494, I tried to integrate GitLocalize on my fork to see how it works: it's super easy to install & configure (nothing to add on the repo, it took me 2 min to configure it). So maybe it could be a good thing to use it to ease the translation process, it would help having up-to-date translations, and if we need to have something more powerful, we can still migrate to a hosted Weblate or something like that. You can try it on my fork to see what it looks like: https://gitlocalize.com/repo/4297

noleti commented 4 years ago

@rneher as far as I understand, now that https://github.com/neherlab/covid19_scenarios/pull/494 is merged, you or @ivan-aksamentov will have to set up the gitlocalize thing to allow creation of translations and PR requests.

ivan-aksamentov commented 4 years ago

@whiver @noleti Created gitlocalize and added you both as admins.

Is there a way to skip navigation to src/locales/en/translation.json when chosing a language there? Feel free to simplify the folder structure if needed.

Would you also like to evaluate whatever Locize service offers?

whiver commented 4 years ago

@ivan-aksamentov I'm not sure that we can skip the navigation, I'll file an issue about that on their repo. I can take a look at Locize if you're confident that you can setup a free instance for the project. I'll keep you posted, I'm first trying to finish up my PR about the import.

whiver commented 4 years ago

I tested Locize a bit but from what I understand I'm not a big fan: there is no git integration, so you have to configure i18next to fetch the translations from their server at runtime. That's also how new strings are added to the platform. This implies extra calls to an external dependency (and no versioning for the translated files).

Though it seems that they are providing a CLI to import/export translations, but that means that we would have to periodically sync Locize with the repo, I'm not sure if that's the best option.

Otherwise the UI is pretty cool and you can add context to help translate the strings: image

ivan-aksamentov commented 4 years ago

@whiver Extra dependencies and network calls are out of question of course, but what if we automate Locize with CI and/or PR bots? It is a fairly popular platform and seems to be recommended by i18next. Pretty sire there are existing solutions.

I don't have any strong opinion on Gitlocalize vs Locize though.