Plots2: Translation prompt improvement

Created on 2 May 2019  ยท  8Comments  ยท  Source: publiclab/plots2

Currently, we show Translation prompts on /subscriptions page, some on /dashboard and /blog page.

Conditions for translation prompt:

  1. translated_string.length > 3 - If translated string has length greater than 3
  2. current_user &.has_tag('translation-helper') - User has tag translation-helper on their profile
  3. !translated_string.include?("translation missing") - There shouldn't be "translation missing" in the translated_string. This effectively means we show translation prompt only in case where translation is present.

The condition 3 is buggy or I would say totally wrong. Why? Because, previously we were running only 3 langs and in those while testing I got a span with translation missing, something like "<span class=\"translation_missing\" title=\"translation missing: ru.home.subscriptions.notes, fallback: false\">Notes</span>" but this would be returned when the translation key is not found in any locale yes, not in en.yml too but in all other cases we would get something i.e., either a translated value in the Russian. japan, etc or a English string because we fallback to English.

Let's say, we want to show prompt only in case a translation is missing in the language we are browsing publiclab.org

then, it would be something like:

Subscription page in English:

eng_as_lang

Subscription page in Russian:

russian_as_a_lang

So, you can see so many prompts because we have less Russian translations. So, what should be the conditions in which prompt should be visible?

Bugs to solve: currently, we directly wrap the returned translation in the span(prompt is made using span element), but we don't get string always in translated value some times it is code too and in those cases, :boom: :point_down: :sweat_smile:

bug

Let's collect ideas and issues about improving translation prompts here. Thanks!

Translation System discussion enhancement

Most helpful comment

  1. We could exempt any string that includes < or > for now?

Ok. Sounds good!

  1. We might limit the # of prompts to 5 per page, using css pseudo
    selectors.

Will give it a try.

Also, we want to show prompt only if a translation is not present for the current language in which we're browsing the website. Right?
Thanks!

All 8 comments

@jywarren @ebarry @steviepubliclab

Ooh, good observations!

A couple ideas.

  1. We might limit the # of prompts to 5 per page, using css pseudo
    selectors.
  2. We could exempt any string that includes < or > for now?

On Thu, May 2, 2019, 2:51 PM Gaurav Sachdeva notifications@github.com
wrote:

Currently, we show Translation prompts on /subscriptions page, some on
/dashboard and /blog page.

Conditions for translation prompt:

  1. translated_string.length > 3 - If translated string has length
    greater than 3
  2. current_user &.has_tag('translation-helper') - User has tag
    translation-helper on their profile
  3. !translated_string.include?("translation missing") - There
    shouldn't be "translation missing" in the translated_string. This
    effectively means we show translation prompt only in case where translation
    is present.

The condition 3 is buggy or I would say totally wrong. Why? Because,
previously we were running only 3 langs and in those while testing I got a
span with translation missing, something like " class=\"translation_missing\" title=\"translation missing:
ru.home.subscriptions.notes, fallback: false\">Notes" but this
would be returned when the translation key is not found in any locale yes,
not in en.yml too but in all other cases we would get something i.e.,
either a translated value in the Russian. japan, etc or a English string
because we fallback to English.

Let's say, we want to show prompt only in case a translation is missing in
the language we are browsing publiclab.org

then, it would be something like:

Subscription page in English:

[image: eng_as_lang]
https://user-images.githubusercontent.com/20878070/57098593-1d60f380-6d38-11e9-960f-bd9a3455a295.png

Subscription page in Russian:

[image: russian_as_a_lang]
https://user-images.githubusercontent.com/20878070/57098645-42556680-6d38-11e9-8d26-1cbec91932b9.png

So, you can see so many prompts because we have less Russian translations.
So, what should be the conditions in which prompt should be visible?

Bugs to solve: currently, we directly wrap the returned translation in the
span(prompt is made using span element), but we don't get string always in
translated value some times it is code too and in those cases, ๐Ÿ’ฅ ๐Ÿ‘‡ ๐Ÿ˜…

[image: bug]
https://user-images.githubusercontent.com/20878070/57099061-2acaad80-6d39-11e9-9720-147f9e8126fa.png

Let's collect ideas and issues about improving translation prompts here.
Thanks!

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/publiclab/plots2/issues/5651, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAF6J5FQLGOWIQFOB34U63PTMZZ7ANCNFSM4HKEEXWA
.

  1. We could exempt any string that includes < or > for now?

Ok. Sounds good!

  1. We might limit the # of prompts to 5 per page, using css pseudo
    selectors.

Will give it a try.

Also, we want to show prompt only if a translation is not present for the current language in which we're browsing the website. Right?
Thanks!

Reopening as limiting the prompt number on screen part is remaining @jywarren

Hi @gauravano! If you can point me at where the JS is for selecting all the prompt insertion points on the page, I can add code to get only the first 5. We could do this in jQuery with an array range or with a pseudo selector (http://nthmaster.com/, kind of cool). Should be pretty easy!

For wrapping up #5737 , would we then want to gradually convert all pages' translation texts to the new system?

And then begin finding untranslated texts that can be added into the system? This would be a great task for GCI! cc @publiclab/reviewers @SidharthBansal @CoderJolly

Ah, i see, it's in Ruby, not JS. We could set an instance variable like @translations_count ||= 0; @translations_count += 1 and then skip any where it's >5?

https://github.com/publiclab/plots2/blob/547339fbc0105c97ebb4ff51cfcef5f7c92997d0/app/helpers/application_helper.rb#L140-L151

Hi @gauravano do you think this would work? It seems an easy addition and I'm happy to make it!

Hi @jywarren, sorry missed your question. Thanks for stalebot for highlighting the mention ๐Ÿ˜„.

Ah, i see, it's in Ruby, not JS. We could set an instance variable like @translations_count ||= 0; @translations_count += 1 and then skip any where it's >5?

This can work, have to be tried. I am not sure because translation_helper lies in application_helper so count can be persisted ๐Ÿค”

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ebarry picture ebarry  ยท  3Comments

grvsachdeva picture grvsachdeva  ยท  3Comments

keshavsethi picture keshavsethi  ยท  3Comments

RuthNjeri picture RuthNjeri  ยท  3Comments

keshavsethi picture keshavsethi  ยท  3Comments