I needed this for a project, so I thought I'd go ahead and create it and provide the patch. It's analogous to the existing "Country to ISO Code" plugin, but for U.S. States. For example, if your Feed has a "state" field that includes data like, "Connecticut", and "New Mexico", this plugin will convert them to "CT" and "NM" - suitable for mapping to fields provided by the Addressfield module.

Patch will be attached in first comment below.

Thanks,
-mike

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ultimike’s picture

...and here's the patch.

Thanks,
-mike

ultimike’s picture

...and how about a patch that actually works (oops)...

-mike

twistor’s picture

Status: Active » Needs review

Can you clean up the commented out function?
Also, are you sure about the t() wrapping the state name?

twistor’s picture

Status: Needs review » Needs work
ultimike’s picture

Status: Needs work » Needs review
FileSize
2.92 KB

Chris,

Whoops - sorry about the commented out function. It's now removed in the attached patch.

As for the t(), I was unsure about it as well, but I modeled my patch after the country_to_code.inc plugin that already exists - that plugin uses the same pattern, including the t().

-mike

twistor’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev
Status: Needs review » Patch (to be ported)
twistor’s picture

I should note that I've removed the t(). I need to check on the country to code plugin, but it doesn't really make sense, afaict.

twistor’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Component: Code » Plugins
Assigned: ultimike » Unassigned
Issue summary: View changes
Status: Patch (to be ported) » Closed (fixed)

I'm not backporting plugins anymore at this point.