It seems to me that the counties for Irish addresses should appear in the final address the same as they appear in the dropdown list, and not as the letter codes?

e.g. "Co Galway" should appear in the address as "Co Galway" and not as "G".

Comments

fonant’s picture

Title: Irish counties appear as codes, not names, in address » Irish counties (and other country areas) appear as codes, not names, in address

Looks like the address output always uses the "ISO code" for the area where areas are specified for countries (the key of the PHP array, rather than the value).

While this works for some countries, where areas/states are usually abbreviated to a code, it doesn't work for many countries, especially where they "ISO codes" are numeric?

I wonder whether there should be an option for each country like "Use ISO code for area", which would give the current behaviour, while if that was false the "ISO codes" should be translated back to the corresponding area array value for output.

I've done a quick fix using hook_addressfield_administrative_areas_alter() in my own module.

bojanz’s picture

Title: Irish counties (and other country areas) appear as codes, not names, in address » Allow address formats to specify whether the administrative area value is rendered instead of the code
Category: Bug report » Feature request

We need to support specifying this in the address format.

bojanz’s picture

Status: Active » Fixed

Done, and added 'render_administrative_area' => TRUE for Ireland.

I'll try to derive this data from Google's dataset at a later date.

  • bojanz committed a175eff on 7.x-1.x
    Issue #2401865: Allow address formats to specify whether the...
fonant’s picture

It might be worth providing the flag the other way around: I think in general addresses will render the address using the administrative area name, rather than the ISO code. So a flag 'render_administrative_area_as_code' used for the few countries (e.g. USA) that would do this, and render all others as the visible string in the drop-down.

Just a though. My custom module code now fixes many countries to use the displayed string, rather than the "ISO code" for output.

bojanz’s picture

Actually no, I've derived this data from Google's dataset (commit after this one, included in 1.0), and the majority display the code, not the label.
So it's good enough for now.

Of course, "display" in this case means "display for an envelope". Addressfield 2.x will separate the "render for screen' and "render for envelope" contexts.

fonant’s picture

That's surprising, although I suppose if the area code forms part of the postcode it makes sense. Ireland doesn't really have postcodes yet!

Thanks for the research, and the fix :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

topdillon’s picture

So, how do I get "Co. Galway" to appear in views instead of "G"?