Module | Amazon::Locale |
In: |
lib/amazon/locale.rb
|
CA | = | %w[ ca ] | ISO 3166 codes of countries likely to want to shop in the CA locale. | |
DE | = | %w[ at ch de ] | ISO 3166 codes of countries likely to want to shop in the DE locale. | |
FR | = | %w[ be fr ] | ISO 3166 codes of countries likely to want to shop in the FR locale. | |
JP | = | %w[ jp ] | ISO 3166 codes of countries likely to want to shop in the JP locale. | |
UK | = | %w[ ad al ba cy cz dk ee es fi fo gg gi gr gl hu ie im is it je li lt lu lv mk mt nl no pl pt ro se si sk sm uk ] | ISO 3166 codes of countries likely to want to shop in the UK locale. | |
US | = | %w[ mx 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. |
This will attempt to return a reasonable locale (ca, de, fr, jp, uk or us) to use for the IP address address.
Example:
get_locale_by_addr( '217.110.207.55' ) => "de"
# File lib/amazon/locale.rb, line 92 def Locale.get_locale_by_addr(address) cc = Net::GeoIP.new.country_code_by_addr( address ) raise GeoError, "invalid address: #{address}" unless cc localise( cc ) end
This will attempt to return a reasonable locale (ca, de, fr, jp, uk or us) to use for host.
Example:
get_locale_by_name( 'xs1.xs4all.nl' ) => "uk"
# File lib/amazon/locale.rb, line 79 def Locale.get_locale_by_name(host) cc = Net::GeoIP.new.country_code_by_name( host ) raise GeoError, "invalid host: #{host}" unless cc localise( cc ) end