zikula / core

Zikula Core Framework
GNU Lesser General Public License v3.0
237 stars 69 forks source link

asort for countryMap #303

Closed phaidon closed 12 years ago

phaidon commented 12 years ago

file: lib/i18n/Zlanguage.php

I think it would be nice to make asort for countryMap. Otherwise the countries in {selector_countries} are not sorted.

ghost commented 12 years ago

Good idea.

phaidon commented 12 years ago

If I add the asort in the function countryMap then there will be an asort in getCountryName, too even there is no asort needed.

Maybe we have to add a second countryMap function. Something like:

/**
     * Map of l2 country names.
     *
     * @return array
     */
    public static function countryMap0()
    {
        return array(
                'ad' => __('Andorra'),
                'ae' => __('United Arab Emirates'),
                'af' => __('Afghanistan'),
                'ag' => __('Antigua & Barbuda'),
                'ai' => __('Anguilla'),
                'al' => __('Albania'),
                'am' => __('Armenia'),
                'an' => __('Netherlands Antilles'),
                'ao' => __('Angola'),
                'aq' => __('Antarctica'),
                'ar' => __('Argentina'),
                'as' => __('American Samoa'),
                'at' => __('Austria'),
                'au' => __('Australia'),
                'aw' => __('Aruba'),
                'ax' => __('Aland Islands'),
                'az' => __('Azerbaijan'),
                'ba' => __('Bosnia and Herzegovina'),
                'bb' => __('Barbados'),
                'bd' => __('Bangladesh'),
                'be' => __('Belgium'),
                'bf' => __('Burkina Faso'),
                'bg' => __('Bulgaria'),
                'bh' => __('Bahrain'),
                'bi' => __('Burundi'),
                'bj' => __('Benin'),
                'bm' => __('Bermuda'),
                'bn' => __('Brunei Darussalam'),
                'bo' => __('Bolivia'),
                'br' => __('Brazil'),
                'bs' => __('Bahama'),
                'bt' => __('Bhutan'),
                'bv' => __('Bouvet Island'),
                'bw' => __('Botswana'),
                'by' => __('Belarus'),
                'bz' => __('Belize'),
                'ca' => __('Canada'),
                'cc' => __('Cocos (Keeling) Islands'),
                'cf' => __('Central African Republic'),
                'cg' => __('Congo'),
                'ch' => __('Switzerland'),
                'ci' => __("Cote d'Ivoire (Ivory Coast)"),
                'ck' => __('Cook Islands'),
                'cl' => __('Chile'),
                'cm' => __('Cameroon'),
                'cn' => __('China'),
                'co' => __('Colombia'),
                'cr' => __('Costa Rica'),
                'cu' => __('Cuba'),
                'cv' => __('Cape Verde'),
                'cx' => __('Christmas Island'),
                'cy' => __('Cyprus'),
                'cz' => __('Czech Republic'),
                'de' => __('Germany'),
                'dj' => __('Djibouti'),
                'dk' => __('Denmark'),
                'dm' => __('Dominica'),
                'do' => __('Dominican Republic'),
                'dz' => __('Algeria'),
                'ec' => __('Ecuador'),
                'ee' => __('Estonia'),
                'eg' => __('Egypt'),
                'eh' => __('Western Sahara'),
                'er' => __('Eritrea'),
                'es' => __('Spain'),
                'et' => __('Ethiopia'),
                'fi' => __('Finland'),
                'fj' => __('Fiji'),
                'fk' => __('Falkland Islands (Malvinas)'),
                'fm' => __('Micronesia'),
                'fo' => __('Faroe Islands'),
                'fr' => __('France'),
                'fx' => __('France, Metropolitan'),
                'ga' => __('Gabon'),
                'gb' => __('United Kingdom (Great Britain)'),
                'gd' => __('Grenada'),
                'ge' => __('Georgia'),
                'gf' => __('French Guiana'),
                'gh' => __('Ghana'),
                'gi' => __('Gibraltar'),
                'gl' => __('Greenland'),
                'gm' => __('Gambia'),
                'gn' => __('Guinea'),
                'gp' => __('Guadeloupe'),
                'gq' => __('Equatorial Guinea'),
                'gr' => __('Greece'),
                'gs' => __('South Georgia and the South Sandwich Islands'),
                'gt' => __('Guatemala'),
                'gu' => __('Guam'),
                'gw' => __('Guinea-Bissau'),
                'gy' => __('Guyana'),
                'hk' => __('Hong Kong'),
                'hm' => __('Heard & McDonald Islands'),
                'hn' => __('Honduras'),
                'hr' => __('Croatia'),
                'ht' => __('Haiti'),
                'hu' => __('Hungary'),
                'id' => __('Indonesia'),
                'ie' => __('Ireland'),
                'il' => __('Israel'),
                'im' => __('Isle of Man'),
                'in' => __('India'),
                'io' => __('British Indian Ocean Territory'),
                'iq' => __('Iraq'),
                'ir' => __('Islamic Republic of Iran'),
                'is' => __('Iceland'),
                'it' => __('Italy'),
                'jm' => __('Jamaica'),
                'jo' => __('Jordan'),
                'jp' => __('Japan'),
                'ke' => __('Kenya'),
                'kg' => __('Kyrgyzstan'),
                'kh' => __('Cambodia'),
                'ki' => __('Kiribati'),
                'km' => __('Comoros'),
                'kn' => __('St. Kitts and Nevis'),
                'ko' => __('Kosovo'), // unoffially allocated yet by ISO - drak
                'kp' => __("Korea, Democratic People's Republic of"),
                'kr' => __('Korea, Republic of'),
                'kw' => __('Kuwait'),
                'ky' => __('Cayman Islands'),
                'kz' => __('Kazakhstan'),
                'la' => __("Lao People's Democratic Republic"),
                'lb' => __('Lebanon'),
                'lc' => __('Saint Lucia'),
                'li' => __('Liechtenstein'),
                'lk' => __('Sri Lanka'),
                'lr' => __('Liberia'),
                'ls' => __('Lesotho'),
                'lt' => __('Lithuania'),
                'lu' => __('Luxembourg'),
                'lv' => __('Latvia'),
                'ly' => __('Libyan Arab Jamahiriya'),
                'ma' => __('Morocco'),
                'mc' => __('Monaco'),
                'md' => __('Moldova, Republic of'),
                'mg' => __('Madagascar'),
                'mh' => __('Marshall Islands'),
                'mk' => __('Macedonia, the form Republic of'),
                'ml' => __('Mali'),
                'mn' => __('Mongolia'),
                'mm' => __('Myanmar'),
                'mo' => __('Macau'),
                'mp' => __('Northern Mariana Islands'),
                'mq' => __('Martinique'),
                'mr' => __('Mauritania'),
                'ms' => __('Monserrat'),
                'mt' => __('Malta'),
                'mu' => __('Mauritius'),
                'mv' => __('Maldives'),
                'mw' => __('Malawi'),
                'mx' => __('Mexico'),
                'my' => __('Malaysia'),
                'mz' => __('Mozambique'),
                'na' => __('Namibia'),
                'nc' => __('New Caledonia'),
                'ne' => __('Niger'),
                'nf' => __('Norfolk Island'),
                'ng' => __('Nigeria'),
                'ni' => __('Nicaragua'),
                'nl' => __('Netherlands'),
                'no' => __('Norway'),
                'np' => __('Nepal'),
                'nr' => __('Nauru'),
                'nu' => __('Niue'),
                'nz' => __('New Zealand'),
                'om' => __('Oman'),
                'pa' => __('Panama'),
                'pe' => __('Peru'),
                'pf' => __('French Polynesia'),
                'pg' => __('Papua New Guinea'),
                'ph' => __('Philippines'),
                'pk' => __('Pakistan'),
                'pl' => __('Poland'),
                'pm' => __('St. Pierre & Miquelon'),
                'pn' => __('Pitcairn'),
                'pr' => __('Puerto Rico'),
                'pt' => __('Portugal'),
                'pw' => __('Palau'),
                'py' => __('Paraguay'),
                'qa' => __('Qatar'),
                're' => __('Reunion'),
                'ro' => __('Romania'),
                'rs' => __('Serbia'),
                'ru' => __('Russian Federation'),
                'rw' => __('Rwanda'),
                'sa' => __('Saudi Arabia'),
                'sb' => __('Solomon Islands'),
                'sc' => __('Seychelles'),
                'sd' => __('Sudan'),
                'se' => __('Sweden'),
                'sg' => __('Singapore'),
                'sh' => __('St. Helena'),
                'si' => __('Slovenia'),
                'sj' => __('Svalbard & Jan Mayen Islands'),
                'sk' => __('Slovakia'),
                'sl' => __('Sierra Leone'),
                'sm' => __('San Marino'),
                'sn' => __('Senegal'),
                'so' => __('Somalia'),
                'sr' => __('Suriname'),
                'st' => __('Sao Tome & Principe'),
                'sy' => __('Syrian Arab Republic'),
                'sz' => __('Swaziland'),
                'tc' => __('Turks & Caicos Islands'),
                'td' => __('Chad'),
                'tf' => __('French Southern Territories'),
                'tg' => __('Togo'),
                'th' => __('Thailand'),
                'tj' => __('Tajikistan'),
                'tk' => __('Tokelau'),
                'tm' => __('Turkmenistan'),
                'tn' => __('Tunisia'),
                'to' => __('Tonga'),
                'tp' => __('East Timor'),
                'tr' => __('Turkey'),
                'tt' => __('Trinidad & Tobago'),
                'tv' => __('Tuvalu'),
                'tw' => __('Taiwan, Province of China'),
                'tz' => __('Tanzania, United Republic of'),
                'ua' => __('Ukraine'),
                'ug' => __('Uganda'),
                'um' => __('United States Minor Outlying Islands'),
                'us' => __('United States of America'),
                'uy' => __('Uruguay'),
                'uz' => __('Uzbekistan'),
                'va' => __('Vatican City State (Holy See)'),
                'vc' => __('St. Vincent & the Grenadines'),
                've' => __('Venezuela'),
                'vg' => __('British Virgin Islands'),
                'vi' => __('United States Virgin Islands'),
                'vn' => __('Vietnam'),
                'vu' => __('Vanuatu'),
                'wf' => __('Wallis & Futuna Islands'),
                'ws' => __('Samoa'),
                'ye' => __('Yemen'),
                'yt' => __('Mayotte'),
                'za' => __('South Africa'),
                'zm' => __('Zambia'),
                'zr' => __('Zaire'),
                'zw' => __('Zimbabwe'),
                'zz' => __('Unknown or unspecified country'));
    }

   public static function countryMap()
   {
        $map = self::countryMap0();
        asort($map);
        return $map;
   }

@drak What do you think about that?

ghost commented 12 years ago

I see a problem because you don't know how things will correctly sort when the country names are actually translated. Does asort() understands internationalization?

phaidon commented 12 years ago

I test it. asort() understands internationalization. I will do a PR.