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


PHP Locale类代码示例

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


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

示例1: getLocale

 /**
  * Gets the Locale from the identifier.
  * 
  * @param string $identifier The identifier of the Locale, such as en_US.
  * 
  * @return \Attibee\Locale\Locale The Locale object, or null if not found.
  */
 public static function getLocale($identifier)
 {
     $resourceDir = __DIR__ . '/../resources/';
     //let's support both formats
     $identifier = str_replace('-', '_', $identifier);
     $file = $resourceDir . $identifier . '.xml';
     //file does not exist, return null
     if (!file_exists($file)) {
         return null;
     }
     $locale = new Locale($identifier);
     //create reader
     $dom = new \DOMDocument();
     $dom->load($file);
     //add reader to locale resources
     $locale->setDom($dom);
     //add parents by successively removing "_suffix"
     //these are added recursively
     $pos = strrpos($identifier, '_');
     if ($pos !== false) {
         $identifier = substr($identifier, 0, $pos);
         $locale->setParentLocale(LocaleFactory::getLocale($identifier));
     }
     return $locale;
 }
开发者ID:Attibee,项目名称:defunct-dont-use,代码行数:32,代码来源:LocaleFactory.php

示例2: getCurrentLocale

 /**
  * Returns the current locale. This is the default locale if
  * no current lcoale has been set or the set current locale has
  * a language code of "mul".
  *
  * @return \TYPO3\FLOW3\I18n\Locale
  */
 public function getCurrentLocale()
 {
     if (!$this->currentLocale instanceof \TYPO3\FLOW3\I18n\Locale || $this->currentLocale->getLanguage() === 'mul') {
         return $this->defaultLocale;
     }
     return $this->currentLocale;
 }
开发者ID:nxpthx,项目名称:FLOW3,代码行数:14,代码来源:Configuration.php

示例3: sum_page

