getName() публичный статический Метод

..).
public static getName ( string $territoryCode, string $locale = '' ) : string
$territoryCode string The territory code
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат string Returns the localized territory name (returns $territoryCode if not found)
Пример #1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('countries')->delete();
     $locales = Config::get('translatable.locales');
     // $locales = get_locales(true);
     $countries = Territory::getCountries('en');
     $producing = ['AL', 'AM', 'AR', 'AT', 'AU', 'AZ', 'BA', 'BE', 'BG', 'BO', 'BR', 'BY', 'CA', 'CH', 'CL', 'CN', 'CU', 'CY', 'CZ', 'DE', 'DZ', 'EE', 'EG', 'ES', 'ET', 'FR', 'GB', 'GE', 'GR', 'HR', 'HU', 'IL', 'IT', 'JO', 'JP', 'KG', 'KZ', 'LB', 'LI', 'LT', 'LU', 'LV', 'LY', 'MA', 'MD', 'ME', 'MG', 'MK', 'MT', 'MX', 'NZ', 'PA', 'PE', 'PT', 'PY', 'RE', 'RO', 'RS', 'RU', 'SI', 'SK', 'SY', 'TJ', 'TM', 'TN', 'TR', 'UA', 'US', 'UY', 'UZ', 'VN', 'ZA', 'ZW', 'CSHH', 'CSXX', 'SUHH', 'YUCS'];
     foreach ($countries as $code => $void) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing)];
         $nameEn = Territory::getName($code, 'en');
         foreach ($locales as $key => $locale) {
             if (is_array($locale)) {
                 $country[$key] = ['name' => Territory::getName($code, $key)];
                 foreach ($locale as $countryLocale) {
                     $name = Territory::getName($code, $key . '-' . $countryLocale);
                     if ($name != $country[$key]['name'] && $name != $nameEn) {
                         $country[$key . '-' . $countryLocale] = ['name' => $name];
                     }
                 }
             } else {
                 $name = Territory::getName($code, $locale);
                 if ($name != $nameEn) {
                     $country[$locale] = ['name' => $name];
                 }
             }
         }
         $country = Country::create($country);
         $langs = Territory::getLanguages($code, 'of', true);
         $langs = array_map(function ($lang) {
             return str_replace('_', '-', $lang);
         }, $langs);
         $langs = array_diff($langs, get_locales(true));
         foreach ($langs as $lang) {
             $name = Territory::getName($code, str_replace('-', '_', $lang));
             $translation = $country->getNewTranslation($lang);
             $translation->name = $name;
             $translation->country_id = $country->id;
             $translation->save();
         }
     }
     $countries = ['CSHH' => 'Czechoslovakia', 'CSXX' => 'Serbia and Montenegro', 'SUHH' => 'Soviet Union', 'YUCS' => 'Yugoslavia'];
     foreach ($countries as $code => $name) {
         $country = ['code' => $code, 'is_wine' => in_array($code, $producing), 'en' => ['name' => $name]];
         $country = Country::create($country);
     }
 }
Пример #2
0
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
 * @link      http://xoops.org
 */
include dirname(dirname(__DIR__)) . '/mainfile.php';
$xoops = Xoops::getInstance();
$xoops->header();
$country = Request::getString('country', 'US');
$form = new Xoops\Form\ThemeForm('Show Flag for a Country', 'form_flag', '', 'post', false, 'horizontal');
$ccode = new Xoops\Form\SelectCountry('Country', 'country', $country);
$form->addElement($ccode, false);
$button = new Xoops\Form\Button('', 'submit', XoopsLocale::A_SUBMIT, 'submit');
$form->addElement($button);
$form->display();
// demonstrate the CountryFlags service
$img = $xoops->service('countryflag')->getImgTag($country)->getValue();
echo $img;
// we can specify a size
$img = $xoops->service('countryflag')->getImgTag($country, null, 'medium')->getValue();
echo $img;
$img = $xoops->service('countryflag')->getImgTag($country, null, 'small')->getValue();
echo $img;
echo '<br /><br />';
// we can add any HTML attributes to the img tag
$attributes = ['class' => 'img-polaroid', 'title' => Territory::getName($country)];
$img = $xoops->service('countryflag')->getImgTag($country, $attributes)->getValue();
echo $img . '<br /><br />';
if (!$xoops->service('countryflag')->isAvailable()) {
    echo 'Please install a countryflag provider to view this demonstration.';
}
\Xoops\Utils::dumpFile(__FILE__);
$xoops->footer();
Пример #3
0
 /**
  * Returns a keyed array of timezone identifiers (keys are the standard PHP timezone names, values are the localized timezone names).
  *
  * @return array
  *
  * @see http://www.php.net/datetimezone.listidentifiers.php
  */
 public function getTimezones()
 {
     static $cache = array();
     $locale = Localization::activeLocale();
     if (array_key_exists($locale, $cache)) {
         $result = $cache[$locale];
     } else {
         $result = array();
         $continentNames = array('Africa' => \Punic\Territory::getName('002'), 'Asia' => \Punic\Territory::getName('142'), 'America' => \Punic\Territory::getName('019'), 'Antarctica' => \Punic\Territory::getName('AQ'), 'Arctic' => t('Arctic'), 'Atlantic' => t('Atlantic Ocean'), 'Australia' => \Punic\Territory::getName('AU'), 'Europe' => \Punic\Territory::getName('150'), 'Indian' => t('Indian Ocean'), 'Pacific' => t('Pacific Ocean'));
         foreach (\DateTimeZone::listIdentifiers() as $timezoneID) {
             switch ($timezoneID) {
                 case 'UTC':
                 case 'GMT':
                     $timezoneName = t('Greenwich Mean Time');
                     break;
                 default:
                     $chunks = explode('/', $timezoneID);
                     if (array_key_exists($chunks[0], $continentNames)) {
                         $chunks[0] = $continentNames[$chunks[0]];
                     }
                     if (count($chunks) > 0) {
                         $city = \Punic\Calendar::getTimezoneExemplarCity($timezoneID, false);
                         if (!strlen($city)) {
                             switch ($timezoneID) {
                                 case 'Antarctica/South_Pole':
                                     $city = t('South Pole');
                                     break;
                                 case 'America/Montreal':
                                     $city = t('Montreal');
                                     break;
                                 case 'America/Shiprock':
                                     $city = t('Shiprock');
                                     break;
                             }
                         }
                         if (strlen($city)) {
                             $chunks = array($chunks[0], $city);
                         }
                     }
                     $timezoneName = implode('/', $chunks);
                     break;
             }
             $result[$timezoneID] = $timezoneName;
         }
         natcasesort($result);
         $cache[$locale] = $result;
     }
     return $result;
 }
Пример #4
0
 function getName($key, $locale)
 {
     switch (@$_GET['type'] ?: 'country') {
         case 'language':
             return Punic\Language::getName($key, $locale);
         case 'currency':
             return Punic\Currency::getName($key, null, $locale);
         default:
             return Punic\Territory::getName($key, $locale);
     }
 }