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

Return the list of countries in the form of an array with key=ID, value=name.
public static getCountries ( string $locale = '' ) : array
$locale string The locale to use. If empty we'll use the default locale set in \Punic\Data
Результат array
Пример #1
0
 protected function loadCountries()
 {
     $countries = \Punic\Territory::getCountries();
     unset($countries['IM'], $countries['JE']);
     $event = new \Symfony\Component\EventDispatcher\GenericEvent();
     $event->setArgument('countries', $countries);
     $event = Events::dispatch('on_get_countries_list', $event);
     $countries = $event->getArgument('countries');
     $this->countries[Localization::activeLocale()] = $countries;
 }
Пример #2
0
 public function __construct()
 {
     $countries = \Punic\Territory::getCountries();
     unset($countries['IM'], $countries['JE']);
     $event = new \Symfony\Component\EventDispatcher\GenericEvent();
     $event->setArgument('countries', $countries);
     $event = Events::dispatch('on_get_countries_list', $event);
     $countries = $event->getArgument('countries');
     $this->countries = $countries;
 }
Пример #3
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);
     }
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function __construct(string $name, string $label = null)
 {
     parent::__construct($name, $label);
     self::translator()->addFile(__DIR__ . '/../../../lang/global', 'bootstrap');
     $this->add((new Group(self::trans('bootstrap.googlePlace/street')))->add($this->fields['number'] = (new Text($name . '[number]'))->setPlaceholder(self::trans('bootstrap.googlePlace/number')))->add($this->fields['street'] = (new Text($name . '[street]'))->setPlaceholder(self::trans('bootstrap.googlePlace/street'))))->add((new Group(Misc::joinUnits([self::trans('bootstrap.googlePlace/zipcode'), self::trans('bootstrap.googlePlace/city')])))->add($this->fields['zipcode'] = (new Text($name . '[zipcode]'))->setPlaceholder(self::trans('bootstrap.googlePlace/zipcode')))->add($this->fields['city'] = (new Text($name . '[city]'))->setPlaceholder(self::trans('bootstrap.googlePlace/city'))))->add($this->fields['state'] = new Text($name . '[state]', self::trans('bootstrap.googlePlace/state')))->add($this->fields['country'] = new Select($name . '[country]', self::trans('bootstrap.googlePlace/country'), Territory::getCountries()))->add($this->fields['lat'] = new Hidden($name . '[lat]'))->add($this->fields['long'] = new Hidden($name . '[long]'));
 }
Пример #5
0
 // $countries = Country::get();
 $locale = 'de';
 $str = 'الإقليم البريطاني في المحيط الهندي';
 $str = 'L\'aîle';
 $str = 'Die saîle';
 echo $str;
 echo '<br>';
 // $art = ['ال'];
 // $art = ['los', 'les', 'unas', 'l\''];
 // $break = '(\s+|\b)';
 // $str = trim(preg_replace('/^('.implode('|', $art).')'.$break.'/ui', '', $str));
 $str = Kitbs\Collator\Collator::getString($str, $locale);
 echo $str;
 die;
 App::setLocale($locale);
 $countries = Territory::getCountries($locale);
 dd($countries);
 // // $coll = collator_create(App::getLocale());
 // // $countries = $countries->sort(function($a, $b) use ($coll) {
 // //     return collator_compare( $coll, $a->name, $b->name );
 // // });
 // return '='.$countries->lists('name');
 // 	$arr  = array( 'Köpfe', 'Kypper', 'Kopfe' );
 // $coll = collator_create( 'en' );
 // collator_sort_with_sort_keys( $coll, $arr );
 // var_export( $arr );
 // die;
 // $s1 = 'Hello';
 $locale = 'zh';
 $en = collator_create('en');
 $coll = collator_create($locale);
Пример #6
0
 /**
  * Get a list of localized country names
  *
  * @return array
  */
 public static function getList()
 {
     $countryList = Territory::getCountries();
     \XoopsLocale::asort($countryList);
     return $countryList;
 }