[PATCH conductor] Fix undefined method `<=>' for :"fr-FR":Symbol

Matt Wagner matt.wagner at redhat.com
Thu Mar 8 21:41:51 UTC 2012


On Thu, Mar 08, 2012 at 03:06:47PM +0100, ifarkas at redhat.com wrote:
> From: Imre Farkas <ifarkas at redhat.com>
> 
> ---
>  src/app/controllers/application_controller.rb |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/src/app/controllers/application_controller.rb b/src/app/controllers/application_controller.rb
> index 4c3347f..e646e6d 100644
> --- a/src/app/controllers/application_controller.rb
> +++ b/src/app/controllers/application_controller.rb
> @@ -348,7 +348,7 @@ class ApplicationController < ActionController::Base
>      languages.each do |language|
>        language += ";q=1.0" unless language.match(";q=\d+\.\d+")
>        lang_code, lang_weight = language.split(";q=")
> -      lang_code = lang_code.gsub(/-[a-z]+$/i) { |x| x.upcase }.to_sym
> +      lang_code = lang_code.gsub(/-[a-z]+$/i) { |x| x.upcase }
>        prefs << [lang_weight, lang_code]
>      end
>      # This is slightly abusing array sorting
> -- 
> 1.7.6.5

Is this associated with a BZ? I can't seem to reproduce the error.
However, in poking around, I think I found another bug in this
detect_locale code. With some debugging added, I see:

 *** ordered languages: ["fr-FR", "en-US", "en"]
 *** Available: [:ja, :fr, :cs, :en]

I don't want to step in too far here without knowing exactly what was
going on, but I think this exposes two other problems with the language
detection code:

(1) I18n.available_locales returns an array of symbols for me, so we'll
end up comparing :fr to "fr". If we drop the to_sym above, I think we
need to to_s the locales from I18n.available_locales.

(2) We don't have any country-specific extensions, and we're looking for
an exact match only. Since my browser wants "fr-FR", our code won't
find "fr" (or :fr) as a match. We should either do some more involved
matching ("If we have fr-FR, use that, otherwise, fr is good
enough..."), OR we should just drop the whole "-FR" extension from
incoming locales, if we don't think we're ever going to have en-US.yml
versus en-GB.yml.

I don't know if this is fixing a specific bug, so if what I've mentioned
ends up being off-topic, I can make this a separate BZ and take it.

-- Matt



More information about the aeolus-devel mailing list