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
i18n working day changed notice in journal
ulfertsdaac761b308d
diff --git a/app/workers/work_packages/apply_working_days_change_job.rb b/app/workers/work_packages/apply_working_days_change_job.rbindex 5b78169e10a..3d34a3cdbfb 100644--- a/app/workers/work_packages/apply_working_days_change_job.rb+++ b/app/workers/work_packages/apply_working_days_change_job.rb@@ -101,16 +101,23 @@ class WorkPackages::ApplyWorkingDaysChangeJob < ApplicationJobdef set_journal_notice(updated_work_packages, previous_working_days)day_changes = changed_days(previous_working_days).index_with { |day| Setting.working_days.include?(day) }+ journal_note = journal_notice_text(day_changes)updated_work_packages.uniq.each do |work_package|- changes = day_changes.collect { |day, working| working_day_change_message(day, working) }-- work_package.journal_notes = "Working days changed (#{changes.join(', ')})."+ work_package.journal_notes = journal_notework_package.saveendend+ def journal_notice_text(day_changes)+ I18n.with_locale(Setting.default_language) do+ I18n.t(:'working_days.journal_note.changed',+ changes: day_changes.collect { |day, working| working_day_change_message(day, working) }.join(', '))+ end+ end+def working_day_change_message(day, working)- "#{I18n.t('date.day_names')[day]} is now #{working ? 'working' : 'non-working'}"+ I18n.t(:"working_days.journal_note.days.#{working ? :working : :non_working}",+ day: I18n.t('date.day_names')[day])endenddiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 8895dadb1b3..ea6eaed8243 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3112,6 +3112,11 @@ en:change_button: "Change working days"warning: >Changing which days of the week are considered working days can affect the start and finish days of all work packages in all projects in this instance.+ journal_note:+ changed: _**Working days** changed (%{changes})._+ days:+ working: "%{day} is now working"+ non_working: "%{day} is now non-working"nothing_to_preview: "Nothing to preview"api_v3:diff --git a/spec/features/admin/working_days_spec.rb b/spec/features/admin/working_days_spec.rbindex 12d2d933802..82227304e81 100644--- a/spec/features/admin/working_days_spec.rb+++ b/spec/features/admin/working_days_spec.rb@@ -116,14 +116,11 @@ describe 'Working Days', type: :feature, js: true dofollower | XXX |CHART- [earliest_work_package,- second_work_package,- follower].each do |work_package|- expect(work_package.journals.count)- .to eq 2- expect(work_package.journals.last.notes)- .to include("Working days changed (Monday is now non-working, Friday is now non-working).")- end+ # The updated work packages will have a journal entry informing about the change+ wp_page = Pages::FullWorkPackage.new(earliest_work_package)+ wp_page.visit!++ wp_page.expect_comment(text: "Working days changed (Monday is now non-working, Friday is now non-working).")endit 'shows error when non working days are all unset' dodiff --git a/spec/workers/work_packages/apply_working_days_change_job_spec.rb b/spec/workers/work_packages/apply_working_days_change_job_spec.rbindex 87bd0789b86..92a7f59ad39 100644--- a/spec/workers/work_packages/apply_working_days_change_job_spec.rb+++ b/spec/workers/work_packages/apply_working_days_change_job_spec.rb@@ -96,7 +96,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dowp_start_only,wp_due_only]end- let(:journal_notice) { "Working days changed (Wednesday is now non-working)." }+ let(:journal_notice) { "**Working days** changed (Wednesday is now non-working)." }endend@@ -123,7 +123,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dolet(:changed_work_packages) do[work_package]end- let(:journal_notice) { "Working days changed (Wednesday is now non-working)." }+ let(:journal_notice) { "**Working days** changed (Wednesday is now non-working)." }endend@@ -149,7 +149,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dolet(:changed_work_packages) do[work_package]end- let(:journal_notice) { "Working days changed (Saturday is now working)." }+ let(:journal_notice) { "**Working days** changed (Saturday is now working)." }endend@@ -177,7 +177,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dolet(:changed_work_packages) do[predecessor, follower]end- let(:journal_notice) { "Working days changed (Wednesday is now non-working)." }+ let(:journal_notice) { "**Working days** changed (Wednesday is now non-working)." }endend@@ -208,7 +208,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dolet(:unchanged_work_packages) do[predecessor]end- let(:journal_notice) { "Working days changed (Wednesday is now non-working)." }+ let(:journal_notice) { "**Working days** changed (Wednesday is now non-working)." }endend@@ -297,7 +297,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob dolet(:unchanged_work_packages) do[follower]end- let(:journal_notice) { "Working days changed (Wednesday is now working)." }+ let(:journal_notice) { "**Working days** changed (Wednesday is now working)." }endend@@ -406,7 +406,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do[wp1, wp2, wp3]endlet(:journal_notice) do- "Working days changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."+ "**Working days** changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."endendend@@ -449,7 +449,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do[wp1, wp2, wp3]endlet(:journal_notice) do- "Working days changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."+ "**Working days** changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."endendend@@ -487,7 +487,7 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do[wp2]endlet(:journal_notice) do- "Working days changed (Tuesday is now working, Wednesday is now working, Friday is now working)."+ "**Working days** changed (Tuesday is now working, Wednesday is now working, Friday is now working)."endendend@@ -522,7 +522,32 @@ RSpec.describe WorkPackages::ApplyWorkingDaysChangeJob do[wp1, wp2, wp3]endlet(:journal_notice) do- "Working days changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."+ "**Working days** changed (Tuesday is now non-working, Wednesday is now non-working, Friday is now non-working)."+ end+ end+ end++ context 'when having a non english default language', with_settings: { default_language: :fr } do+ let_schedule(<<~CHART)+ days | fssMTWTFSS |+ work_package | X▓▓XX ░░ |+ CHART++ before do+ set_working_week_days('saturday')+ end++ # Not interested in the scheduling changes in this spec+ it_behaves_like 'journal updates with note' do+ let(:changed_work_packages) do+ [work_package]+ end+ let(:journal_notice) do+ I18n.with_locale(:fr) do+ I18n.t(:'working_days.journal_note.changed',+ changes: I18n.t(:'working_days.journal_note.days.working',+ day: I18n.t('date.day_names')[6]))+ endendendend