This ticket is simply about providing a better method for importing Country -> State data. All other edge cases, will need to be completed in another ticket. Please refrain from making this ticket take 2 years and lets keep this on task.

---

I've created a mega ticket for essentially what is a single task. Making sure addressfield is flexible and pluggable enough, so that one can easily add new sub-administrative areas for a country.

Currently this is done in code, and should probably be some kind of flat file format, which can be imported into the database upon install, and later through admin.

I think there are 3 issues which need to get resolved fully for this to be complete.

I suggest we focus on implementing an more pluggable solution for now, this way we can get a common format.

Then later in another ticket, we can worry about all the edge cases.

1. Country -> State lists need to be easily pluggable.

Currently, it's hard-coded in code. Ubercart has a nice way if importing this type of data via .cif files. We could steal those and get support for many other countries. I'll let you guys fight on how to do this properly.

2. Country, State abbreviations need to be convertible into full names. Vice versa.

So my use case, is that I'm using address field to take in my Country, State, City information for the world.

My problem is, for countries like US, Canada, when I get the State/Province information back, it comes back as an abbreviated version (CA for California). I personally want the full name for SEO reasons. Same goes for countries. Currently addressfield doesn't have an appropriate API for this...and it should.

3. Country, State names need to be translatable. Additionally the name for "State / Province" needs to be translatable.

Again for SEO reasons, countries need to be translatable into other languages. ISO codes should be used for all languages.

---

Related tickets.

1. Need to be easily pluggable:

#1317070: Use ISO codes XML file for populating country-specific properties Appears to be the ticket with the most support.
#977798: Store data in XML and parse it on load
#1662376: More segregated country data
#1335200: Path for adding a new country

Country specific:

#1097890: Canadian Address Fields with pluggable way to do other countries. Pluggable solution?
#1218304: Make the postal code field optional for China
#1152700: Support Russian adresses
#1665788: Add administrative areas for Russian regions
#1171454: Address formats for Estonia, Latvia, Lithuania
#1779674: Administrative area's in Italy not translatable
#1345198: Add irish counties, fix locality label
#1335916: Province List of India
#1568276: Argentina provinces
#1297580: State dropdown list for Malaysia
#1810458: Rename administrative area for Egypt
#1669620: Proper format for South African addresses
#1472628: Add Mexican states
#1475886: Polish states
#1480796: French Addresses
#1651612: Add administrative area #options for New Zealand regions
#1707192: Add Columbian administrative areas (departments)
#1593456: Add US Armed Forces administrative area #options
#989756: Support for Hungarian addresses
#973056: Brazilian address

---

Attached is also a simple country name translation script I made in perl for another project. It creates gettext files, which you can then import into Drupal.

CommentFileSizeAuthor
#7 aol_address.tar_.gz112.57 KBMantasK
#3 translate_countries.tgz185.93 KBj0rd

Comments

j0rd’s picture

Issue tags: +pluggable regions

All issues in this post have been tagged with pluggable regions.

I've commented on all of those issues as well, making them aware of this post. If that's where you're coming from, don't actually close your ticket, if it's currently active, but otherwise I suppose it could be closed and a more generic solution could get created here.

damien tournoud’s picture

This is something we discussed during the Commerce 2.x sprint, and is definitely part of our roadmap for Addressfield 2.x.

The objective of Addressfield 1.x was to come up with a simple address solution management that covers the 80% use case. It obviously failed, so we are going to tackle the complexity in Addressfield 2.x instead of avoiding it.

The idea is to support two concepts:

Address format

Addressfield will support multiple address formats, and will ship by default with three address formats (new address formats can be added):

  • City-level (ie. city / possibly administrative division / country)
  • Building-level (ie. premise / thoroughfare / dependent_locality + City-level)
  • Full (ie. name / organization + Building-level)

Each address format will be stored as a configurable entity in CMI. We will have a token system (yet to be designed, possibly the one adopted by Google) and support for different edit / render formats and country-specific override of each address format.

Postal divisions

This is actually different then the common principal subdivisions defined by ISO-3166-2 (for example, the US has postal divisions "AA", "AE" and "AP" for state-side and oversee Armed forces).

The postal divisions are going to be managed in separate configurable entities in CMI, so that they can be used by multiple address formats.

j0rd’s picture

StatusFileSize
new185.93 KB

GetText creator for Countries in many languages. Didn't attach to first post for some reason.

j0rd’s picture

When I hear CMI does this mean Configuration Management Initiative or something different? If so are we looking at D8 release for Commerce 2.x and AddressField 2.x.

