system.getPreference("locale", "country") return US for vietnam

Hi all,

i am using the following function :

myCountry = system.getPreference( "locale", "country" ):lower():sub(1,2)

I am a french people in France using an iphone, and the return is well " fr" for me.

I have a user based in india, using an old android, and the return is well " in" for him.

the pb is that i have a real viet people based in vietnam using an android, and the return for him is " us" instead of " vn"…

So what is the “country” returned by this function ?

The country where the phone has been bought ? …

How can i have the real country of the user ?

thanks :slight_smile:

maybe i should use :

system.getPreference( "ui", "country" ):lower():sub(1,2)

does it work on android ?

Hi,

If your request rate is under 150/min, you can use a free geolocation service.

local json = require("json") local function onRequest( evt ) local res = json.decode(evt.response) for k, v in pairs( res ) do print(k..":", v) end end network.request("http://ip-api.com/json", "GET", onRequest)

The result table data looks something like:

lon: -81.6954 country: United States zip: 44192 lat: 41.4995 status: success timezone: America/New\_York regionName: Ohio region: OH city: Cleveland query: 208.80.152.201 as: AS14907 Wikimedia Foundation, Inc. countryCode: US isp: Wikimedia Foundation, Inc. org: Wikimedia Foundation, Inc.

-dev

What operating system and device are you seeing this on?

Are you trying to figure out where the user is?  What language to show? or some other use of the country they are in?

Rob

maybe i should use :

system.getPreference( "ui", "country" ):lower():sub(1,2)

does it work on android ?

Hi,

If your request rate is under 150/min, you can use a free geolocation service.

local json = require("json") local function onRequest( evt ) local res = json.decode(evt.response) for k, v in pairs( res ) do print(k..":", v) end end network.request("http://ip-api.com/json", "GET", onRequest)

The result table data looks something like:

lon: -81.6954 country: United States zip: 44192 lat: 41.4995 status: success timezone: America/New\_York regionName: Ohio region: OH city: Cleveland query: 208.80.152.201 as: AS14907 Wikimedia Foundation, Inc. countryCode: US isp: Wikimedia Foundation, Inc. org: Wikimedia Foundation, Inc.

-dev

What operating system and device are you seeing this on?

Are you trying to figure out where the user is?  What language to show? or some other use of the country they are in?

Rob