OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Change texts to handle singular vs plural better
Henriette Darge406c525439a0
diff --git a/app/helpers/mail_digest_helper.rb b/app/helpers/mail_digest_helper.rbindex 67bf356cb2f..70900cf54bd 100644--- a/app/helpers/mail_digest_helper.rb+++ b/app/helpers/mail_digest_helper.rb@@ -30,14 +30,18 @@module MailDigestHelperdef digest_summary_text(notification_count, mentioned_count)- if mentioned_count > 0- I18n.t(:'mail.digests.summary_with_mentioned',- number_unread: notification_count,- number_mentioned: mentioned_count)- else- I18n.t(:'mail.digests.summary',- number_unread: notification_count)+ mentioned = mentioned_count > 1 ? 'plural' : 'singular'+ notifications = notification_count > 1 ? 'plural' : 'singular'++ summary = I18n.t(:"mail.digests.unread_notification_#{notifications}",+ number_unread: notification_count).to_s++ unless mentioned_count === 0+ summary << " #{I18n.t(:"mail.digests.including_mention_#{mentioned}",+ number_mentioned: mentioned_count)}"end++ summaryenddef digest_notification_timestamp_text(notification, html: true, extended_text: false)diff --git a/app/helpers/mail_notification_helper.rb b/app/helpers/mail_notification_helper.rbindex fafa1f3a664..ae54ae6a835 100644--- a/app/helpers/mail_notification_helper.rb+++ b/app/helpers/mail_notification_helper.rb@@ -35,8 +35,9 @@ module MailNotificationHelpercurrent_logo = CustomStyle.current.logo unless CustomStyle.current.nil?if current_logo.present?- logo = File.read(current_logo.local_file)- suffix = MIME::Types.type_for(current_logo.local_file.path).first.content_type+ logo_file = current_logo.local_file+ logo = File.read(logo_file)+ suffix = MIME::Types.type_for(logo_file.path).first.content_typeelselogo = Rails.application.assets["logo_openproject_narrow.svg"]suffix = "svg+xml"diff --git a/app/mailers/digest_mailer.rb b/app/mailers/digest_mailer.rbindex 6562e205cc1..41310248890 100644--- a/app/mailers/digest_mailer.rb+++ b/app/mailers/digest_mailer.rb@@ -36,6 +36,7 @@ class DigestMailer < ApplicationMailerinclude OpenProject::StaticRouting::UrlHelpersinclude OpenProject::TextFormattinginclude Redmine::I18n+ include MailDigestHelperhelper :mail_digest,:mail_notification@@ -73,28 +74,8 @@ class DigestMailer < ApplicationMailerreturn if @aggregated_notifications.empty?- project_count = @aggregated_notifications- .keys- .map(&:project_id)- .uniq- .size-with_locale_for(recipient) do- if @mentioned_count > 0- subject = I18n.t('mail.digests.work_packages.subject_with_mentioned',- instance_name: Setting.app_title,- notifications: notification_ids.size,- mentioned: @mentioned_count,- work_packages: @aggregated_notifications.size,- projects: project_count)- else-- subject = I18n.t('mail.digests.work_packages.subject',- instance_name: Setting.app_title,- notifications: notification_ids.size,- work_packages: @aggregated_notifications.size,- projects: project_count)- end+ subject = "#{Setting.app_title} - #{digest_summary_text(notification_ids.size, @mentioned_count)}"mail to: recipient.mail,subject: subjectdiff --git a/app/views/digest_mailer/work_packages.html.erb b/app/views/digest_mailer/work_packages.html.erbindex 359359556fa..ffeadc3606c 100644--- a/app/views/digest_mailer/work_packages.html.erb+++ b/app/views/digest_mailer/work_packages.html.erb@@ -1,6 +1,6 @@<%= render partial: 'mailer/notification_mailer_header',locals: {- summary: digest_summary_text(@notification_ids.length, @mentioned_count)+ summary: "#{I18n.t(:'mail.digests.you_have')} #{digest_summary_text(@notification_ids.length, @mentioned_count)}"} %><% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>diff --git a/app/views/digest_mailer/work_packages.text.erb b/app/views/digest_mailer/work_packages.text.erbindex 3681f7ed00f..3bcb4135a93 100644--- a/app/views/digest_mailer/work_packages.text.erb+++ b/app/views/digest_mailer/work_packages.text.erb@@ -1,5 +1,5 @@<%= I18n.t(:'mail.salutation', user: @user.firstname) %>-<%= digest_summary_text(@notification_ids.length, @mentioned_count) %>+<%= "#{I18n.t(:'mail.digests.you_have')} #{digest_summary_text(@notification_ids.length, @mentioned_count)}" %><%= "-" * 100 %><% @aggregated_notifications.first(DigestMailer::MAX_SHOWN_WORK_PACKAGES).each do | work_package, notifications_by_work_package| %>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 849a3c7e88e..d31002da0a7 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -1967,8 +1967,10 @@ en:mail:actions: 'Actions'digests:- summary: "You have %{number_unread} unread notifications"- summary_with_mentioned: "You have %{number_unread} unread notifications including %{number_mentioned} mentions"+ including_mention_singular: 'including a mention'+ including_mention_plural: 'including %{number_mentioned} mentions'+ unread_notification_singular: '1 unread notification'+ unread_notification_plural: '%{number_unread} unread notifications'work_packages:comment_added: '<b>Comment</b> added'created: 'Created'@@ -1984,10 +1986,9 @@ en:subscribed: 'all'prefix: 'Received because of the notification setting: %{reason}'see_all: 'See all'- subject: '%{instance_name} - %{notifications} unread notification(s) in %{work_packages} work package(s)'- subject_with_mentioned: '%{instance_name} - %{notifications} unread notification(s) including %{mentioned} mention(s) in %{work_packages} work package(s), in %{projects} projects'updated: 'Updated'updated_at: 'at %{timestamp} by %{user}'+ you_have: 'You have'logo_alt_text: 'Logo'notification:center: 'To notification center'diff --git a/spec/features/notifications/digest_mail_spec.rb b/spec/features/notifications/digest_mail_spec.rbindex 3b0b758aea7..1ba1004b122 100644--- a/spec/features/notifications/digest_mail_spec.rb+++ b/spec/features/notifications/digest_mail_spec.rb@@ -135,9 +135,6 @@ describe "Digest email", type: :feature, js: true do.to be 1expect(ActionMailer::Base.deliveries.first.subject)- .to eql I18n.t(:'mail.digests.work_packages.subject',- instance_name: Setting.app_title,- notifications: 1,- work_packages: 1)+ .to eql "OpenProject - 1 unread notification including a mention"endenddiff --git a/spec/mailers/digest_mailer_spec.rb b/spec/mailers/digest_mailer_spec.rbindex 3a6e7c8ccda..89c51353ed2 100644--- a/spec/mailers/digest_mailer_spec.rb+++ b/spec/mailers/digest_mailer_spec.rb@@ -85,10 +85,7 @@ describe DigestMailer, type: :mailer doit 'notes the day and the number of notifications in the subject' doexpect(mail.subject)- .to eql I18n.t('mail.digests.work_packages.subject',- instance_name: Setting.app_title,- notifications: 1,- work_packages: 1)+ .to eql "OpenProject - 1 unread notification"endit 'sends to the recipient' do@@ -111,6 +108,7 @@ describe DigestMailer, type: :mailer doendit 'includes the notifications grouped by work package' do+ time_stamp = journal.created_at.strftime('%I:%M %p')expect(mail_body).to have_text("Hey #{recipient.firstname}!")@@ -122,11 +120,11 @@ describe DigestMailer, type: :mailer doexpect(mail_body).to have_text(expected_notification_header, normalize_ws: true)- expected_journal_text = "Comment added at #{journal.created_at.strftime('%I:%M %p')} by #{recipient.name}"+ expected_journal_text = "Comment added at #{time_stamp} by #{recipient.name}"expect(mail_body).to have_text(expected_journal_text, normalize_ws: true)- expected_details_text = "Subject changed from old subject to new subject at #{journal.created_at.strftime('%I:%M %p')} by #{recipient.name}"+ expected_details_text = "Subject changed from old subject to new subject at #{time_stamp} by #{recipient.name}"expect(mail_body).to have_text(expected_details_text, normalize_ws: true)end