Hi,
I have nodes with location info through feedapi feeds which only hold countrynames, not isocodes.
This seems problematic within location module. Everything seems to be depending on Country ISO codes.
- How can I get from a countryname to the specific ISO-code? Is there a function within location?
For example I have the countryname; holland, or nederland and needs to get the ISO code of the netherlands with it, which is nl
- If I then have the country ISO code, how can I then translate the english countryname with this to dutch?
With ISO-code NL, location shows "The Netherlands", but I would like to show "Nederland".
Thanks for your reply!
Greetings,
Martijn
Comments
Comment #1
yesct commentedrelated to #286066: asking for help outputting country name instead of country code ?
tagging
Comment #2
hanno commentedCan the module Country codes API (http://drupal.org/project/countries_api) help you with this?
There is a patch for this module for a Dutch translation of the country names: http://drupal.org/node/382828
Comment #3
summit commentedHi,
How to get from countryname to countrycode? This part of the puzzle is still for me not to crasp..
Filed a issues on country api also: http://drupal.org/node/487296
greetings,
Martijn
Comment #4
summit commentedOn http://drupal.org/node/487296 , Tom Kirkpatrick explained beneath code to get from countryname to iso2 code
Still the problem of having different country-names in my feeds. For instance:
a feed which shows in the country-field: "United states of America"
another feed shows in the country-field: "United states"
another feed shows in the country-field: "America"
They all mean the same.
How can I automated still get to the right iso countrycode. Pseudocode:
First get from the different country-fields to the right $countryname. Then use above code to get to the right $iso2.
How to get this working please?
Thanks a lot in advance! greetings, Martijn
Comment #5
summit commentedWill something like this work?
For translation to dutch I can use http://drupal.org/project/countries_api
Please advice whole structure to first get from possibiliteis to right country id.
Thanks in advance greetings, Martijn
Comment #6
mrfelton commentedbear in mind that the 'name' column stores the official country names (in upper case).. The 'printable_name' column stores them in a printable format. So, you should probably run strtolower($countryname) when you perform your match.
Comment #7
rooby commentedThere is a function the the location module uses for its country list location_get_iso3166_list() in location.inc.
Calling location_get_iso3166_list() or location_get_iso3166_list(FALSE) will give you lower case country codes and calling location_get_iso3166_list(TRUE) will give you upper case country codes.
It returns an array of country_code => country_name pairs so you could use something like this to get the code for a country name:
or
In regards to translations, all the countries in the country list are run through the t() function so if there is a dutch translation for the location module you should just be able to use that.
Otherwise you can just use drupals translation functionality to translate it manually.