From c31a6719735114c371e5da68eb3787b8713c5360 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Sun, 13 Dec 2009 04:06:55 +0000 Subject: [PATCH] Added a setting to configure the day that week start on (Monday or Sunday). (#4363) git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3166 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 10 ++++++++++ app/views/settings/_display.rhtml | 3 +++ config/locales/bg.yml | 1 + config/locales/bs.yml | 1 + config/locales/ca.yml | 1 + config/locales/cs.yml | 1 + config/locales/da.yml | 1 + config/locales/de.yml | 1 + config/locales/el.yml | 1 + config/locales/en.yml | 1 + config/locales/es.yml | 1 + config/locales/fi.yml | 1 + config/locales/fr.yml | 1 + config/locales/gl.yml | 1 + config/locales/he.yml | 1 + config/locales/hu.yml | 1 + config/locales/it.yml | 1 + config/locales/ja.yml | 1 + config/locales/ko.yml | 1 + config/locales/lt.yml | 1 + config/locales/nl.yml | 1 + config/locales/no.yml | 1 + config/locales/pl.yml | 1 + config/locales/pt-BR.yml | 1 + config/locales/pt.yml | 1 + config/locales/ro.yml | 1 + config/locales/ru.yml | 1 + config/locales/sk.yml | 1 + config/locales/sl.yml | 1 + config/locales/sr.yml | 1 + config/locales/sv.yml | 1 + config/locales/th.yml | 1 + config/locales/tr.yml | 1 + config/locales/uk.yml | 1 + config/locales/vi.yml | 1 + config/locales/zh-TW.yml | 1 + config/locales/zh.yml | 1 + config/settings.yml | 2 ++ lib/redmine/helpers/calendar.rb | 9 ++++++++- 39 files changed, 58 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3e1d6cea8..cdb64f417 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -659,8 +659,18 @@ module ApplicationHelper unless @calendar_headers_tags_included @calendar_headers_tags_included = true content_for :header_tags do + start_of_week = case Setting.start_of_week.to_i + when 1 + 'Calendar._FD = 1;' # Monday + when 7 + 'Calendar._FD = 0;' # Sunday + else + '' # use language + end + javascript_include_tag('calendar/calendar') + javascript_include_tag("calendar/lang/calendar-#{current_language.to_s.downcase}.js") + + javascript_tag(start_of_week) + javascript_include_tag('calendar/calendar-setup') + stylesheet_link_tag('calendar') end diff --git a/app/views/settings/_display.rhtml b/app/views/settings/_display.rhtml index 351760fa1..10a081935 100644 --- a/app/views/settings/_display.rhtml +++ b/app/views/settings/_display.rhtml @@ -7,6 +7,9 @@

<%= select_tag 'settings[default_language]', options_for_select( lang_options_for_select(false), Setting.default_language) %>

+

+<%= select_tag 'settings[start_of_week]', options_for_select( [[l(:label_language_based), ''], [day_name(1),'1'], [day_name(7),'7']] , Setting.start_of_week) %>

+

<%= select_tag 'settings[date_format]', options_for_select( [[l(:label_language_based), '']] + Setting::DATE_FORMATS.collect {|f| [Date.today.strftime(f), f]}, Setting.date_format) %>

diff --git a/config/locales/bg.yml b/config/locales/bg.yml index 07dfe794f..0ca7cddb6 100644 --- a/config/locales/bg.yml +++ b/config/locales/bg.yml @@ -853,3 +853,4 @@ bg: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/bs.yml b/config/locales/bs.yml index 9bf78abf2..8e317f7dd 100644 --- a/config/locales/bs.yml +++ b/config/locales/bs.yml @@ -877,3 +877,4 @@ bs: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/ca.yml b/config/locales/ca.yml index 77cd1fce1..d23aa30eb 100644 --- a/config/locales/ca.yml +++ b/config/locales/ca.yml @@ -856,3 +856,4 @@ ca: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 095e41236..a90fbf80f 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -859,3 +859,4 @@ cs: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/da.yml b/config/locales/da.yml index 6fbfd0f57..2bb10f550 100644 --- a/config/locales/da.yml +++ b/config/locales/da.yml @@ -879,3 +879,4 @@ da: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/de.yml b/config/locales/de.yml index 7db4cf469..960af08a1 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -879,3 +879,4 @@ de: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/el.yml b/config/locales/el.yml index 32129deb1..1792e9164 100644 --- a/config/locales/el.yml +++ b/config/locales/el.yml @@ -859,3 +859,4 @@ el: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/en.yml b/config/locales/en.yml index 6491af515..89fee2e3b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -322,6 +322,7 @@ en: setting_issue_done_ratio: Calculate the issue done ratio with setting_issue_done_ratio_issue_field: Use the issue field setting_issue_done_ratio_issue_status: Use the issue status + setting_start_of_week: Start calendars on permission_add_project: Create project permission_edit_project: Edit project diff --git a/config/locales/es.yml b/config/locales/es.yml index 2775ae77e..067037f16 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -900,3 +900,4 @@ es: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/fi.yml b/config/locales/fi.yml index 89dcdb6f8..d8809294c 100644 --- a/config/locales/fi.yml +++ b/config/locales/fi.yml @@ -889,3 +889,4 @@ fi: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 0324f8d42..c203944c4 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -882,3 +882,4 @@ fr: field_active: Actif enumeration_system_activity: Activité système setting_gravatar_default: Default Gravatar image + setting_start_of_week: Start calendars on diff --git a/config/locales/gl.yml b/config/locales/gl.yml index 873daa57f..9ac409505 100644 --- a/config/locales/gl.yml +++ b/config/locales/gl.yml @@ -879,3 +879,4 @@ gl: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/he.yml b/config/locales/he.yml index a7a6690d5..b71548cca 100644 --- a/config/locales/he.yml +++ b/config/locales/he.yml @@ -863,3 +863,4 @@ he: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 8e4a977e5..1f3a9b595 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -884,3 +884,4 @@ notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/it.yml b/config/locales/it.yml index b149e88d2..46c00c90c 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -866,3 +866,4 @@ it: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/ja.yml b/config/locales/ja.yml index c5a0e3455..f547a3785 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -888,3 +888,4 @@ ja: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 73f12331f..51a70762d 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -919,3 +919,4 @@ ko: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/lt.yml b/config/locales/lt.yml index 605e73be2..bd02c2f51 100644 --- a/config/locales/lt.yml +++ b/config/locales/lt.yml @@ -889,3 +889,4 @@ lt: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 7fc547d2e..d80581cf5 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -841,3 +841,4 @@ nl: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/no.yml b/config/locales/no.yml index 096485396..7bc626181 100644 --- a/config/locales/no.yml +++ b/config/locales/no.yml @@ -854,3 +854,4 @@ notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/pl.yml b/config/locales/pl.yml index f2a6ab96a..0bf2d5cd5 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -882,3 +882,4 @@ pl: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index c34de1c64..aae971933 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -885,3 +885,4 @@ pt-BR: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/pt.yml b/config/locales/pt.yml index 29f5cd28b..fa9cb57a7 100644 --- a/config/locales/pt.yml +++ b/config/locales/pt.yml @@ -871,3 +871,4 @@ pt: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/ro.yml b/config/locales/ro.yml index bd37a3fd3..c348f7856 100644 --- a/config/locales/ro.yml +++ b/config/locales/ro.yml @@ -856,3 +856,4 @@ ro: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/ru.yml b/config/locales/ru.yml index 3d8c0ac08..bd1d71b47 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -967,3 +967,4 @@ ru: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/sk.yml b/config/locales/sk.yml index 20369eaa1..37f26d005 100644 --- a/config/locales/sk.yml +++ b/config/locales/sk.yml @@ -858,3 +858,4 @@ sk: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/sl.yml b/config/locales/sl.yml index df6eb64cc..a018dc80a 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -855,3 +855,4 @@ sl: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/sr.yml b/config/locales/sr.yml index 6ae247e77..a4e36e3cf 100644 --- a/config/locales/sr.yml +++ b/config/locales/sr.yml @@ -874,3 +874,4 @@ notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/sv.yml b/config/locales/sv.yml index a95d9a348..35b5fc212 100644 --- a/config/locales/sv.yml +++ b/config/locales/sv.yml @@ -908,3 +908,4 @@ sv: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/th.yml b/config/locales/th.yml index 961ce2493..2036138f0 100644 --- a/config/locales/th.yml +++ b/config/locales/th.yml @@ -856,3 +856,4 @@ th: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/tr.yml b/config/locales/tr.yml index c81976014..9f721e099 100644 --- a/config/locales/tr.yml +++ b/config/locales/tr.yml @@ -886,3 +886,4 @@ tr: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/uk.yml b/config/locales/uk.yml index 1da115987..3d92016a4 100644 --- a/config/locales/uk.yml +++ b/config/locales/uk.yml @@ -855,3 +855,4 @@ uk: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/vi.yml b/config/locales/vi.yml index cdaa4136b..0a25b25d5 100644 --- a/config/locales/vi.yml +++ b/config/locales/vi.yml @@ -918,3 +918,4 @@ vi: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 442d85039..33f41a284 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -950,3 +950,4 @@ notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 97173fc75..18661d6da 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -883,3 +883,4 @@ zh: notice_issue_done_ratios_updated: Issue done ratios updated. error_workflow_copy_source: Please select a source tracker or role label_update_issue_done_ratios: Update issue done ratios + setting_start_of_week: Start calendars on diff --git a/config/settings.yml b/config/settings.yml index 754c0248a..1cbcba523 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -172,3 +172,5 @@ openid: default: 0 gravatar_default: default: '' +start_of_week: + default: '' diff --git a/lib/redmine/helpers/calendar.rb b/lib/redmine/helpers/calendar.rb index 3e703ea6d..ec474025b 100644 --- a/lib/redmine/helpers/calendar.rb +++ b/lib/redmine/helpers/calendar.rb @@ -65,7 +65,14 @@ module Redmine # Return the first day of week # 1 = Monday ... 7 = Sunday def first_wday - @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1 + case Setting.start_of_week.to_i + when 1 + @first_dow ||= (1 - 1)%7 + 1 + when 7 + @first_dow ||= (7 - 1)%7 + 1 + else + @first_dow ||= (l(:general_first_day_of_week).to_i - 1)%7 + 1 + end end def last_wday