Skip to content

Two translation helper errors on profile pages (one left) #10765

Open
@jywarren

Description

@jywarren

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:

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:

<span style = "font-size:24px;"><small> <%= raw translation('users.profile.joined_time_ago', :time_ago => distance_of_time_in_words(@profile_user.created_at, Time.current, { include_seconds: false, scope: 'datetime.time_ago_in_words' })) %></small></span>

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:

<a href="/tag/<%= tag.name %>/author/<%= @profile_user.name %>"><%= translation('tag.index.notes', count: Node.find_by_tag_and_author(tag.name, @profile_user.id, 'notes').size) %></a> |
<a href="/questions/tag/<%= tag.name %>/author/<%= @profile_user.name %>"><%= translation('tag.index.questions', count: Node.find_by_tag_and_author(tag.name, @profile_user.id, 'questions').size) %></a> |
<a href="/profile/comments/<%= @profile_user.name %>/tag/<%= tag.name %>"><%= translation('tag.index.comments', count: Comment.find_by_tag_and_author(tag.name, @profile_user.id).size) %></a>
by @<%= @profile_user.name %>

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

def translation(key, options = {}, html = true)
translated_string = t(key, options)
options[:fallback] = false
translated_string2 = t(key, options)
english_translation = t(key, locale: :en)
if html && current_user&.has_tag('translation-helper') && (translated_string2.include?("translation missing") || translated_string === "") && !translated_string.include?("<")
raw(%(<span>#{english_translation} <a class="translationIcon" style='display: none; padding-left: 3px;' href="https://www.transifex.com/publiclab/publiclaborg/translate/#de/$?q=text%3A#{translated_string}">
<i data-toggle='tooltip' data-placement='top' title='Needs translation? Click to help translate the text \" #{translated_string} \" .' style='position:relative; right:2px; color:#bbb; font-size: 15px;' class='fa fa-globe'></i></a>
</span>))
else
raw(translated_string)
end
end

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    RubyTranslation Systemissues which involve adding new translations, improving the translation systembugthe issue is regarding one of our programs which faces problems when a certain task is executedhardhelp wantedrequires help by anyone willing to contribute

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions