I have an addressfield that uses the locality (city), administrative area (state), and country.

I am using Address Field 1.0-beta3.

I have configured my addressfield to be taxonomized by location taxonomy and to "Use full name" for both country and province.

I can add the following two values without trouble:
Country: United States (dropdown)
Admin area: Alabama (dropdown)
City: Montogomery

Country: Italy (dropdown)
Admin area: Alessandria

These values are stored and taxonomized correctly upon initial save.

However, after saving nodes containing these values, when I go to /admin/config/content/location_taxonomize and click "Empty Location Vocab" and then "Bulk Taxonomize Locations", Italy's "Alessandria" becomes "Alabama" in the taxonomy. I am guessing this has something to do with the fact that the Address Field formatter (in addressfield/plugins/format/address.inc) uses 'AL' as the code for both of these administrative areas.

Comments

ptmkenny’s picture

I uncovered the following with some additional testing:

My website uses a custom addressfield formatter (/addressfield/plugins/format/mycustomformatter.inc) which contains a selector for all of the prefectures (provinces) in Japan:

  else if ($address['country'] == 'JP') {
    $format['locality_block']['administrative_area']['#options'] = array(
      ''   => t('--'),
      'HK' => t('Hokkaido'),
      'AM' => t('Aomori'),
      'IT' => t('Iwate'),
      'MG' => t('Miyagi'),
      'AT' => t('Akita'),
      'YA' => t('Yamagata'),
      'FS' => t('Fukushima'),
      'IG' => t('Ibaraki'),
      'TG' => t('Tochigi'),
      'GM' => t('Gunma'),
      'ST' => t('Saitama'),
      'CB' => t('Chiba'),
      'AL' => t('Tokyo'),
      'KN' => t('Kanagawa'),
      'NG' => t('Niigata'),
      'TY' => t('Toyama'),
      'IK' => t('Ishikawa'),
      'FI' => t('Fukui'),
      'YN' => t('Yamanashi'),
      'NN' => t('Nagano'),
      'GF' => t('Gifu'),
      'SZ' => t('Shizuoka'),
      'AC' => t('Aichi'),
      'ME' => t('Mie'),
      'SI' => t('Shiga'),
      'KT' => t('Kyoto'),
      'OS' => t('Osaka'),
      'HG' => t('Hyogo'),
      'NR' => t('Nara'),
      'WK' => t('Wakayama'),
      'TT' => t('Tottori'),
      'SM' => t('Shimane'),
      'OY' => t('Okayama'),
      'HS' => t('Hiroshima'),
      'YU' => t('Yamaguchi'),
      'TS' => t('Tokushima'),
      'KA' => t('Kagawa'),
      'EH' => t('Ehime'),
      'KC' => t('Kochi'),
      'FO' => t('Fukuoka'),
      'SA' => t('Saga'),
      'NS' => t('Nagasaki'),
      'KU' => t('Kumamoto'),
      'OT' => t('Oita'),
      'MZ' => t('Miyazaki'),
      'KO' => t('Kagoshima'),
      'ON' => t('Okinawa'),
    );
    $format['locality_block']['administrative_area']['#title'] = t('Prefecture');
  }

This allows users to select the prefectures from a drop-down list. If I have "Synchronize the Location Taxonomy with location data as soon as it's submitted." checked, the name of the prefecture will be added to the taxonomy properly. However, if this box is checked, or if I empty the taxonomy and then run bulk taxonomize again, only the abbreviation will be given for the administrative area.

leo82’s picture

I have the same problem,
Italy
Milan

will be insert as

Italy
Michigan

i don't know if it works with Synchronize the Location Taxonomy with location data as soon as it's submitted

because automatic synchronization doesn't work for me

I don't know how to solve it because location for all over the world could be chosen

goron’s picture

This happens because there is no way to get a province name from a province code. When taxonomizing in real time, the full name is available in the address form and can be added to to the taxonomy. But when bulk taxonomizing that's not available. I included US states in the module so those are possible, that's why Milan is turning into Michigan, etc.

I will look at AF again to see if there's a way to use it to convert province code to province name. If not, the only fix will be to make sure the milan/michigan thing doesn't happen...

Or, allowing modules to plug in province "dictionaries" to LT to achieve this, but I probably don't have time to implement this now.

ptmkenny’s picture

Here's a workaround which is kind of ugly but worked for my case:

Modify the relevant addressfield.inc (name may be different) file in plugins/format so that the "key" being used is not the abbreviation but rather the name of the administrative area.

Example:

Instead of
'TO' => t('Tokyo'),
use
'Tokyo' => t('Tokyo'),

This is OK for me because all my locations are in English. This way, when the bulk taxonomize operation runs, the terms are regenerated to match the assigned values.

ptmkenny’s picture

Issue summary: View changes

added info on configuration

Michael Molchanov’s picture

Here is my fix of this issue. I'll profile this solution later and provide new patch.

Michael Molchanov’s picture

Status: Active » Needs review
proweb.ua’s picture

thx Michael
#5 works

narkoff’s picture

#5 solved issue for me as well.