aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r--activesupport/lib/active_support/core_ext/array/conversions.rb11
-rw-r--r--activesupport/lib/active_support/locale/en-US.rb28
-rw-r--r--activesupport/lib/active_support/vendor.rb10
m---------activesupport/lib/active_support/vendor/i18n-0.0.10
4 files changed, 44 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 49ada8f174..e67b719ddb 100644
--- a/activesupport/lib/active_support/core_ext/array/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -6,10 +6,12 @@ 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)
+
+ default = I18n.translate(:'support.array.sentence_connector', :locale => options[: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 +25,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/locale/en-US.rb b/activesupport/lib/active_support/locale/en-US.rb
new file mode 100644
index 0000000000..51324a90bf
--- /dev/null
+++ b/activesupport/lib/active_support/locale/en-US.rb
@@ -0,0 +1,28 @@
+I18n.backend.store_translations :'en-US', {
+ :support => {
+ :array => {
+ :sentence_connector => 'and'
+ }
+ },
+ :date => {
+ :formats => {
+ :default => "%Y-%m-%d",
+ :short => "%b %d",
+ :long => "%B %d, %Y",
+ },
+ :day_names => Date::DAYNAMES,
+ :abbr_day_names => Date::ABBR_DAYNAMES,
+ :month_names => Date::MONTHNAMES,
+ :abbr_month_names => Date::ABBR_MONTHNAMES,
+ :order => [:year, :month, :day]
+ },
+ :time => {
+ :formats => {
+ :default => "%a, %d %b %Y %H:%M:%S %z",
+ :short => "%d %b %H:%M",
+ :long => "%B %d, %Y %H:%M",
+ },
+ :am => 'am',
+ :pm => 'pm'
+ }
+} \ No newline at end of file
diff --git a/activesupport/lib/active_support/vendor.rb b/activesupport/lib/active_support/vendor.rb
index a02e42f791..381471b833 100644
--- a/activesupport/lib/active_support/vendor.rb
+++ b/activesupport/lib/active_support/vendor.rb
@@ -23,4 +23,12 @@ begin
gem 'tzinfo', '~> 0.3.9'
rescue Gem::LoadError
$:.unshift "#{File.dirname(__FILE__)}/vendor/tzinfo-0.3.9"
-end \ No newline at end of file
+end
+
+# TODO I18n gem has not been released yet
+# begin
+# gem 'i18n', '~> 0.0.1'
+# rescue Gem::LoadError
+ $:.unshift "#{File.dirname(__FILE__)}/vendor/i18n-0.0.1/lib"
+ 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 46aad289935eaf059c429acb5f3bfa0946f2d99