I have spent hours searching to find where magento stores full county name. We can get a full list of countries using this code:
$_countries = Mage::getResourceModel('directory/country_collection')
->loadData()
->toOptionArray(false);
This will return an array with country code and name, I investigated the directory module, and found out this call gets data from the table
directory_county
But this table don't have full county name! So where is it stored? and how is it retrieved using that call?
Thanks in advance.
Use the Zend_Local translation.
Use the column 'iso2_code' from the table 'directory_country' for your $code.
Ok so to compensate for my wrong answer. Here is how this works:
/lib/Zend/Locale/Data/en.xml - if your store is in english, else another xml in the same directoery is read. Every country is there and its code under the xml tag
<territory>
The xml is cached using the Zend_Cache_Core class.
/lib/Zend/Locale.php - function getTranslation invokes the lib/Zend/Cache/Core.php class to load from the cache.
Example: If you change the name of some country in en.xml and clear the magento cache. You will see the change when u invoke your code again.
Full country names are not stored in database. Magento uses inbuilt Zend functionality.
Check file:
lib/Zend/Locale/Data/Translation.php
for full list.Magneto only stores country codes in DB, and relies for names on Zend's Locale module to provide translated names, for different locale.
By the
toOptionArray
method it invokes theZend_Locale
class to get the translated value.Refer
$name = Mage::app()->getLocale()->getCountryTranslation($data['value']);
, which gets toMage_Core_Model_Locale
and then toZend_Locale
.It decides which of the node from the data to read, by the switch case statement in
Zend_Locale_Data::getContent()
line# 962, 963Magento caches the names, so if you make any change to
XML
files, make sure to clean your cache folder to get what you seek.