diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 438ed29c..a55bec83 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -39,6 +39,14 @@ module ApplicationHelper content_tag(:a, body.html_safe, href: path, class: ("list-group-item #{'active ' if current_page? path}#{options[:class]}")) end + def tooltip(body, tooltip_content, placement) + content_tag(:span, body, {title: tooltip_content, "data-toggle" => "tooltip", "data-placement" => placement} ) + end + + def hidespan(body, hide) + content_tag(:span, body, class: "hidden-#{hide}") + end + ## # def bootstrap_color c diff --git a/app/views/shared/_answerbox.html.haml b/app/views/shared/_answerbox.html.haml index d1b4d95e..6d773ba2 100644 --- a/app/views/shared/_answerbox.html.haml +++ b/app/views/shared/_answerbox.html.haml @@ -23,21 +23,12 @@ %i.fa.fa-exclamation-triangle Report %h6.text-muted.media-heading.answerbox--question-user - = user_screen_name a.question.user, a.question.author_is_anonymous - asked - - if @user.nil? or a.question.author_is_anonymous - %span{title: a.question.created_at, data: { toggle: :tooltip, placement: :bottom }} - = time_ago_in_words(a.question.created_at) - - else - %a{href: show_user_question_path(a.question.user.screen_name, a.question.id)} - %span{title: a.question.created_at, data: { toggle: :tooltip, placement: :bottom }} - = time_ago_in_words(a.question.created_at) - ago + = raw t('views.answerbox.asked', user: user_screen_name(a.question.user, a.question.author_is_anonymous), time: (@user.nil? or a.question.author_is_anonymous) ? tooltip(time_ago_in_words(a.question.created_at), a.question.created_at, "bottom") : link_to(tooltip(time_ago_in_words(a.question.created_at), a.question.created_at, "bottom"),show_user_question_path(a.question.user.screen_name, a.question.id))) - unless a.question.author_is_anonymous - if a.question.answer_count > 1 ยท %a{href: show_user_question_path(a.question.user.screen_name, a.question.id)} - #{a.question.answer_count} answers + = pluralize(a.question.answer_count, t('views.general.answer')) .answerbox--question-text = a.question.content .panel-body @@ -48,7 +39,7 @@ [...] %p %a.btn.btn-primary{href: show_user_answer_path(a.user.screen_name, a.id)} - Read the entire answer + = t 'views.answerbox.read' - else .answerbox--answer-text = markdown a.content @@ -61,24 +52,16 @@ %img.img-rounded.answerbox--img{src: gravatar_url(a.user)} .media-body %h6.media-heading.answerbox--answer-user - %span.hidden-xs - Answered by - = user_screen_name a.user + = raw t('views.answerbox.answered', hide: hidespan(t('views.answerbox.hide'), "xs"), user: user_screen_name(a.user)) .answerbox--answer-date - %a{href: show_user_answer_path(a.user.screen_name, a.id)} - %span{title: a.created_at, data: { toggle: :tooltip, placement: :bottom }} - = time_ago_in_words(a.created_at) - ago + = link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id)) .col-md-6.col-sm-8.col-xs-6.text-right = render 'shared/answerbox_buttons', a: a - else .row .col-md-6.col-sm-4.col-xs-6.text-left.text-muted %i.fa.fa-clock-o - %a{href: show_user_answer_path(a.user.screen_name, a.id)} - %span{title: a.created_at, data: { toggle: :tooltip, placement: :bottom }} - = time_ago_in_words(a.created_at) - ago + = link_to((raw t('views.answerbox.time', time: tooltip(time_ago_in_words(a.created_at), a.created_at, "bottom"))), show_user_answer_path(a.user.screen_name, a.id)) .col-md-6.col-sm-8.col-xs-6.text-right = render 'shared/answerbox_buttons', a: a .panel-footer{id: "ab-comments-section-#{a.id}", style: @display_all.nil? ? 'display: none' : nil } diff --git a/config/locales/en.yml b/config/locales/en.yml index 5d540e41..e1d6d72e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -105,4 +105,10 @@ en: new: "registered %{time} ago" answers: "answered %{questions}" questions: "asked %{questions}" + answerbox: + asked: "%{user} asked %{time} ago" + read: "Read the entire answer" + answered: "%{hide} %{user}" + hide: "Answered by" + time: "%{time} ago" hello: "Hello world"