flattenthecurve / guide

https://www.flattenthecurve.com
Creative Commons Attribution 4.0 International
38 stars 33 forks source link

Images on COVID-19 page are not translated #393

Open rousik opened 4 years ago

rousik commented 4 years ago

I have assumed that PNG pictures embedded on COVID-19 page used to have their labels translated. This is no longer case. I do not know why. We should try to fix that.

rousik commented 4 years ago

The problem seems to be due to image paths. Absolute paths /images/${stuff}.png always point to the english version. If we use relative path such as images/${stuff}.png, this will not be found as the translated images reside under /${lang}/images/${stuff}.png. Relative to COVID-19 page this should be ../images/${stuff}.png. Maybe there's a way to detect and fix these?

rousik commented 4 years ago

Ideally there would be a programmatic way to fix /images/ paths to the correct localized destination when the site is built. It is unclear if that is easily possible.

rousik commented 4 years ago

Alternatively we could "fix" this in the import_language.rb script by looking for ]((|/)images/*.svg) and replacing it with ](/$lang/images/*.svg) within files below _sections/COVID-19.

rousik commented 4 years ago

I have used the following sequence for a temporary fix:

cd _sections/COVID-19
sed -i 's/(image/(\/image/' $(grep -r '(images' | grep -v en/))
grep '(/images' -r | grep -v en/ | \
  while read f ; do l=$(echo $f|cut -f1 -d/) ; sed -i "s/(\/images/(\/$l\/images/" $f ; done