If so, I think others need a solution for AddressField 1.x on D7. Actually based on the amount of tickets, and the eastern block planning a mutiny (#1792302), I'd think we'd need a simple solution for AF 1.x and D7.

Something fairly simple could get added to allow an easier way to import Countries -> Regions in 1.x, additional country specific complexity could be handled still by add-on ctools plugins. I think they currently are pretty easy. Keep everything backwards compatible.

Then Commerce guys can dream up a solution for AddressField 2.x, which will hopefully solve the short comings of 1.x. But I have a feeling release date for something like that is a long time away, and would most likely break current module implementations which rely on addressfield 1.x.

damien tournoud’s picture

1.x is feature frozen at this point. We are not going to make any drastic change to this branch.

damien tournoud’s picture

Issue summary: View changes

improved formatting.

giorgio79’s picture

Issue summary: View changes

Added Hungarian

giorgio79’s picture

Issue summary: View changes

type

giorgio79’s picture

Title: [meta] Address Field 2.x needs pluggable administrative areas and an actual API » SUPER TICKET: AddressField needs easily pluggable province / state / region data. And improved API for devs.
Priority: Normal » Major

The module could use / import CLDR Unicode country data, the industry standard used by the big boys (and Drupal #1938892: Switch from ISO-3166-1 country data to CLDR unicode data) for country / region data including translations! So, all data is already available in all languages :) Perhaps the module could have some supporting db tables or xml files.

Addressfield could also integrate with http://drupal.org/project/countries that is looking into this #1830198: Better support for various providers of Country data.

MantasK’s picture

StatusFileSize
new112.57 KB

I'm doing address module migration and I have created custom module which changes Address form (country-specific) (I just copied that plugin and customized it.

In that plugin I use states from address module. And it has all countries, though abbreviations are not always right, sometimes it uses 2 and sometimes 3 letters. I didnt check, maybe states are in better shape in newest dev version, as we have custom list. But it is quite good solution.

I'm attaching my custom module. After enabling u can see 1 more checkbox while configuring field. And then states will come from all countries or almost all

rszrama’s picture

Title: SUPER TICKET: AddressField needs easily pluggable province / state / region data. And improved API for devs. » [meta] Address Field 2.x needs pluggable administrative areas and an actual API
Priority: Major » Normal

Just looping this in: #1010314-37: Separate Components of Address field

That contains a first pass patch at making individual address components available or not available. It's a different approach to what Damien's described, and given the opportunity for a 2.x rewrite, I doubt we'll carry it on. But there's still plenty of history to link in there.

zterry95’s picture

Glad to see this improvement.

However, currently we are going to improve the china addressfield. So I wonder to know any news on the 2.x branch? especially the ctools plugin system. Thank you.

The link of china address field:
http://drupal.org/project/China_address_field

giorgio79’s picture

Title: SUPER TICKET: AddressField needs easily pluggable province / state / region data. And improved API for devs. » [meta] Address Field 2.x needs pluggable administrative areas and an actual API
Priority: Major » Normal

Drupal core now uses Unicode CLDR data for country list #1938892: Switch from ISO-3166-1 country data to CLDR unicode data. I believe there is no point in replicating all country info in this module, but reuse Unicode CLDR, and let users submit address data straight to unicode. Let's not duplicate efforts! Think big, and outside of the box...

rszrama’s picture

@giorgio79 - that's a separate issue; this module will always follow the ISO standard as much as possible. Administrative areas are subdivisions of countries and not covered by the core patch (which is for D8 anyways).

giorgio79’s picture

Yep, thx Ryan. While the core patch doesn't, cldr does cover administrative areas, subdivisions etc including internationalization. For example: http://www.unicode.org/review/pri180/
Looks like the Google data is ISO compatible as well :)

summit’s picture

Hi, I noticed the head issue was closed, but this UI is to great to forget I think.
It would be great to have installed within Addressfield https://drupal.org/node/1010314#comment-5615366
Greetings, Martijn

summit’s picture

Issue summary: View changes

added brazo;

malberts’s picture

Issue summary: View changes

Changed South Africa's issue to the active one.

iamEAP’s picture

Just as a heads up, I've been building a module that layers on top of Address Field in a largely client-side way that happens to reduce some friction in this area.

bojanz’s picture

Status: Active » Fixed

We now know how 2.x is going to look and work:
https://drupalcommerce.org/blog/16864/commerce-2x-stories-addressing
It uses the dataset Google built for Android, including their list of subdivisions (the CLDR data is insufficient).
The 8.x-2.x version of addressfield will depend on the library we created to do the actual work.
A 7.x-2.x version can follow the same architecture, with the imposed PHP 5.4 requirement of course.

The library / implementation plan resolves all of the points raised by the OP, so I'm marking this issue as fixed.

In the meantime, in 7.x-1.x I plan to move the administrative areas out of address.inc, and try to replace them with the ones supplied by Google.
That's as much as we can improve in 1.x without breaking backwards compatibility.

giorgio79’s picture

That is fantastic! Much appreciated Bojanz :)

Status: Fixed » Closed (fixed)

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

bojanz’s picture

As promised, administrative areas are in their own include file: http://cgit.drupalcode.org/addressfield/commit/?id=2ae5e55

I also managed to introduce the concept of an address format without causing BC breaks:
http://cgit.drupalcode.org/addressfield/commit/?id=712da4d and explained in #2390035: Introduce the concept of an address format, import (some of) Google's dataset.

I'm also planning to add alter hooks. All of that is already a huge improvement over beta5.