google/libaddressinput

Spanish address format

Opened this issue · 0 comments

The address format for Spain is currently as follows:

"fmt":"%N%n%O%n%A%n%Z %C %S"

It looks wrong to me to have the province (%S) separated by a space. Instead, one of the following changes would make most sense:

  1. Put it in parentheses. That appears to be the more idiomatic formatting, but it seems to make it harder to make the province be optional.
  2. Add an optional field fmt_admin1 which, when present, indicates a format to use for the admin1 field if present. Then set fmt_admin1 to "(%S)" for Spain.
  3. Make it a newline (%n) instead of a space. This is a simple fix that libaddressinput supports and that is also supported by the postal service.

Regarding the first point, out in the wild, a well-formatted Spanish address seems to leave out the province if it's obvious. For example, for the city of Barcelona, one would write Barcelona by itself rather than write "Barcelona (Barcelona)". For that reason, it may be problematic to make the format string as simple as "%N%n%O%n%A%n%Z %C (%S)". When the admin1 is not present, the address would end up with empty parentheses.