Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Force all internal calls to Array#to_sentence to use English [#2010 s…
…tate:resolved]
  • Loading branch information
dhh committed Feb 27, 2009
1 parent e2b925f commit 6de8356
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions actionpack/lib/action_controller/base.rb
Expand Up @@ -22,7 +22,7 @@ class MethodNotAllowed < ActionControllerError #:nodoc:
attr_reader :allowed_methods

def initialize(*allowed_methods)
super("Only #{allowed_methods.to_sentence} requests are allowed.")
super("Only #{allowed_methods.to_sentence(:locale => :en)} requests are allowed.")
@allowed_methods = allowed_methods
end

Expand Down Expand Up @@ -1298,7 +1298,7 @@ def perform_action
rescue ActionView::MissingTemplate => e
# Was the implicit template missing, or was it another template?
if e.path == default_template_name
raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence}", caller
raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence(:locale => :en)}", caller
else
raise e
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_controller/request.rb
Expand Up @@ -32,7 +32,7 @@ def key?(key)
# <tt>:get</tt>. If the request \method is not listed in the HTTP_METHODS
# constant above, an UnknownHttpMethod exception is raised.
def request_method
@request_method ||= HTTP_METHOD_LOOKUP[super] || raise(UnknownHttpMethod, "#{super}, accepted HTTP methods are #{HTTP_METHODS.to_sentence}")
@request_method ||= HTTP_METHOD_LOOKUP[super] || raise(UnknownHttpMethod, "#{super}, accepted HTTP methods are #{HTTP_METHODS.to_sentence(:locale => :en)}")
end

# Returns the HTTP request \method used for action processing as a
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations.rb
Expand Up @@ -22,7 +22,7 @@ def initialize(reflection)
through_reflection = reflection.through_reflection
source_reflection_names = reflection.source_reflection_names
source_associations = reflection.through_reflection.klass.reflect_on_all_associations.collect { |a| a.name.inspect }
super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence :two_words_connector => ' or ', :last_word_connector => ', or '} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence :two_words_connector => ' or ', :last_word_connector => ', or '}?")
super("Could not find the source association(s) #{source_reflection_names.collect(&:inspect).to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)} in model #{through_reflection.klass}. Try 'has_many #{reflection.name.inspect}, :through => #{through_reflection.name.inspect}, :source => <name>'. Is it one of #{source_associations.to_sentence(:two_words_connector => ' or ', :last_word_connector => ', or ', :locale => :en)}?")
end
end

Expand Down
Expand Up @@ -7,10 +7,9 @@ module Conversions
# * <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_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])
default_last_word_connector = I18n.translate(:'support.array.last_word_connector', :locale => options[:locale])

# Try to emulate to_senteces previous to 2.3
if options.has_key?(:connector) || options.has_key?(:skip_last_comma)
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/duration.rb
Expand Up @@ -70,7 +70,7 @@ def inspect #:nodoc:
[:years, :months, :days, :minutes, :seconds].map do |length|
n = consolidated[length]
"#{n} #{n == 1 ? length.to_s.singularize : length.to_s}" if n.nonzero?
end.compact.to_sentence
end.compact.to_sentence(:locale => :en)
end

protected
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/plugin/loader.rb
Expand Up @@ -178,7 +178,7 @@ def ensure_all_registered_plugins_are_loaded!
if explicit_plugin_loading_order?
if configuration.plugins.detect {|plugin| plugin != :all && !loaded?(plugin) }
missing_plugins = configuration.plugins - (plugins.map{|p| p.name.to_sym} + [:all])
raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence}"
raise LoadError, "Could not locate the following plugins: #{missing_plugins.to_sentence(:locale => :en)}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/tasks/testing.rake
Expand Up @@ -48,7 +48,7 @@ task :test do
task
end
end.compact
abort "Errors running #{errors.to_sentence}!" if errors.any?
abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any?
end

namespace :test do
Expand Down

0 comments on commit 6de8356

Please sign in to comment.