Skip to content

Commit 1854209

Browse files
spastorinojosevalim
authored andcommitted
Unforce i18n from AS
Signed-off-by: José Valim <[email protected]>
1 parent f5104ca commit 1854209

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

actionpack/actionpack.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
2121

2222
s.add_dependency('activesupport', version)
2323
s.add_dependency('activemodel', version)
24+
s.add_dependency('i18n', '~> 0.4.0')
2425
s.add_dependency('rack', '~> 1.1.0')
2526
s.add_dependency('rack-test', '~> 0.5.4')
2627
s.add_dependency('rack-mount', '~> 0.6.3')

activemodel/activemodel.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Gem::Specification.new do |s|
2020
s.has_rdoc = true
2121

2222
s.add_dependency('activesupport', version)
23+
s.add_dependency('i18n', '~> 0.4.0')
2324
end

activesupport/activesupport.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
1919

2020
s.has_rdoc = true
2121

22-
s.add_dependency('i18n', '~> 0.4.0')
2322
s.add_dependency('tzinfo', '~> 0.3.16')
2423
s.add_dependency('builder', '~> 2.1.2')
2524
s.add_dependency('memcache-client', '>= 1.7.5')

activesupport/lib/active_support/core_ext/array/conversions.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ class Array
99
# * <tt>:two_words_connector</tt> - The sign or word used to join the elements in arrays with two elements (default: " and ")
1010
# * <tt>:last_word_connector</tt> - The sign or word used to join the last element in arrays with three or more elements (default: ", and ")
1111
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
1521

1622
options.assert_valid_keys(:words_connector, :two_words_connector, :last_word_connector, :locale)
1723
options.reverse_merge! :words_connector => default_words_connector, :two_words_connector => default_two_words_connector, :last_word_connector => default_last_word_connector
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
require 'active_support/i18n'
12
require 'i18n/core_ext/string/interpolate'
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
27
I18n.load_path << "#{File.dirname(__FILE__)}/locale/en.yml"
3-
ActiveSupport.run_load_hooks(:i18n)
8+
ActiveSupport.run_load_hooks(:i18n)

0 commit comments

Comments
 (0)