Search code examples
ruby-on-railsruby-on-rails-3rails-geocoder

country_code list for geocoder gem


I'm using geocoder to detect country user.

On my app I need detect country user. I make something like:

c = request.location.country_code
  case c
    when 'US'
     I18n.locale = :en
    when 'ES'
     I18n.locale = :es
    else
     locale ||= I18n.default_locale
   end

My question is where can I find a country_code list for my other languages?


Solution

  • Check the documentation for the provider you're using. For example, Google returns ISO 3166-1 codes.

    http://www.iso.org/iso/iso-3166-1_decoding_table.html

    Regards!