diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2010-05-31 07:31:08 -0300 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-03 23:32:10 +1000 |
commit | de50ba22380207aec3ab424efc0b2d1323334617 (patch) | |
tree | 060a6801dbd315f0c85f01842374fb1ee20c73bc /activesupport/lib | |
parent | f29a8a3f6e30116644851038118707f306d76ff9 (diff) | |
download | rails-de50ba22380207aec3ab424efc0b2d1323334617.tar.gz rails-de50ba22380207aec3ab424efc0b2d1323334617.tar.bz2 rails-de50ba22380207aec3ab424efc0b2d1323334617.zip |
Unforce i18n from AS
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/lib')
3 files changed, 17 insertions, 5 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 2b07f05d27..7e4d30f5e8 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -9,9 +9,15 @@ class Array # * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ") # * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ") def to_sentence(options = {}) - default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale]) - default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale]) - default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale]) + if defined?(I18n) + default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale]) + default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale]) + default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale]) + else + default_words_connector = ", " + default_two_words_connector = " and " + default_last_word_connector = ", and " + end options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale) options.reverse_merge! :words_connector => default_words_connector, :two_words_connector => default_two_words_connector, :last_word_connector => default_last_word_connector diff --git a/activesupport/lib/active_support/core_ext/string/interpolation.rb b/activesupport/lib/active_support/core_ext/string/interpolation.rb index 932117cc10..7f764e9de1 100644 --- a/activesupport/lib/active_support/core_ext/string/interpolation.rb +++ b/activesupport/lib/active_support/core_ext/string/interpolation.rb @@ -1 +1,2 @@ +require 'active_support/i18n' require 'i18n/core_ext/string/interpolate' diff --git a/activesupport/lib/active_support/i18n.rb b/activesupport/lib/active_support/i18n.rb index 11af48d67e..0ffdd904fd 100644 --- a/activesupport/lib/active_support/i18n.rb +++ b/activesupport/lib/active_support/i18n.rb @@ -1,3 +1,8 @@ -require 'i18n' +begin + require 'i18n' +rescue LoadError => e + $stderr.puts "You don't have i18n installed in your application. Please add it to your Gemfile and run bundle install" + raise e +end I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml" -ActiveSupport.run_load_hooks(:i18n)
\ No newline at end of file +ActiveSupport.run_load_hooks(:i18n) |