function sum_page()
{
    global $gEnv;
    $amp_locale = new Locale('amp_root_menu', AMP_LANG);
    import('com.solarix.ampoliros.module.ModuleConfig');
    $mod_cfg = new ModuleConfig($gEnv['root']['db'], 'ampoliros');
    $hui = new Hui($gEnv['root']['db'], TRUE);
    $hui->LoadWidget('table');
    $hui->LoadWidget('page');
    $hui->LoadWidget('vertgroup');
    $hui->LoadWidget('vertframe');
    $hui->LoadWidget('treemenu');
    $hui_page = new HuiPage('page', array('title' => 'Ampoliros' . (strlen(AMP_HOST) ? ' - ' . AMP_HOST . (strlen(AMP_DOMAIN) ? '.' . AMP_DOMAIN : '') : ''), 'border' => 'false'));
    $hui_page->mArgs['background'] = $hui_page->mThemeHandler->mStyle['menuback'];
    $hui_mainvertgroup = new HuiVertGroup('mainvertgroup');
    $el[1]['groupname'] = 'Ampoliros';
    $cont = 1;
    $query =& $gEnv['root']['db']->Execute('SELECT id FROM sites');
    if ($query->NumRows()) {
        $el[1]['groupelements'][$cont]['name'] = $amp_locale->GetStr('siteadmin');
        $el[1]['groupelements'][$cont]['image'] = $hui_page->mThemeHandler->mStyle['siteaccess'];
        $el[1]['groupelements'][$cont]['action'] = 'admin/';
        $el[1]['groupelements'][$cont]['themesized'] = 'true';
        $cont++;
    }
    $el[1]['groupelements'][$cont]['name'] = $amp_locale->GetStr('rootadmin');
    $el[1]['groupelements'][$cont]['image'] = $hui_page->mThemeHandler->mStyle['rootaccess'];
    $el[1]['groupelements'][$cont]['action'] = 'root/';
    $el[1]['groupelements'][$cont]['themesized'] = 'true';
    if ($mod_cfg->GetKey('ampoliros-link-disabled') != '1') {
        $el[1]['groupelements'][++$cont]['name'] = $amp_locale->GetStr('amphome');
        $el[1]['groupelements'][$cont]['image'] = $hui_page->mThemeHandler->mStyle['ampminilogo'];
        $el[1]['groupelements'][$cont]['action'] = 'http://www.ampoliros.com/';
        $el[1]['groupelements'][$cont]['target'] = 'op';
        $el[1]['groupelements'][$cont]['themesized'] = 'true';
    }
    if ($mod_cfg->GetKey('solarix-link-disabled') != '1') {
        $el[1]['groupelements'][++$cont]['name'] = $amp_locale->GetStr('solarixhome');
        $el[1]['groupelements'][$cont]['image'] = $hui_page->mThemeHandler->mStyle['solarixminilogo'];
        $el[1]['groupelements'][$cont]['action'] = 'http://www.solarix.biz/';
        $el[1]['groupelements'][$cont]['target'] = 'op';
        $el[1]['groupelements'][$cont]['themesized'] = 'true';
    }
    if ($mod_cfg->GetKey('oem-link-disabled') != '1') {
        $oem_link_filename = $mod_cfg->GetKey('oem-link-filename');
        if (strlen($oem_link_filename) and file_exists(CGI_PATH . $oem_link_filename)) {
            $el[1]['groupelements'][++$cont]['name'] = $mod_cfg->GetKey('oem-name');
            $el[1]['groupelements'][$cont]['image'] = CGI_URL . $oem_link_filename;
            $el[1]['groupelements'][$cont]['action'] = $mod_cfg->GetKey('oem-url');
            $el[1]['groupelements'][$cont]['target'] = 'parent';
            $el[1]['groupelements'][$cont]['themesized'] = 'false';
        }
    }
    $hui_vertframe = new HuiVertFrame('vertframe');
    $hui_vertframe->AddChild(new HuiTreeMenu('treemenu', array('elements' => $el, 'width' => '120', 'target' => 'parent', 'allgroupsactive' => 'true')));
    $hui_mainvertgroup->AddChild($hui_vertframe);
    $hui_page->AddChild($hui_mainvertgroup);
    $hui->AddChild($hui_page);
    $hui->Render();
}
开发者ID:alexpagnoni,项目名称:ampoliros,代码行数:60,代码来源:sum.php

示例4: testGetDayNameSunday

  function testGetDayNameSunday()
  {
    $locale = new Locale('en');

    $this->assertEqual($locale->getDayName(6, $short = false), 'Sunday');
    $this->assertEqual($locale->getDayName(6, $short = true), 'Sun');
  }
开发者ID:BackupTheBerlios,项目名称:limb-svn,代码行数:7,代码来源:LocaleTest.class.php

