From af327b3f08f684809e7abc68b8524e59890b75bd Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Thu, 7 Jul 2022 01:15:20 +0200 Subject: [PATCH] Add translations for notification types --- app/views/notifications/type/_answer.haml | 13 +++++----- app/views/notifications/type/_comment.haml | 24 +++++++++++-------- .../type/{_relationship.haml => _follow.haml} | 2 +- app/views/notifications/type/_reaction.haml | 19 +++++++-------- 4 files changed, 30 insertions(+), 28 deletions(-) rename app/views/notifications/type/{_relationship.haml => _follow.haml} (69%) diff --git a/app/views/notifications/type/_answer.haml b/app/views/notifications/type/_answer.haml index 0c3d781d..147c25fb 100644 --- a/app/views/notifications/type/_answer.haml +++ b/app/views/notifications/type/_answer.haml @@ -4,19 +4,18 @@ .media-body .notification__heading %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } - = user_screen_name notification.target.user - answered - = link_to 'your question', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id) - = time_tooltip(notification.target) - ago + = t(".heading_html", + user: user_screen_name(notification.target.user), + question: link_to(t(".link_text"), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.id)), + time: time_tooltip(notification.target)) .list-group .list-group-item .media.question-media .media-body - %h6.notification__list-heading question + %h6.notification__list-heading= t("activerecord.models.question.one") = markdown notification.target.question.content[0..60] + (notification.target.question.content.length > 60 ? '[...]' : '') .list-group-item .media.question-media .media-body - %h6.notification__list-heading answer + %h6.notification__list-heading= t("activerecord.models.answer.one") = markdown notification.target.content[0..60] + (notification.target.content.length > 60 ? '[...]' : '') diff --git a/app/views/notifications/type/_comment.haml b/app/views/notifications/type/_comment.haml index 02ee271a..f678e2b8 100644 --- a/app/views/notifications/type/_comment.haml +++ b/app/views/notifications/type/_comment.haml @@ -4,25 +4,29 @@ .media-body .notification__heading %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } - = user_screen_name notification.target.user - commented on - if notification.target.answer.user == current_user - = link_to 'your answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = t(".active.heading_html", + user: user_screen_name(notification.target.user), + answer: link_to(t(".active.link_text"), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + time: time_tooltip(notification.target)) - elsif notification.target.user == notification.target.answer.user - = link_to 'their answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) + = t(".passive.heading_html", + user: user_screen_name(notification.target.user), + answer: link_to(t(".passive.link_text"), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + time: time_tooltip(notification.target)) - else - = link_to "#{notification.target.answer.user.screen_name}'s answer", - show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id) - = time_tooltip(notification.target) - ago + = t(".other.heading_html", + user: user_screen_name(notification.target.user), + answer: link_to(t(".other.link_text", user: user_screen_name(notification.target.answer.user)), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.answer.id)), + time: time_tooltip(notification.target)) .list-group .list-group-item .media.question-media .media-body - %h6.notification__list-heading answer + %h6.notification__list-heading= t("activerecord.models.answer.one") = markdown notification.target.answer.content[0..60] + (notification.target.answer.content.length > 60 ? '[...]' : '') .list-group-item .media.question-media .media-body - %h6.notification__list-heading comment + %h6.notification__list-heading= t("activerecord.models.comment.one") = markdown notification.target.content[0..60] + (notification.target.content.length > 60 ? '[...]' : '') diff --git a/app/views/notifications/type/_relationship.haml b/app/views/notifications/type/_follow.haml similarity index 69% rename from app/views/notifications/type/_relationship.haml rename to app/views/notifications/type/_follow.haml index 8e0cf3cf..c71a9819 100644 --- a/app/views/notifications/type/_relationship.haml +++ b/app/views/notifications/type/_follow.haml @@ -5,4 +5,4 @@ %h6.media-heading.notification__user = user_screen_name notification.target.source .notification__text - = raw t('views.notifications.relationship.body', time: time_ago_in_words(notification.target.created_at)) + = t(".heading_html", time: time_ago_in_words(notification.target.created_at)) diff --git a/app/views/notifications/type/_reaction.haml b/app/views/notifications/type/_reaction.haml index 850fa4c5..4a08d8f7 100644 --- a/app/views/notifications/type/_reaction.haml +++ b/app/views/notifications/type/_reaction.haml @@ -4,20 +4,19 @@ .media-body .notification__heading %img.avatar-xs{ src: notification.target.user.profile_picture.url(:small) } - = user_screen_name notification.target.user - smiled - if notification.target.parent_type == 'Answer' - = link_to 'your answer', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.parent.id) + = t(".#{notification.target.parent_type.downcase}.heading_html", + user: user_screen_name(notification.target.user), + type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.parent.id)), + time: time_tooltip(notification.target)) - elsif notification.target.parent_type == 'Comment' - = link_to 'your comment', show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.parent.answer.id) - = time_tooltip(notification.target) - ago + = t(".#{notification.target.parent_type.downcase}.heading_html", + user: user_screen_name(notification.target.user), + type: link_to(t(".#{notification.target.parent_type.downcase}.link_text"), show_user_answer_path(username: notification.target.user.screen_name, id: notification.target.parent.answer.id)), + time: time_tooltip(notification.target)) .list-group .list-group-item .media.question-media .media-body - - if notification.target.parent_type == 'Answer' - %h6.notification__list-heading answer - - elsif notification.target.parent_type == 'Comment' - %h6.notification__list-heading comment + %h6.notification__list-heading= t("activerecord.models.#{notification.target.parent_type.downcase}.one") = markdown notification.target.parent.content[0..60] + (notification.target.parent.content.length > 60 ? '[...]' : '')