aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-05-31 07:31:08 -0300
committerJosé Valim <jose.valim@gmail.com>2010-05-31 12:56:25 +0200
commit1854209bb3d06bc81034dfec4ef75412700eae74 (patch)
tree060a6801dbd315f0c85f01842374fb1ee20c73bc /activesupport/lib
parentf5104caf3b36a206aaf8a4355a2b3a73bbf55e5b (diff)
downloadrails-1854209bb3d06bc81034dfec4ef75412700eae74.tar.gz
rails-1854209bb3d06bc81034dfec4ef75412700eae74.tar.bz2
rails-1854209bb3d06bc81034dfec4ef75412700eae74.zip
Unforce i18n from AS
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb12
-rw-r--r--activesupport/lib/active_support/core_ext/string/interpolation.rb1
-rw-r--r--activesupport/lib/active_support/i18n.rb9
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)