示例5: getInstance

 /**
  * Gets the Collator for the desired locale.
  *
  * @param   util.Locale locale
  * @return  text.Collator
  */
 public static function getInstance(Locale $locale)
 {
     $id = $locale->hashCode();
     if (!isset(self::$instance[$id])) {
         self::$instance[$id] = new self($locale->toString());
     }
     return self::$instance[$id];
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:14,代码来源:Collator.class.php

示例6: onBootstrap

 public function onBootstrap($e)
 {
     \Locale::setDefault('de_DE');
     $sm = $e->getApplication()->getServiceManager();
     $translator = $sm->get('translator');
     \Zend\Validator\AbstractValidator::setDefaultTranslator(new \Zend\Mvc\I18n\Translator($translator));
 }
开发者ID:nouron,项目名称:nouron,代码行数:7,代码来源:Module.php

示例7: getLocale

 /**
  * Returns the set locale
  *
  * @return string
  */
 public function getLocale()
 {
     if (null === $this->locale) {
         $this->locale = \Locale::getDefault();
     }
     return $this->locale;
 }
开发者ID:leodido,项目名称:moneylaundry,代码行数:12,代码来源:ScientificNotation.php

示例8: __construct

 public function __construct(Dispatcher $dispatcher)
 {
     $request = $this->getDI()->get('request');
     $queryLang = $request->getQuery('lang');
     if (!$queryLang) {
         $lang = $dispatcher->getParam('lang');
     } else {
         $lang = $queryLang;
     }
     switch ($lang) {
         case 'uk':
             define('LANG', 'uk');
             define('LANG_SUFFIX', '_uk');
             define('LANG_URL', '/uk');
             define('LOCALE', 'uk_UA');
             break;
         case 'en':
             define('LANG', 'en');
             define('LANG_SUFFIX', '_en');
             define('LANG_URL', '/en');
             define('LOCALE', 'en_EN');
             break;
         default:
             define('LANG', 'ru');
             define('LANG_SUFFIX', '');
             define('LANG_URL', '/');
             define('LOCALE', 'ru_RU');
     }
     Locale::setDefault(LOCALE);
     $this->getDI()->set('translate', new \Application\Localization\GettextAdapter(array('locale' => LOCALE, 'lang' => LANG, 'file' => 'messages', 'directory' => APPLICATION_PATH . '/lang')));
 }
开发者ID:bitclaw,项目名称:phalcon-skeleton,代码行数:31,代码来源:LocalizationPlugin.php

示例9: getPattern

 /**
  * Returns the pattern for this locale.
  *
  * The pattern contains the placeholder "{{ widget }}" where the HTML tag should
  * be inserted
  */
 protected static function getPattern($currency)
 {
     if (!$currency) {
         return '{{ widget }}';
     }
     $locale = \Locale::getDefault();
     if (!isset(self::$patterns[$locale])) {
         self::$patterns[$locale] = array();
     }
     if (!isset(self::$patterns[$locale][$currency])) {
         $format = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
         $pattern = $format->formatCurrency('123', $currency);
         // the spacings between currency symbol and number are ignored, because
         // a single space leads to better readability in combination with input
         // fields
         // the regex also considers non-break spaces (0xC2 or 0xA0 in UTF-8)
         preg_match('/^([^\\s\\xc2\\xa0]*)[\\s\\xc2\\xa0]*123(?:[,.]0+)?[\\s\\xc2\\xa0]*([^\\s\\xc2\\xa0]*)$/u', $pattern, $matches);
         if (!empty($matches[1])) {
             self::$patterns[$locale][$currency] = $matches[1] . ' {{ widget }}';
         } elseif (!empty($matches[2])) {
             self::$patterns[$locale][$currency] = '{{ widget }} ' . $matches[2];
         } else {
             self::$patterns[$locale][$currency] = '{{ widget }}';
         }
     }
     return self::$patterns[$locale][$currency];
 }
开发者ID:vadim2404,项目名称:symfony,代码行数:33,代码来源:MoneyType.php

示例10: read

 /**
  * Reads data.
  *
  * Results are aggregated by querying all requested configurations for the requested
  * locale then repeating this process for all locales down the locale cascade. This
  * allows for sparse data which is complemented by data from other sources or for more
  * generic locales. Aggregation can be controlled by either specifying the configurations
  * or a scope to use.
  *
  * Usage:
  * ```
  * Catalog::read(true, 'message', 'zh');
  * Catalog::read('default', 'message', 'zh');
  * Catalog::read('default', 'validation.postalCode', 'en_US');
  * ```
  *
  * @param mixed $name Provide a single configuration name as a string or multiple ones as
  *        an array which will be used to read from. Pass `true` to use all configurations.
  * @param string $category A (dot-delimeted) category.
  * @param string $locale A locale identifier.
  * @param array $options Valid options are:
  *        - `'scope'`: The scope to use.
  *        - `'lossy'`: Whether or not to use the compact and lossy format, defaults to `true`.
  * @return array If available the requested data, else `null`.
  */
 public static function read($name, $category, $locale, array $options = array())
 {
     $defaults = array('scope' => null, 'lossy' => true);
     $options += $defaults;
     $category = strtok($category, '.');
     $id = strtok('.');
     $names = $name === true ? array_keys(static::$_configurations) : (array) $name;
     $results = array();
     foreach (Locale::cascade($locale) as $cascaded) {
         foreach ($names as $name) {
             $adapter = static::adapter($name);
             if ($result = $adapter->read($category, $cascaded, $options['scope'])) {
                 $results += $result;
             }
         }
     }
     if ($options['lossy']) {
         array_walk($results, function (&$value) {
             $value = $value['translated'];
         });
     }
     if ($id) {
         return isset($results[$id]) ? $results[$id] : null;
     }
     return $results ?: null;
 }
开发者ID:unionofrad,项目名称:lithium,代码行数:51,代码来源:Catalog.php

示例11: addItem

 function addItem($args, &$request)
 {
     $this->setupTemplate();
     $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
     $press =& $request->getPress();
     $index = 'sourceTitle-' . $this->getId();
     $format = $args[$index];
     if (!isset($format)) {
         $json = new JSON('false');
         return $json->getString();
     } else {
         // Make sure the item doesn't already exist
         $formats = $pressSettingsDao->getSetting($press->getId(), 'cataloguingMetadata');
         foreach ($formats as $item) {
             if ($item['name'] == $format) {
                 $json = new JSON('false', Locale::translate('common.listbuilder.itemExists'));
                 return $json->getString();
                 return false;
             }
         }
         $formats[] = array('name' => $format);
         $pressSettingsDao->updateSetting($press->getId(), 'cataloguingMetadata', $formats, 'object');
         // Return JSON with formatted HTML to insert into list
         $row =& $this->getRowInstance();
         $row->setGridId($this->getId());
         $row->setId($format);
         $rowData = array('item' => $format);
         $row->setData($rowData);
         $row->initialize($request);
         $json = new JSON('true', $this->_renderRowInternally($request, $row));
         return $json->getString();
     }
 }
开发者ID:ramonsodoma,项目名称:omp,代码行数:33,代码来源:CataloguingMetadataListbuilderHandler.inc.php

示例12: saveProfile

 /**
  * Validate and save changes to user's profile.
  */
 function saveProfile()
 {
     $this->validate();
     $this->setupTemplate();
     $dataModified = false;
     import('user.form.ProfileForm');
     $profileForm = new ProfileForm();
     $profileForm->readInputData();
     if (Request::getUserVar('uploadProfileImage')) {
         if (!$profileForm->uploadProfileImage()) {
             $profileForm->addError('profileImage', Locale::translate('user.profile.form.profileImageInvalid'));
         }
         $dataModified = true;
     } else {
         if (Request::getUserVar('deleteProfileImage')) {
             $profileForm->deleteProfileImage();
             $dataModified = true;
         }
     }
     if (!$dataModified && $profileForm->validate()) {
         $profileForm->execute();
         Request::redirect(null, null, Request::getRequestedPage());
     } else {
         $profileForm->display();
     }
 }
开发者ID:jalperin,项目名称:ocs,代码行数:29,代码来源:ProfileHandler.inc.php

示例13: displayPaymentForm

 function displayPaymentForm($queuedPaymentId, &$queuedPayment)
 {
     if (!$this->isConfigured()) {
         return false;
     }
     $journal =& Request::getJournal();
     $templateMgr =& TemplateManager::getManager();
     $user =& Request::getUser();
     $templateMgr->assign('itemName', $queuedPayment->getName());
     $templateMgr->assign('itemDescription', $queuedPayment->getDescription());
     if ($queuedPayment->getAmount() > 0) {
         $templateMgr->assign('itemAmount', $queuedPayment->getAmount());
         $templateMgr->assign('itemCurrencyCode', $queuedPayment->getCurrencyCode());
     }
     $templateMgr->assign('manualInstructions', $this->getSetting($journal->getJournalId(), 'manualInstructions'));
     $templateMgr->display($this->getTemplatePath() . 'paymentForm.tpl');
     if ($queuedPayment->getAmount() > 0) {
         import('mail.MailTemplate');
         $contactName = $journal->getSetting('contactName');
         $contactEmail = $journal->getSetting('contactEmail');
         $mail =& new MailTemplate('MANUAL_PAYMENT_NOTIFICATION');
         $mail->setFrom($contactEmail, $contactName);
         $mail->addRecipient($contactEmail, $contactName);
         $mail->assignParams(array('journalName' => $journal->getJournalTitle(), 'userFullName' => $user ? $user->getFullName() : '(' . Locale::translate('common.none') . ')', 'userName' => $user ? $user->getUsername() : '(' . Locale::translate('common.none') . ')', 'itemName' => $queuedPayment->getName(), 'itemCost' => $queuedPayment->getAmount(), 'itemCurrencyCode' => $queuedPayment->getCurrencyCode()));
         $mail->send();
     }
 }
开发者ID:LiteratimBi,项目名称:jupitertfn,代码行数:27,代码来源:ManualPaymentPlugin.inc.php

示例14: onBootstrap

 public function onBootstrap(MvcEvent $e)
 {
     $e->getApplication()->getServiceManager()->get('translator');
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     // Add translation
     $translator = $e->getApplication()->getServiceManager()->get('translator');
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $setLang = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     } else {
         $setLang = '';
     }
     $translator->setLocale(\Locale::acceptFromHttp($setLang))->setFallbackLocale('en_US');
     // Add ACL information to the Navigation view helper
     $sm = $e->getApplication()->getServiceManager();
     $authorize = $sm->get('BjyAuthorize\\Service\\Authorize');
     $acl = $authorize->getAcl();
     $role = $authorize->getIdentity();
     \Zend\View\Helper\Navigation::setDefaultAcl($acl);
     \Zend\View\Helper\Navigation::setDefaultRole($role);
     $e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) use($sm) {
         if ($e->getParam('exception')) {
             $sm->get('Zend\\Log\\Logger')->crit($e->getParam('exception'));
         }
     });
 }
