localising postal / physical address display from database fields
Asked Answered
C

2

12

Can anyone point me to a list of international postal / residential / delivery address format templates that use some kind of parseable standard vocabulary for address parts?

The ideal list contains a country code then a format using replaceable tokens so I can substitute database address fields into a template to produce something printable in the local format.

for example

NZ | [first_name] [family_name]\n[company_name]\n[street_address]\n[city] [post_code]\n[country]
AU | [first_name] [family_name]\n[company_name]\n[street_address]\n[city]\n[state] [post_code]\n[country]
US | etc
UK | etc

Background: I used to have a simple freetext field to accept addresses. Moving to support vCard download, which requires addresses to be broken down into specific fields. Thats all fine: we can do the migration. I'm looking for a way to display the fields in the "correct" order for each country. thanks for your help!

Choong answered 30/4, 2011 at 8:38 Comment(0)
P
7

Google have a JSON-based API that they use for their Android address input field library that contains this kind of formatting information.

The field you'd be interested in is fmt. There doesn't seem to be any formal documentation on the format they use, but a proposal to include this information as part of the Unicode CLDR has matching fields (scroll down to "Detailed Breakdown of elements"); there are also some clues in Google's libaddressinput source code.

Preceding answered 7/5, 2011 at 7:7 Comment(2)
Thanks. Exactly what I needed. I can slurp that all down and parse it easily. Much appreciated.Choong
@Choong note that the bounty doesn't get awarded automatically along with accepting the answer, you'll have to do that explicitly.Swivel
S
8

This MSDN page has the information in the format you need and seems accurate, but covers only 33 countries. Maybe they are enough.

The Universal Postal Union offers all the information you need for a lot of countries here. This is top quality information; however, it is split across as many PDF documents as there are countries and is not in the format you need.

This page provides the information in a slightly more accessible form. As far as I can judge, it is accurate (and contains a lot of valuable info), but I can't speak to its quality nor its currentness.

Swivel answered 7/5, 2011 at 6:23 Comment(1)
Thanks for your help. I looked carefully at the links you provided. The Google api from @一二三 was easier to parse automatically. Appreciated your quality answer though!Choong
P
7

Google have a JSON-based API that they use for their Android address input field library that contains this kind of formatting information.

The field you'd be interested in is fmt. There doesn't seem to be any formal documentation on the format they use, but a proposal to include this information as part of the Unicode CLDR has matching fields (scroll down to "Detailed Breakdown of elements"); there are also some clues in Google's libaddressinput source code.

Preceding answered 7/5, 2011 at 7:7 Comment(2)
Thanks. Exactly what I needed. I can slurp that all down and parse it easily. Much appreciated.Choong
@Choong note that the bounty doesn't get awarded automatically along with accepting the answer, you'll have to do that explicitly.Swivel

© 2022 - 2024 — McMap. All rights reserved.