Software: country2currency
country2currency is an XML-file and an associated Drupal module that maps countries to their respective official currency. The XML-file contains a mapping from ISO-3166-1 alpha-3 three-letter country codes to ISO-4217 three-letter currency codes. The associated Drupal module automates access to this data for use in other Drupal modules. You may use this data directly in your application or you may use the provided Drupal module to access it.
This data can be used to automatically select the right currency for your users. If you combine this feature with IP-to-country detection, you can automatically select the appropriate currency for your visitors. See CENIT’s How Far Your Money Goes page for an example. If the official currency of your country is supported by the currency converter, that currency should be selected auto-magically. Kind of neat, isn’t it?
Download now!
- XML-file (last updated: January 7th, 2008)
- Drupal module (current version: 1.0-b1)
Warning: This software is beta-quality and untested. The country-to-currency data might not be accurate. Both the data and the Drupal module are released without any warranty — use at your own risk! Also, the Drupal module has never been tested with a PostgreSQL database.
License: The country2currency Drupal module is released as open-source under the GNU General Public License version 2, or any later version published by the Free Software Foundation. The country2currency data itself (i.e., the XML-file) is released under the GNU Free Documentation License.
Note: The data contained in the XML-file is based on the Wikipedia article about ISO 4217 currency codes. Its accuracy depends on the accuracy on the Wikipedia article. Many thanks to the Wikipedia authors for providing this amazing source of information!
Questions? Problems? Comments? Bugs? — email me!
Changelog:
- 2008-01-07: Cyprus and Malta now use the Euro; added missing countries / territories: Puerto Rico, Liechtenstein, British Virgin Islands, Åland Islands
- 2007-01-02: Slovenia now uses the Euro
How to Use:
If you want to parse the XML-file yourself, simply access the file at http://www.vonkoeller.de/data/country2currency.xml and parse the XML. The syntax is self-explanatory. The date of the latest update is included in the XML file. For an example of how to parse the XML-file in PHP, please see the code of the Drupal module.
You may also access the date of the latest update as pure text at http://www.vonkoeller.de/software_versions/country2currency.txt
If you want to use this feature in another Drupal module, download and activate the county2currency Drupal module as you would with any other module. Then use the functions country2currency_get_countries($currency_code) and country2currency_get_currency($country_code) to convert country codes to currency codes and vice versa. Their usage is self-explanatory.
The Drupal module automatically caches country2currency information in your local database. This data is downloaded automatically when you first activate the module and is regularly updated, by default once a month.




