开发者ID:riceri,项目名称:MvitInvoice,代码行数:27,代码来源:Module.php

示例15: execute

 /**
  * Create the test locale file.
  */
 function execute()
 {
     Locale::initialize();
     $localeFiles =& Locale::getLocaleFiles();
     $localeFile = array_shift($localeFiles[$this->inLocale]);
     $localeData = LocaleFile::load($localeFile->filename);
     if (!isset($localeData)) {
         printf('Invalid locale \'%s\'', $this->inLocale);
         exit(1);
     }
     $outFile = sprintf('locale/%s/locale.xml', $this->outLocale);
     $fp = fopen($outFile, 'wb');
     if (!$fp) {
         printf('Failed to write to \'%s\'', $outFile);
         exit(1);
     }
     fwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" . "<!DOCTYPE locale SYSTEM \"../locale.dtd\">\n\n" . "<!--\n" . "  * locale.xml\n" . "  *\n" . "  * Copyright (c) 2003-2007 John Willinsky\n" . "  * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.\n" . "  *\n" . sprintf("  * Localization strings for the %s (%s) locale.\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME) . "  *\n" . "  * \$Id\$\n" . "  -->\n\n" . sprintf("<locale name=\"%s\" full_name=\"%s\">\n", $this->outLocale, DEFAULT_OUT_LOCALE_NAME));
     foreach ($localeData as $key => $message) {
         $outMessage = $this->fancifyString($message);
         if (strstr($outMessage, '<') || strstr($outMessage, '>')) {
             $outMessage = '<![CDATA[' . $outMessage . ']]>';
         }
         fwrite($fp, sprintf("\t<message key=\"%s\">%s</message>\n", $key, $outMessage));
     }
     fwrite($fp, "</locale>\n");
     fclose($fp);
 }
开发者ID:alenoosh,项目名称:ojs,代码行数:30,代码来源:genTestLocale.php


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