plots2 icon indicating copy to clipboard operation
plots2 copied to clipboard

Two translation helper errors on profile pages (one left)

Open jywarren opened this issue 3 years ago • 15 comments

The Translation helper is supposed to insert a little globe icon for some users, where you can contribute missing translations.

Learn about the translation system at:

  • https://publiclab.org/wiki/translation
  • https://github.com/publiclab/plots2/blob/main/doc/Translation_System.md

Unfortunately it is broken in a few places:

image

To see this yourself, you have to log in, join the translation team at https://publiclab.org/wiki/translation, and visit https://publiclab.org/profile/warren or another profile page.

What's wrong?

Note that to the right side it says Joined %{time_ago} - something must be going wrong with this line of code:

https://github.com/publiclab/plots2/blob/7de0bb0eab2e7e63d0143244b76c211f4498d042/app/views/users/profile.html.erb#L63

Also, in the left column under "Remembering Tonawanda" it says:

{:one=>"1 note", :other=>"%{count} notes"} | {:one=>"1 question", :other=>"%{count} questions"} | {:one=>"1 comment", :other=>"%{count} comments"} by @warren

That leads to this line of code:

https://github.com/publiclab/plots2/blob/7de0bb0eab2e7e63d0143244b76c211f4498d042/app/views/tag/_profileCard.html.erb#L27-L30

There, I think we are passing back a hash instead of a number... somehow we're misusing the helper, which can be found here:

https://github.com/publiclab/plots2/blob/a54bf46102c1951734ab94966b4f9e867b0b2762/app/helpers/application_helper.rb#L157-L170

This is a pretty complex pair of issues. I'm not sure how easy they will be to fix -- so we're hoping for someone with a little Ruby experience to help out here! Thanks!

jywarren avatar Mar 08 '22 22:03 jywarren

@jywarren I am unable to see this error on https://publiclab.org/profile/warren (screenshot below), even though I've joined the translation team. image

KarishmaVanwari avatar Mar 09 '22 07:03 KarishmaVanwari

@KarishmaVanwari You need to change the site's language to one that doesn't have a lot of translations. For example: Deutsch

TildaDares avatar Mar 09 '22 08:03 TildaDares

Okay, thank you @TildaDares

KarishmaVanwari avatar Mar 10 '22 08:03 KarishmaVanwari

Hey @TildaDares, can I try my hands on this issue?

KarishmaVanwari avatar Mar 10 '22 20:03 KarishmaVanwari

Go ahead @KarishmaVanwari

TildaDares avatar Mar 10 '22 20:03 TildaDares

Hi @KarishmaVanwari how did that go, were you able to reproduce this? I can try to help if not!

jywarren avatar Mar 15 '22 17:03 jywarren

Hey @jywarren, I was still unable to reproduce the error, could you please help me out?

KarishmaVanwari avatar Mar 18 '22 20:03 KarishmaVanwari

@KarishmaVanwari Was if on the live site or your local environment that you couldn’t reproduce the bug?

TildaDares avatar Mar 19 '22 07:03 TildaDares

@TildaDares On the live site. I've successfully reproduced the bug locally.

KarishmaVanwari avatar Mar 20 '22 12:03 KarishmaVanwari

Hi @jywarren, @KarishmaVanwari, distance_of_time_in_words can translate on its own when you pass in the scope method. So we don't need to pass that method into the translate function. I created an FTO to fix that in #10849. Also, some of the translation file keys use distance_in_words instead of time_ago_in_words so I created an issue in #10850 to resolve that too. I think when these issues are resolved, the first translation problem will be solved.

@KarishmaVanwari I think with this solution you should be able to resolve the second error.

TildaDares avatar Mar 27 '22 15:03 TildaDares

Great work figuring this all out! Very much appreciated @TildaDares and @KarishmaVanwari 🎉

jywarren avatar Mar 29 '22 17:03 jywarren

Just noting that the topic card bug shown here is now resolved in stable:

image

The second bug, near "Joined" is also resolved!

image

Thank you all very much for your help!!!

jywarren avatar May 17 '22 17:05 jywarren

Hi @KarishmaVanwari - I noticed this small error on profile pages with translations: https://publiclab.org/profile/carmen2x

image

I think it's returning a more structured associative array (or hash, i think the Ruby term is) of counts per type, instead of just a number. The code is here:

https://github.com/publiclab/plots2/blame/main/app/views/tag/_profileCard.html.erb#L27-L29

I'm not sure we fixed that one... @TildaDares what do you think? Maybe when I confirmed it in stable, it didn't have a translation turned on? Stable is offline right now but will be back up pretty soon so we can check, but locally we can check by changing the language and looking at that page.

If the issue persists, I think we may need to do something like: translation(...)[:one] -- but maybe something more complicated with pluralization is going on -- maybe it'll take a little experimenting to get it right.

jywarren avatar Jun 23 '22 04:06 jywarren

@jywarren I think that line works fine, it's a lack of translation for those phrases that causes that issue. If you change the language to French, everything works great and that's because we only have translations for those phrases in French.

https://github.com/publiclab/plots2/blob/112f78925df2c03f5422179f4572210781035006/config/locales/fr.yml#L342-L350

That was the same thing that happened to the joined error I fixed earlier.

TildaDares avatar Jun 23 '22 07:06 TildaDares

Ah, thanks @TildaDares and sorry to miss this. I think we need to fix the logic for when there is no translation:

https://github.com/publiclab/plots2/blob/3b7222e5655e41ea4e7102ddbdcb1510932b6228/app/views/tag/_profileCard.html.erb#L27-L29

See how it looks here:

image

jywarren avatar Aug 02 '22 15:08 jywarren