Search code examples
ruby-on-railsrubyinternationalizationlocale

what is the actual parameter for the locale=I18nData.country_code(request.location.country)?


First, install gem geocoder and gem i18n_data to make this work.

I ran a test on this locale=I18nData.country_code(request.location.country) with a slight tweak (for testing purposes). This is what i actually did

@country=I18nData.country_code("Spain")

this returns

@country="ES"

however when i just did

@country=I18nData.country_code("spain")

it did not display the output. it is clear that the letter of spain needs to be capital S but when the web application goes live would @country=I18nData.country_code(request.location.country) actually give the true parameter which is "Spain"?

Any help towards it would really help me to clarify this confusion! Many Thanks


Solution

  • After asking question here and there and with testing, the answer is, the above method extracts "Spain" and explicitly set locale as "ES"