From 3119d1996c3c3fda10309ef39bfd327fb2390151 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Mon, 13 Aug 2012 18:13:10 +0000 Subject: [PATCH] Use abbr_day_name to get the first letter of the day name (#9839). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10202 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/views/gantts/show.html.erb | 2 +- lib/redmine/i18n.rb | 4 ++++ test/unit/lib/redmine/i18n_test.rb | 16 ++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb index 7323e84ee..5b9aaa289 100644 --- a/app/views/gantts/show.html.erb +++ b/app/views/gantts/show.html.erb @@ -146,7 +146,7 @@ if show_days width = zoom - 1 %>
5 %>" class="gantt_hdr"> - <%= day_name(wday).first %> + <%= day_letter(wday) %>
<% left = left + width + 1 diff --git a/lib/redmine/i18n.rb b/lib/redmine/i18n.rb index fade9a9ae..12445b450 100644 --- a/lib/redmine/i18n.rb +++ b/lib/redmine/i18n.rb @@ -58,6 +58,10 @@ module Redmine ::I18n.t('date.day_names')[day % 7] end + def day_letter(day) + ::I18n.t('date.abbr_day_names')[day % 7].first + end + def month_name(month) ::I18n.t('date.month_names')[month] end diff --git a/test/unit/lib/redmine/i18n_test.rb b/test/unit/lib/redmine/i18n_test.rb index 2ec6dc2f9..d234ddf3c 100644 --- a/test/unit/lib/redmine/i18n_test.rb +++ b/test/unit/lib/redmine/i18n_test.rb @@ -25,6 +25,10 @@ class Redmine::I18nTest < ActiveSupport::TestCase User.current.language = nil end + def teardown + set_language_if_valid 'en' + end + def test_date_format_default set_language_if_valid 'en' today = Date.today @@ -155,6 +159,18 @@ class Redmine::I18nTest < ActiveSupport::TestCase end end + def test_day_name + set_language_if_valid 'fr' + assert_equal 'dimanche', day_name(0) + assert_equal 'jeudi', day_name(4) + end + + def test_day_letter + set_language_if_valid 'fr' + assert_equal 'd', day_letter(0) + assert_equal 'j', day_letter(4) + end + def test_valid_languages assert valid_languages.is_a?(Array) assert valid_languages.first.is_a?(Symbol)