diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-06-19 16:25:27 +0200 |
---|---|---|
committer | Sven Fuchs <svenfuchs@artweb-design.de> | 2008-06-19 16:25:27 +0200 |
commit | 45d41f0dadd9fa171f306ff356770c4492726f30 (patch) | |
tree | 44829d24de330827d53e52c328b5dc8d81244656 /activesupport | |
parent | 40557e17dda0525d5d26c09b3279b83695df3f4d (diff) | |
download | rails-45d41f0dadd9fa171f306ff356770c4492726f30.tar.gz rails-45d41f0dadd9fa171f306ff356770c4492726f30.tar.bz2 rails-45d41f0dadd9fa171f306ff356770c4492726f30.zip |
integrating I18n into Rails
Diffstat (limited to 'activesupport')
-rw-r--r-- | activesupport/lib/active_support/core_ext/array/conversions.rb | 14 | ||||
-rw-r--r-- | activesupport/lib/active_support/vendor.rb | 7 | ||||
m--------- | activesupport/lib/active_support/vendor/i18n-0.0.1 | 0 |
3 files changed, 17 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index a9882828ca..08e608d346 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -6,10 +6,15 @@ module ActiveSupport #:nodoc: module Conversions # Converts the array to a comma-separated sentence where the last element is joined by the connector word. Options: # * <tt>:connector</tt> - The word used to join the last element in arrays with two or more elements (default: "and") - # * <tt>:skip_last_comma</tt> - Set to true to return "a, b and c" instead of "a, b, and c". - def to_sentence(options = {}) - options.assert_valid_keys(:connector, :skip_last_comma) - options.reverse_merge! :connector => 'and', :skip_last_comma => false + # * <tt>:skip_last_comma</tt> - Set to true to return "a, b and c" instead of "a, b, and c". + def to_sentence(options = {}) + options.assert_valid_keys(:connector, :skip_last_comma, :locale) + + locale = options[:locale] + locale ||= request.locale if respond_to?(:request) + + default = :'support.array.sentence_connector'.t(locale) + options.reverse_merge! :connector => default, :skip_last_comma => false options[:connector] = "#{options[:connector]} " unless options[:connector].nil? || options[:connector].strip == '' case length @@ -23,6 +28,7 @@ module ActiveSupport #:nodoc: "#{self[0...-1].join(', ')}#{options[:skip_last_comma] ? '' : ','} #{options[:connector]}#{self[-1]}" end end + # Calls <tt>to_param</tt> on all its elements and joins the result with # slashes. This is used by <tt>url_for</tt> in Action Pack. diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb index a02e42f791..bca2664fa4 100644 --- a/activesupport/lib/active_support/vendor.rb +++ b/activesupport/lib/active_support/vendor.rb @@ -23,4 +23,11 @@ begin gem 'tzinfo', '~> 0.3.9' rescue Gem::LoadError $:.unshift "#{File.dirname(__FILE__)}/vendor/tzinfo-0.3.9" +end + +begin + gem 'i18n', '~> 0.3.9' +rescue Gem::LoadError + $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.0.1/lib" # TODO + require 'i18n' end
\ No newline at end of file diff --git a/activesupport/lib/active_support/vendor/i18n-0.0.1 b/activesupport/lib/active_support/vendor/i18n-0.0.1 new file mode 160000 +Subproject 70ab0f3cc5921cc67e09741939a08b2582d707c |