开发者

Localized states/provinces data

I am trying to provide drop down menus so that users can select their country and state in a multilingual web application.

I was able to extract a list of countries and the name of those countries in various languages from unicode.org's cldr files.

Currently these are all stored in arrays in seperate files (I have files such as en.php, es.php, fr.php and so on).

While this doesn't seem too difficult, I am having trouble trying to get a list of Administrative Divions (states/provinces/prefectures) in localized form. Essentially, if the person is using the french version (fr_fr) of the application, I would like that when he selects "France" as his country, the states drop down would be populated with the various french departments in french.

I have found some data on geonames.org: http://www.geonames.org/GB/administrative-division-united-kingdom.html but all the content seems to be in English, so I can't provide localized states. Additionally, some countries like the UK have 2 sets of data in "Administrative division", which might make grabbing the data automatically somewhat problematic.

Similiar, if someone is using the Japanese version, then the prefecture drop down should contain the prefectures in Japanese. As for the other countries, I think it would be unfeasible to have all administrative divisions translated into Japanese, so defaulting to English is fine.

Additionally, countries have different terms for administrative divisions (states/territory/provinces/prefectures and perhaps some other ones I have missed. I would like to have this data somewhere, so that when someone selets say, Japan, instead of the label being "state" he is presented with the label "prefecture".

Another issue I have is where to store all the data. At the moment I am leaning towards storing the administrative division (state) and label (state,prefecture, etc) in arrays in a more specific file containing the locale (en_US.php, en_GB.php, etc).

Has anyone dealt with something like this on a project? I would love to hear your suggestions/views. Also, it would be great if someone can provide a source where I can get localized states.

EDIT

  • Post codes: Some countries don't have post codes, so I need to store this informatio开发者_开发知识库n and make sure the postcode isn't required when submitting.
  • Optional states: As mentioned. Some countries don't have states, so this will need to be stored somehow.


What are you using the state/province data for? If it is for mailing, then keep in mind that state/province is not required (and is not typically given) in the mailing addresses of many countries, and you will just annoy the user if you ask for it when it is not needed.

Postal code is more important for mailing and the Unicode CLDR has the postal code validation regex for 158 countries. (It is in supplemental/postalCodeData.xml when you download the CLDR)

If you really want state/province, then there is a CLDR proposal to add address formatting information to the CLDR here - http://unicode.org/review/pri180/

You'll notice that the proposal links to a google appengine service which contains the proposed address formatting information - http://i18napis.appspot.com/address

The states/provinces seem to be listed there, but only for countries which require such information in postal addresses. And it looks like it is translated into the languages of each country - for example, Canadian province names are listed in both English and french. It also tells you, for example, that it is called a prefecture in Japan

If you really, really want all subdivisions, regardless of whether it is needed in a postal address, then grab ISO 3166-2. Buy it here - http://www.iso.org/iso/country_codes/iso_3166_databases.htm (you can also potentially scape it off of the wikipedia site for ISO-3166-2)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