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 information 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.