aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/array/conversions.rb
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/active_support/core_ext/array/conversions.rb
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/active_support/core_ext/array/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb12
1 files changed, 9 insertions, 3 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