当前位置: 首页>>代码示例>>PHP>>正文


PHP Locale::getScript方法代码示例

本文整理汇总了PHP中Locale::getScript方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getScript方法的具体用法?PHP Locale::getScript怎么用?PHP Locale::getScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Locale的用法示例。


在下文中一共展示了Locale::getScript方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateLocaleName

 private function generateLocaleName($locale, $displayLocale)
 {
     $name = null;
     $lang = \Locale::getPrimaryLanguage($locale);
     $script = \Locale::getScript($locale);
     $region = \Locale::getRegion($locale);
     $variants = \Locale::getAllVariants($locale);
     // Currently the only available variant is POSIX, which we don't want
     // to include in the list
     if (count($variants) > 0) {
         return null;
     }
     // Some languages are translated together with their region,
     // i.e. "en_GB" is translated as "British English"
     // we don't include these languages though because they mess up
     // the name sorting
     // $name = $this->langBundle->getLanguageName($displayLocale, $lang, $region);
     // Some languages are simply not translated
     // Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
     if (null === ($name = $this->languageBundle->getLanguageName($lang, null, $displayLocale))) {
         return null;
     }
     // "as" (Assamese) has no "Variants" block
     //if (!$langBundle->get('Variants')) {
     //    continue;
     //}
     $extras = array();
     // Discover the name of the script part of the locale
     // i.e. in zh_Hans_MO, "Hans" is the script
     if ($script) {
         // Some scripts are not translated into every language
         if (null === ($scriptName = $this->languageBundle->getScriptName($script, $lang, $displayLocale))) {
             return null;
         }
         $extras[] = $scriptName;
     }
     // Discover the name of the region part of the locale
     // i.e. in de_AT, "AT" is the region
     if ($region) {
         // Some regions are not translated into every language
         if (null === ($regionName = $this->regionBundle->getCountryName($region, $displayLocale))) {
             return null;
         }
         $extras[] = $regionName;
     }
     if (count($extras) > 0) {
         // Remove any existing extras
         // For example, in German, zh_Hans is "Chinesisch (vereinfacht)".
         // The latter is the script part which is already included in the
         // extras and will be appended again with the other extras.
         if (preg_match('/^(.+)\\s+\\([^\\)]+\\)$/', $name, $matches)) {
             $name = $matches[1];
         }
         $name .= ' (' . implode(', ', $extras) . ')';
     }
     return $name;
 }
开发者ID:TuxCoffeeCorner,项目名称:tcc,代码行数:57,代码来源:LocaleBundleTransformationRule.php

示例2: foreach

// the braces are not printed.
foreach ($translatedLocales as $translatedLocale) {
    // Don't include ICU's root resource bundle
    if ($translatedLocale === 'root') {
        continue;
    }
    $langBundle = load_resource_bundle($translatedLocale, $langDir);
    $regionBundle = load_resource_bundle($translatedLocale, $regionDir);
    $localeNames = array();
    foreach ($supportedLocales as $supportedLocale) {
        // Don't include ICU's root resource bundle
        if ($supportedLocale === 'root') {
            continue;
        }
        $lang = \Locale::getPrimaryLanguage($supportedLocale);
        $script = \Locale::getScript($supportedLocale);
        $region = \Locale::getRegion($supportedLocale);
        $variants = \Locale::getAllVariants($supportedLocale);
        // Currently the only available variant is POSIX, which we don't want
        // to include in the list
        if (count($variants) > 0) {
            continue;
        }
        $langName = $langBundle->get('Languages')->get($lang);
        $extras = array();
        // Some languages are simply not translated
        // Example: "az" (Azerbaijani) has no translation in "af" (Afrikaans)
        if (!$langName) {
            continue;
        }
        // "af" (Afrikaans) has no "Scripts" block
开发者ID:ronaldlunaramos,项目名称:webstore,代码行数:31,代码来源:build-data.php

示例3: getScript

 /**
  * Gets the script for the locale
  *
  * @return string The script subtag for the locale or NULL if not present
  */
 public function getScript()
 {
     return IntlLocale::getScript($this->getLocale());
 }
开发者ID:ledgr,项目名称:localefacade,代码行数:9,代码来源:LocaleFacade.php

示例4: scriptCode

 /**
  * Returns the script code of a locale.
  *
  * @return CUStringObject The locale's four-letter script code (always titlecased).
  */
 public function scriptCode()
 {
     assert('$this->hasScriptCode()', vs(isset($this), get_defined_vars()));
     return Locale::getScript($this->m_name);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:10,代码来源:CULocale.php

示例5:

    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>';
    ?>
</td>
    </tr>
    <tr>
        <th>Default Currency</th>
        <?php 
    $defaultCurrency = \app\models\NumberFormatterInfo::getDefaultCurrency($locale);
开发者ID:samdark,项目名称:intl-icu-data-tables,代码行数:31,代码来源:index.php


注:本文中的Locale::getScript方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。