Phonegap - 从用户发现国家iso代码的最佳方式 [英] Phonegap - the best way to discover the country iso code from a user

查看:159
本文介绍了Phonegap - 从用户发现国家iso代码的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是最好的和最快的方式获得国家iso代码by
开始一个应用程序构建与phonegap?有一个函数来获取
地理坐标,但不是Iso代码。为了得到iso代码也许
有必要调用一个外部webservice和获得iso通过
给定坐标。是否有最简单的方法?

what is the best and fastest way to get the country iso code by starting an App build with phonegap? There is a function to get the geo coordinates, but not the Iso code. For getting the iso code maybe it is necessary to call an external webservice and get the iso by given coordinates. Is there a simplest way?

感谢
Nik

Thanks Nik

推荐答案

p>你正在寻找用户在哪里,或者更像是用户语言/ nationallity的东西?对于后者,你总是可以看看 navigator.language 中的内容。根据目标平台,它会给你或者只是语言代码(在我的Android测试机上的'en')或语言代码和国家代码(在我的iOS测试机上的'en-us')。要查看它会给您带来什么,请使用设备的股票浏览器此处,然后键入

Are you looking for where the user is at the moment or for something more like the users language/nationallity? For the latter you could always look at what's in navigator.language. Depending on target platform it'll give you either just language code ('en' on my Android test machine) or language code and country code ('en-us' on my iOS test machine). To see what it will give you, go with your device's stock browser here and type in navigator.language in the text input box.

否则,请随意浏览 HTML5地理位置规范似乎表明您需要使用网络服务或打包带有代码的数据文件在应用程序。 似乎是一个相当不错的。

Otherwise, casual browsing of the HTML5 Geolocation spec seems to indicate that you'll either need a web-service or package a datafile with codes in the app. This seems to be a pretty good one.

这篇关于Phonegap - 从用户发现国家iso代码的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