本文整理汇总了PHP中Locale::getDisplayRegion方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getDisplayRegion方法的具体用法?PHP Locale::getDisplayRegion怎么用?PHP Locale::getDisplayRegion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::getDisplayRegion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getOptionLocales
/**
* Get options array for locale dropdown
*
* @param bool $translatedName translation flag
* @return array
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _getOptionLocales($translatedName = false)
{
$currentLocale = $this->localeResolver->getLocale();
$locales = \ResourceBundle::getLocales('') ?: [];
$languages = (new LanguageBundle())->get($currentLocale)['Languages'];
$countries = (new RegionBundle())->get($currentLocale)['Countries'];
$options = [];
$allowedLocales = $this->_config->getAllowedLocales();
foreach ($locales as $locale) {
if (!in_array($locale, $allowedLocales)) {
continue;
}
$language = \Locale::getPrimaryLanguage($locale);
$country = \Locale::getRegion($locale);
if (!$languages[$language] || !$countries[$country]) {
continue;
}
if ($translatedName) {
$label = ucwords(\Locale::getDisplayLanguage($locale, $locale)) . ' (' . \Locale::getDisplayRegion($locale, $locale) . ') / ' . $languages[$language] . ' (' . $countries[$country] . ')';
} else {
$label = $languages[$language] . ' (' . $countries[$country] . ')';
}
$options[] = ['value' => $locale, 'label' => $label];
}
return $this->_sortOptionArray($options);
}
示例2: geocode
public function geocode($ipAddress)
{
$region = \Locale::getRegion($this->getLocale());
$countryName = \Locale::getDisplayRegion($this->getLocale(), 'en');
$countryCode = \Locale::getRegion($this->getLocale());
if ($countryCode == '') {
throw new NoResult(sprintf('No results found for IP address "%s".', $ipAddress));
}
return $this->returnResults([$this->fixEncoding(array_merge($this->getDefaults(), array('country' => $countryName, 'countryCode' => $countryCode)))]);
}
示例3: init
/**
* set up option list
*/
public function init()
{
$libPhoneNumber = PhoneNumberUtil::getInstance();
$optionsList = [];
foreach ($libPhoneNumber->getSupportedRegions() as $code) {
$fullTextCountry = \Locale::getDisplayRegion('en_' . $code, 'en');
$optionsList[$code] = $fullTextCountry;
}
asort($optionsList);
$this->setValueOptions($optionsList);
}
示例4: getDisplayTerritory
/**
* Returns detailed informations from the territory table
* If no detail is given a complete table is returned
*
* @param string $locale Normalized locale
* @param boolean $invert Invert output of the data
* @param string|array $detail Detail to return information for
* @return array
*/
public static function getDisplayTerritory($locale, $invert = false, $detail = null)
{
if ($detail !== null) {
return Locale::getDisplayRegion($locale);
} else {
$list = ZFLocale::getLocaleList();
foreach ($list as $key => $value) {
$list[$key] = Locale::getDisplayRegion($key);
}
if ($invert) {
array_flip($list);
}
return $list;
}
}
示例5: getCountryName
/**
* this function will return the user country name
* @param string $locale the language code to display the country name in example: ar, en.
* @return NULL|string the country name
*/
public function getCountryName($locale = null)
{
//check if we have a country code
if ($this->countryCode) {
if (!$locale) {
$locale = $this->suggestedLanguage;
}
//return the country name
return \Locale::getDisplayRegion($this->suggestedLanguage . '_' . $this->countryCode, $locale);
}
return NULL;
}
示例6:
echo Locale::getDisplayLanguage($locale, $locale) ?: '<em>none</em>';
?>
</td>
</tr>
<tr>
<th>Region</th>
<td><?php
echo Locale::getRegion($locale) ?: '<em>none</em>';
?>
</td>
<td><?php
echo Locale::getDisplayRegion($locale, Yii::$app->language) ?: '<em>none</em>';
?>
</td>
<td><?php
echo Locale::getDisplayRegion($locale, $locale) ?: '<em>none</em>';
?>
</td>
</tr>
<tr>
<th>Script</th>
<td><?php
echo Locale::getScript($locale) ?: '<em>none</em>';
?>
</td>
<td><?php
echo Locale::getDisplayScript($locale, Yii::$app->language) ?: '<em>none</em>';
?>
</td>
<td><?php
echo Locale::getDisplayScript($locale, $locale) ?: '<em>none</em>';
示例7: init
/**
*
*
* @param $Path
* @param $Controller
*/
public function init($Path, $Controller)
{
$Smarty = $this->smarty();
// Get a friendly name for the controller.
$ControllerName = get_class($Controller);
if (StringEndsWith($ControllerName, 'Controller', true)) {
$ControllerName = substr($ControllerName, 0, -10);
}
// Get an ID for the body.
$BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
$Smarty->assign('BodyID', $BodyIdentifier);
//$Smarty->assign('Config', Gdn::Config());
// Assign some information about the user.
$Session = Gdn::session();
if ($Session->isValid()) {
$User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
$Photo = $Session->User->Photo;
if ($Photo) {
if (!IsUrl($Photo)) {
$Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
}
} else {
if (function_exists('UserPhotoDefaultUrl')) {
$Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto');
} elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) {
$Photo = Gdn_Upload::url($ConfigPhoto);
} else {
$Photo = Asset('/applications/dashboard/design/images/defaulticon.png', true);
}
}
$User['Photo'] = $Photo;
} else {
$User = false;
/*array(
'Name' => '',
'CountNotifications' => 0,
'SignedIn' => FALSE);*/
}
$Smarty->assign('User', $User);
// Make sure that any datasets use arrays instead of objects.
foreach ($Controller->Data as $Key => $Value) {
if ($Value instanceof Gdn_DataSet) {
$Controller->Data[$Key] = $Value->resultArray();
} elseif ($Value instanceof stdClass) {
$Controller->Data[$Key] = (array) $Value;
}
}
$BodyClass = val('CssClass', $Controller->Data, '', true);
$Sections = Gdn_Theme::section(null, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$BodyClass .= ' Section-' . $Section;
}
}
$Controller->Data['BodyClass'] = $BodyClass;
// Set the current locale for themes to take advantage of.
$Locale = Gdn::locale()->Locale;
$CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', $Locale));
if (class_exists('Locale')) {
$CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
$CurrentLocale['Region'] = Locale::getRegion($Locale);
$CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
$CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
$CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
}
$Smarty->assign('CurrentLocale', $CurrentLocale);
$Smarty->assign('Assets', (array) $Controller->Assets);
$Smarty->assign('Path', Gdn::request()->path());
// Assign the controller data last so the controllers override any default data.
$Smarty->assign($Controller->Data);
$Smarty->Controller = $Controller;
// for smarty plugins
$Smarty->security = true;
$Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('Category', 'CheckPermission', 'InSection', 'InCategory', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url'));
$Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf'));
$Smarty->secure_dir = array($Path);
}
示例8: get_country_names
/**
* Get an array containing country names associated with their ISO-2 codes.
*
* @return array An associative array with names and codes.
* @since 2.0.0
*/
protected function get_country_names()
{
function compareASCII($a, $b)
{
$at = iconv('UTF-8', 'ASCII//TRANSLIT', $a);
$bt = iconv('UTF-8', 'ASCII//TRANSLIT', $b);
return strcmp(strtoupper($at), strtoupper($bt));
}
$result = [];
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
$continue = array('BU', 'DY', 'EU', 'HV', 'FX', 'NH', 'QO', 'RH', 'TP', 'YU', 'ZR', 'ZZ');
$locale = get_locale();
for ($i = 0; $i < 26; $i++) {
for ($j = 0; $j < 26; $j++) {
$s = $letters[$i] . $letters[$j];
if (in_array($s, $continue)) {
continue;
}
$t = Locale::getDisplayRegion('-' . $s, $locale);
if ($s != $t) {
$result[$s] = ucfirst($t);
}
}
}
$save_locale = setlocale(LC_ALL, '');
setlocale(LC_ALL, $locale);
uasort($result, 'compareASCII');
setlocale(LC_ALL, $save_locale);
return $result;
}
示例9: dispRegion
/**
* Returns the country/region of a locale after localizing it in the default or some other locale.
*
* @param CULocale $inLocale **OPTIONAL. Default is** *the application's default locale*. The locale in which the
* country/region is to be localized.
*
* @return CUStringObject The locale's localized country/region.
*/
public function dispRegion(CULocale $inLocale = null)
{
$strInLocale = isset($inLocale) ? $inLocale->m_name : self::defaultLocaleName();
return Locale::getDisplayRegion($this->m_name, $strInLocale);
}
示例10: getRegionDisplayName
/**
* Returns the customary display name in the given language for the given region.
*
* @param $regionCode
* @param $locale
* @return string
*/
private function getRegionDisplayName($regionCode, $locale)
{
$loc = Locale::getDisplayRegion(Locale::country_code_to_locale($regionCode), $locale);
return $regionCode === null || $regionCode == 'ZZ' || $regionCode === PhoneNumberUtil::REGION_CODE_FOR_NON_GEO_ENTITY ? "" : $loc;
}
示例11: init
/**
*
*
* @param string $Path
* @param Gdn_Controller $Controller
*/
public function init($Path, $Controller)
{
$Smarty = $this->smarty();
// Get a friendly name for the controller.
$ControllerName = get_class($Controller);
if (StringEndsWith($ControllerName, 'Controller', true)) {
$ControllerName = substr($ControllerName, 0, -10);
}
// Get an ID for the body.
$BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
$Smarty->assign('BodyID', htmlspecialchars($BodyIdentifier));
//$Smarty->assign('Config', Gdn::Config());
// Assign some information about the user.
$Session = Gdn::session();
if ($Session->isValid()) {
$User = array('Name' => htmlspecialchars($Session->User->Name), 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
$Photo = $Session->User->Photo;
if ($Photo) {
if (!isUrl($Photo)) {
$Photo = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
}
} else {
$Photo = UserModel::getDefaultAvatarUrl($Session->User);
}
$User['Photo'] = $Photo;
} else {
$User = false;
/*array(
'Name' => '',
'CountNotifications' => 0,
'SignedIn' => FALSE);*/
}
$Smarty->assign('User', $User);
// Make sure that any datasets use arrays instead of objects.
foreach ($Controller->Data as $Key => $Value) {
if ($Value instanceof Gdn_DataSet) {
$Controller->Data[$Key] = $Value->resultArray();
} elseif ($Value instanceof stdClass) {
$Controller->Data[$Key] = (array) $Value;
}
}
$BodyClass = val('CssClass', $Controller->Data, '', true);
$Sections = Gdn_Theme::section(null, 'get');
if (is_array($Sections)) {
foreach ($Sections as $Section) {
$BodyClass .= ' Section-' . $Section;
}
}
$Controller->Data['BodyClass'] = $BodyClass;
// Set the current locale for themes to take advantage of.
$Locale = Gdn::locale()->Locale;
$CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', Gdn::locale()->language(true)));
if (class_exists('Locale')) {
$CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
$CurrentLocale['Region'] = Locale::getRegion($Locale);
$CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
$CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
$CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
}
$Smarty->assign('CurrentLocale', $CurrentLocale);
$Smarty->assign('Assets', (array) $Controller->Assets);
// 2016-07-07 Linc: Request used to return blank for homepage.
// Now it returns defaultcontroller. This restores BC behavior.
$isHomepage = val('isHomepage', $Controller->Data);
$Path = $isHomepage ? "" : Gdn::request()->path();
$Smarty->assign('Path', $Path);
$Smarty->assign('Homepage', $isHomepage);
// true/false
// Assign the controller data last so the controllers override any default data.
$Smarty->assign($Controller->Data);
$security = new SmartySecurityVanilla($Smarty);
$security->php_handling = Smarty::PHP_REMOVE;
$security->allow_constants = false;
$security->allow_super_globals = false;
$security->streams = null;
$security->setPhpFunctions(array_merge($security->php_functions, ['array', 'category', 'checkPermission', 'inSection', 'inCategory', 'ismobile', 'multiCheckPermission', 'getValue', 'setValue', 'url', 'useragenttype']));
$security->php_modifiers = array_merge($security->php_functions, array('sprintf'));
$Smarty->enableSecurity($security);
}
示例12: displayCountry
/**
* Return the country name corresponding to the given ISO code
* NB: the name is localized if the intl extension is installed, otherwise it is returned in English
* @param string $iso
* @return string
*/
function displayCountry($iso)
{
if (!$iso) {
return '';
}
return class_exists('Locale') ? \Locale::getDisplayRegion('-' . $iso, $this->locale()) : constant('ISO::CC_' . $iso);
}
示例13: getDisplayRegion
/**
* Returns an appropriately localized display name for region of the locale
*
* @param string $inLocale Optional format locale to use to display the language name
* @return string Name of the region in the format appropriate for $inLocale
*/
public function getDisplayRegion($inLocale = '')
{
if (!$inLocale) {
$inLocale = $this->getLocale();
}
return IntlLocale::getDisplayRegion($this->getLocale(), $inLocale);
}
示例14: country
public static function country($code, $translate = true)
{
return \Locale::getDisplayRegion("_{$code}", $translate ? Yii::$app->language : 'en');
}
示例15: get_the_terms
<?php
$project_classification = get_the_terms($post, 'project_classification');
$project_classification_slug = $project_classification[0]->slug;
$more_projects = new WP_Query("post_type=project&project_classification={$project_classification_slug}&posts_per_page=4");
// The Loop
if ($more_projects->have_posts()) {
// Display Title With Related Project Classification
echo "<div class='columns medium-12'>";
echo "<h6>Other {$project_classification[0]->name} Projects</h6>";
echo "</div>";
while ($more_projects->have_posts()) {
$more_projects->the_post();
echo '<li>';
the_post_thumbnail('header_thumbnail');
echo '<h4>' . get_the_title() . '</h4>';
echo Locale::getDisplayRegion('-' . rwmb_meta('100foldstudio_project_country_code'), 'en');
echo '</li>';
}
} else {
// No Projects Within The Same Country Found
}
wp_reset_postdata();
?>
</ul>
</div>
</div>
</div>
<div class="row">
<div class="columns medium-12 project-donate-section">