module Amazon::Locale

Use of this module requires the use of the GeoIP library from MaxMind. It also requires the net-geoip Ruby module to interface with it.

Load this library as follows:

require 'amazon/locale'

Constants

CA

ISO 3166 codes of countries likely to want to shop in the CA locale.

DE

ISO 3166 codes of countries likely to want to shop in the DE locale.

FR

ISO 3166 codes of countries likely to want to shop in the FR locale.

JP

ISO 3166 codes of countries likely to want to shop in the JP locale.

UK

ISO 3166 codes of countries likely to want to shop in the UK locale.

US

ISO 3166 codes of countries likely to want to shop in the US locale. Any countries not explicitly listed above default to the US locale.

Public Class Methods

get_locale_by_addr(address) click to toggle source

This will attempt to return a reasonable locale (ca, de, fr, jp, uk or us) to use for the IP address addr.

For example:

get_locale_by_addr('217.110.207.55') => "de"
# File lib/amazon/locale.rb, line 87
def Locale.get_locale_by_addr(address)
  localise(Net::GeoIP.new.country_code_by_addr(address))
end
get_locale_by_name(host) click to toggle source

This will attempt to return a reasonable locale (ca, de, fr, jp, uk or us) to use for host.

For example:

get_locale_by_name('xs1.xs4all.nl') => "uk"
# File lib/amazon/locale.rb, line 76
def Locale.get_locale_by_name(host)
  localise(Net::GeoIP.new.country_code_by_name(host))
end