BustByte / coronastatus

Anonymous crowd sourcing of COVID-19 symptoms all over the world (with public data sets)!
MIT License
173 stars 89 forks source link

Sync missing translation keys in app/locales/*.json files to a Google Sheet #481

Open michaelmcmillan opened 4 years ago

michaelmcmillan commented 4 years ago

The script is heavily commented with what I've been thinking. There might be a logical error here, so please read through the script to see if it makes sense.

This script will produce false positives (since it looks at all changes to the file ever). Why did I make it like that? Because translations are added at different points in time – a new feature branch will contain new translations, while all the existing branches and locales will be missing those.

This will produce some false positives (translations which have been removed etc.), but it in turn include translations which are being worked on right now in different branches (which should allow us to start translating before the PR is done, and widen the bottleneck which is currently halting PRs). We could also just add the false positives to an ignore list to make them go away.

I'm hoping this should make it easier for us to quickly grab all missing translations for all locales and then handing them off to a non-technical person that don't know JSON or git, maybe via. a more friendly medium like Google Sheets.

This is what I get if I run the script right now for no, en-IN and se.

no missing translation for: Sweden ... basically means that the Norwegian locale (no.json) has never had a row in its JSON file where the key is Sweden and the value is Sverige.

Does this make sense? Haha, I'm actually not sure. Here's the full output:

no missing translation for: Sweden
no missing translation for: https://www.whatismyzip.com
no missing translation for: What is my Zip code?
---
se missing translation for: this
se missing translation for: https://who.org
se missing translation for:  article as an attempt to chart these numbers.
se missing translation for: In total <%= numberWithSpaces(totalPeopleInContactWithInfected) %> people have reported that they have been in close contact with a person who was tested positive for COVID-19.
se missing translation for: In total <%= numberWithSpaces(totalInfectedPeopleWithSymptoms) %> people have reported that they have tested positive for COVID-19 and experience symptoms.
se missing translation for: In total <%= numberWithSpaces(totalPeopleInContactWithInfected) %> people have reported that they have been tested for COVID-19.
se missing translation for: Join the most important crowdsource! Regardless if you're healthy or not, please submit the form below – that is also valuable information!
se missing translation for: Zip code information
se missing translation for: Netherlands
se missing translation for:  if you can't get it to work.
se missing translation for: I agree to my being data in accordance with the privacy statement
se missing translation for: To WHO.org
se missing translation for: /healthcondition/
se missing translation for: Using self-report, you can get a better picture of how many people have symptoms without exposing health workers to potential contamination hazards and without using up valuable infection control equipment that is already in short supply. We at Bustbyte, well helped by other volunteers, have created this tool in response to
se missing translation for: In total <%= numberWithSpaces(totalPeopleWithSymptoms) %> people have reported that they experience symptoms.
---
en-IN missing translation for: this
en-IN missing translation for: https://who.org
en-IN missing translation for:  article as an attempt to chart these numbers.
en-IN missing translation for: In total <%= numberWithSpaces(totalPeopleInContactWithInfected) %> people have reported that they have been in close contact with a person who was tested positive for COVID-19.
en-IN missing translation for: In total <%= numberWithSpaces(totalInfectedPeopleWithSymptoms) %> people have reported that they have tested positive for COVID-19 and experience symptoms.
en-IN missing translation for: In total <%= numberWithSpaces(totalPeopleInContactWithInfected) %> people have reported that they have been tested for COVID-19.
en-IN missing translation for: Join the most important crowdsource! Regardless if you're healthy or not, please submit the form below – that is also valuable information!
en-IN missing translation for: Zip code information
en-IN missing translation for: Netherlands
en-IN missing translation for:  if you can't get it to work.
en-IN missing translation for: I agree to my being data in accordance with the privacy statement
en-IN missing translation for: To WHO.org
en-IN missing translation for: /healthcondition/
en-IN missing translation for: Using self-report, you can get a better picture of how many people have symptoms without exposing health workers to potential contamination hazards and without using up valuable infection control equipment that is already in short supply. We at Bustbyte, well helped by other volunteers, have created this tool in response to
en-IN missing translation for: In total <%= numberWithSpaces(totalPeopleWithSymptoms) %> people have reported that they experience symptoms.
fossecode commented 4 years ago

Nice! Couple of questions:

  1. When and who runs the script? On PRs?
  2. Does it make sense to run it on all branches and all commits, or should we only run it on the current state on the branch you are on?
  3. Any reasons javascript is used instead of typescript?
michaelmcmillan commented 4 years ago

Nice! Couple of questions:

  1. When and who runs the script? On PRs?

Not sure what's best. PRs would work

  1. Does it make sense to run it on all branches and all commits, or should we only run it on the current state on the branch you are on?

See comment above.

  1. Any reasons javascript is used instead of typescript?

Wanted to crank it out fast. Types can be added.

fossecode commented 4 years ago

Great job, I think it will make it much easier to handle translations :)

michaelmcmillan commented 4 years ago

Just tested this on @sbocinec's PR #483 and it seems to have worked 👍

Screenshot 2020-03-30 at 00 09 17
fossecode commented 4 years ago

Just tested this on @sbocinec's PR #483 and it seems to have worked 👍

Screenshot 2020-03-30 at 00 09 17

Haha nice, also found this bug from looking at the picture: https://github.com/BustByte/coronastatus/commit/b2988f401286d0f54f3c9d7e2e65f37d81329f16

fossecode commented 4 years ago

Although a few of the keys are not part of the translations anymore. Maybe add a whitelist or something where we can declare those?

michaelmcmillan commented 4 years ago

Next step before it's ready to merge:

  1. Find a way of git fetching all PRs to local.
  2. Add sync in the other direction (from Sheet to locale.json).
trkoch commented 4 years ago

@michaelmcmillan hub (an extension to git) might be of use for fetching PRs.