diff options
-rw-r--r-- | actionmailer/lib/action_mailer/base.rb | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_view/helpers/date_helper.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/number_helper.rb | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/validations.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/validations_i18n_test.rb | 2 | ||||
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 2 | ||||
m--------- | activesupport/lib/active_support/vendor/i18n-0.0.1 | 0 | ||||
-rw-r--r-- | activesupport/test/core_ext/i18n_test.rb | 75 | ||||
-rw-r--r-- | activesupport/test/i18n_test.rb | 75 |
9 files changed, 85 insertions, 84 deletions
diff --git a/actionmailer/lib/action_mailer/base.rb b/actionmailer/lib/action_mailer/base.rb index e787c1b8da..f7da90d10f 100644 --- a/actionmailer/lib/action_mailer/base.rb +++ b/actionmailer/lib/action_mailer/base.rb @@ -349,7 +349,7 @@ module ActionMailer #:nodoc: # the current locale, and, finally, on the +default_charset+ specified # for ActionMailer::Base. def charset(charset = nil) - @charset ||= charset || :'charset'.t || @@default_charset + @charset ||= charset || I18n.translate(:charset) || @@default_charset end attr_writer :charset diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb index 6ac4171fd5..d306c7a742 100755 --- a/actionpack/lib/action_view/helpers/date_helper.rb +++ b/actionpack/lib/action_view/helpers/date_helper.rb @@ -512,7 +512,8 @@ module ActionView else month_options = [] month_names = options[:use_month_names] || begin - (options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names').t locale + key = options[:use_short_month] ? :'date.abbr_month_names' : :'date.month_names' + I18n.translate key, locale end month_names.unshift(nil) if month_names.size < 13 @@ -632,7 +633,7 @@ module ActionView position = { :year => 1, :month => 2, :day => 3, :hour => 4, :minute => 5, :second => 6 } - order = options[:order] ||= :'date.order'.t(locale) + order = options[:order] ||= I18n.translate(:'date.order', locale) # Discard explicit and implicit by not being included in the :order discard = {} diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 3e0d5b1db4..981589437d 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -70,7 +70,7 @@ module ActionView # # => 1234567890,50 £ def number_to_currency(number, options = {}) options = options.symbolize_keys - defaults = :'currency.format'.t(options[:locale]) || {} + defaults = I18n.translate(:'currency.format', options[:locale]) || {} precision = options[:precision] || defaults[:precision] unit = options[:unit] || defaults[:unit] diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb index 5bbd10394c..5245f65869 100755 --- a/activerecord/lib/active_record/validations.rb +++ b/activerecord/lib/active_record/validations.rb @@ -22,7 +22,7 @@ module ActiveRecord class << self def default_error_messages ActiveSupport::Deprecation.warn("ActiveRecord::Errors.default_error_messages has been deprecated. Please use 'active_record.error_messages'.t.") - 'active_record.error_messages'.t + I18n.translate 'active_record.error_messages' end end @@ -43,7 +43,7 @@ module ActiveRecord # error can be added to the same +attribute+ in which case an array will be returned on a call to <tt>on(attribute)</tt>. # If no +msg+ is supplied, "invalid" is assumed. def add(attribute, message = nil) - message ||= :"active_record.error_messages.invalid".t + message ||= I18n.translate :"active_record.error_messages.invalid" @errors[attribute.to_s] ||= [] @errors[attribute.to_s] << message end @@ -168,7 +168,7 @@ module ActiveRecord full_messages << message else key = :"active_record.human_attribute_names.#{@base.class.name.underscore.to_sym}.#{attr}" - attr_name = key.t(locale) || @base.class.human_attribute_name(attr) + attr_name = I18n.translate(key, locale, :raise => true) rescue @base.class.human_attribute_name(attr) full_messages << attr_name + " " + message end end diff --git a/activerecord/test/cases/validations_i18n_test.rb b/activerecord/test/cases/validations_i18n_test.rb index 53e90f4d53..840fcd81d0 100644 --- a/activerecord/test/cases/validations_i18n_test.rb +++ b/activerecord/test/cases/validations_i18n_test.rb @@ -79,7 +79,7 @@ class ActiveRecordValidationsI18nTests < Test::Unit::TestCase def test_errors_full_messages_translates_human_attribute_name_for_model_attributes @topic.errors.instance_variable_set :@errors, { 'title' => 'empty' } - I18n.expects(:translate).with(:"active_record.human_attribute_names.topic.title", 'en-US').returns('Title') + I18n.expects(:translate).with(:"active_record.human_attribute_names.topic.title", 'en-US', :raise => true).returns('Title') @topic.errors.full_messages :locale => 'en-US' end end diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 80d91a6cbd..80bf1404de 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -13,7 +13,7 @@ module ActiveSupport #:nodoc: locale = options[:locale] locale ||= self.locale if respond_to?(:locale) - default = :'support.array.sentence_connector'.t(locale) + default = I18n.translate(:'support.array.sentence_connector', locale) options.reverse_merge! :connector => default, :skip_last_comma => false options[:connector] = "#{options[:connector]} " unless options[:connector].nil? || options[:connector].strip == '' diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1 b/activesupport/lib/active_support/vendor/i18n-0.0.1 -Subproject 20c331666b3b6a21791d4cded53c3d8654fba71 +Subproject 970bc7ab5faa94e41ee4a56bc8913c144c1cdd1 diff --git a/activesupport/test/core_ext/i18n_test.rb b/activesupport/test/core_ext/i18n_test.rb deleted file mode 100644 index a67b6a5d8c..0000000000 --- a/activesupport/test/core_ext/i18n_test.rb +++ /dev/null @@ -1,75 +0,0 @@ -require 'abstract_unit' - -class I18nTest < Test::Unit::TestCase - def setup - @date = Date.parse("2008-7-2") - @time = Time.utc(2008, 7, 2, 16, 47, 1) - end - - uses_mocha 'I18nTimeZoneTest' do - def test_time_zone_localization_with_default_format - Time.zone.stubs(:now).returns Time.local(2000) - assert_equal "Sat, 01 Jan 2000 00:00:00 +0100", Time.zone.now.l - end - end - - def test_date_localization_should_use_default_format - assert_equal "2008-07-02", @date.l - end - - def test_date_localization_with_default_format - assert_equal "2008-07-02", @date.l(nil, :default) - end - - def test_date_localization_with_short_format - assert_equal "Jul 02", @date.l(nil, :short) - end - - def test_date_localization_with_long_format - assert_equal "July 02, 2008", @date.l(nil, :long) - end - - def test_time_localization_should_use_default_format - assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", @time.l - end - - def test_time_localization_with_default_format - assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", @time.l(nil, :default) - end - - def test_time_localization_with_short_format - assert_equal "02 Jul 16:47", @time.l(nil, :short) - end - - def test_time_localization_with_long_format - assert_equal "July 02, 2008 16:47", @time.l(nil, :long) - end - - def test_day_names - assert_equal Date::DAYNAMES, :'date.day_names'.t - end - - def test_abbr_day_names - assert_equal Date::ABBR_DAYNAMES, :'date.abbr_day_names'.t - end - - def test_month_names - assert_equal Date::MONTHNAMES, :'date.month_names'.t - end - - def test_abbr_month_names - assert_equal Date::ABBR_MONTHNAMES, :'date.abbr_month_names'.t - end - - def test_date_order - assert_equal [:year, :month, :day], :'date.order'.t - end - - def test_time_am - assert_equal 'am', :'time.am'.t - end - - def test_time_pm - assert_equal 'pm', :'time.pm'.t - end -end diff --git a/activesupport/test/i18n_test.rb b/activesupport/test/i18n_test.rb new file mode 100644 index 0000000000..e6d90f09c1 --- /dev/null +++ b/activesupport/test/i18n_test.rb @@ -0,0 +1,75 @@ +require 'abstract_unit' + +class I18nTest < Test::Unit::TestCase + def setup + @date = Date.parse("2008-7-2") + @time = Time.utc(2008, 7, 2, 16, 47, 1) + end + + uses_mocha 'I18nTimeZoneTest' do + def test_time_zone_localization_with_default_format + Time.zone.stubs(:now).returns Time.local(2000) + assert_equal "Sat, 01 Jan 2000 00:00:00 +0100", I18n.localize(Time.zone.now) + end + end + + def test_date_localization_should_use_default_format + assert_equal "2008-07-02", I18n.localize(@date) + end + + def test_date_localization_with_default_format + assert_equal "2008-07-02", I18n.localize(@date, nil, :default) + end + + def test_date_localization_with_short_format + assert_equal "Jul 02", I18n.localize(@date, nil, :short) + end + + def test_date_localization_with_long_format + assert_equal "July 02, 2008", I18n.localize(@date, nil, :long) + end + + def test_time_localization_should_use_default_format + assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", I18n.localize(@time) + end + + def test_time_localization_with_default_format + assert_equal "Wed, 02 Jul 2008 16:47:01 +0100", I18n.localize(@time, nil, :default) + end + + def test_time_localization_with_short_format + assert_equal "02 Jul 16:47", I18n.localize(@time, nil, :short) + end + + def test_time_localization_with_long_format + assert_equal "July 02, 2008 16:47", I18n.localize(@time, nil, :long) + end + + def test_day_names + assert_equal Date::DAYNAMES, I18n.translate(:'date.day_names') + end + + def test_abbr_day_names + assert_equal Date::ABBR_DAYNAMES, I18n.translate(:'date.abbr_day_names') + end + + def test_month_names + assert_equal Date::MONTHNAMES, I18n.translate(:'date.month_names') + end + + def test_abbr_month_names + assert_equal Date::ABBR_MONTHNAMES, I18n.translate(:'date.abbr_month_names') + end + + def test_date_order + assert_equal [:year, :month, :day], I18n.translate(:'date.order') + end + + def test_time_am + assert_equal 'am', I18n.translate(:'time.am') + end + + def test_time_pm + assert_equal 'pm', I18n.translate(:'time.pm') + end +end |