Skip to content
This repository
Browse code

Unforce i18n from AS

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit de50ba22380207aec3ab424efc0b2d1323334617 1 parent f29a8a3
Santiago Pastorino spastorino authored mikel committed
1  actionpack/actionpack.gemspec
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21 21
22 22 s.add_dependency('activesupport', version)
23 23 s.add_dependency('activemodel', version)
  24 + s.add_dependency('i18n', '~> 0.4.0')
24 25 s.add_dependency('rack', '~> 1.1.0')
25 26 s.add_dependency('rack-test', '~> 0.5.4')
26 27 s.add_dependency('rack-mount', '~> 0.6.3')
1  activemodel/activemodel.gemspec
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
20 20 s.has_rdoc = true
21 21
22 22 s.add_dependency('activesupport', version)
  23 + s.add_dependency('i18n', '~> 0.4.0')
23 24 end
1  activesupport/activesupport.gemspec
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19 19
20 20 s.has_rdoc = true
21 21
22   - s.add_dependency('i18n', '~> 0.4.0')
23 22 s.add_dependency('tzinfo', '~> 0.3.16')
24 23 s.add_dependency('builder', '~> 2.1.2')
25 24 s.add_dependency('memcache-client', '>= 1.7.5')
12 activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -9,9 +9,15 @@ class Array
9 9 # * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ")
10 10 # * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ")
11 11 def to_sentence(options = {})
12   - default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale])
13   - default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale])
14   - default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale])
  12 + if defined?(I18n)
  13 + default_words_connector = I18n.translate(:'support.array.words_connector', :locale => options[:locale])
  14 + default_two_words_connector = I18n.translate(:'support.array.two_words_connector', :locale => options[:locale])
  15 + default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale])
  16 + else
  17 + default_words_connector = ", "
  18 + default_two_words_connector = " and "
  19 + default_last_word_connector = ", and "
  20 + end
15 21
16 22 options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
17 23 options.reverse_merge! :words_connector => default_words_connector, :two_words_connector => default_two_words_connector, :last_word_connector => default_last_word_connector
1  activesupport/lib/active_support/core_ext/string/interpolation.rb
... ... @@ -1 +1,2 @@
  1 +require 'active_support/i18n'
1 2 require 'i18n/core_ext/string/interpolate'
9 activesupport/lib/active_support/i18n.rb
... ... @@ -1,3 +1,8 @@
1   -require 'i18n'
  1 +begin
  2 + require 'i18n'
  3 +rescue LoadError => e
  4 + $stderr.puts "You don't have i18n installed in your application. Please add it to your Gemfile and run bundle install"
  5 + raise e
  6 +end
2 7 I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml"
3   -ActiveSupport.run_load_hooks(:i18n)
  8 +ActiveSupport.run_load_hooks(:i18n)

0 comments on commit de50ba2

Please sign in to comment.
Something went wrong with that request. Please try again.