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


PHP Locale\ResolverInterface类代码示例

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


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

示例1: __construct

 /**
  * @param \Magento\Framework\View\Element\Template\Context $context
  * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
  * @param \Magento\Core\Helper\PostData $postDataHelper
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @param array $data
  */
 public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Directory\Model\CurrencyFactory $currencyFactory, \Magento\Core\Helper\PostData $postDataHelper, \Magento\Framework\Locale\ResolverInterface $localeResolver, array $data = array())
 {
     $this->_currencyFactory = $currencyFactory;
     $this->_postDataHelper = $postDataHelper;
     parent::__construct($context, $data);
     $this->_locale = $localeResolver->getLocale();
 }
开发者ID:aiesh,项目名称:magento2,代码行数:14,代码来源:Currency.php

示例2: __construct

 /**
  * @param Filter $filter
  * @param TimezoneInterface $localeDate
  * @param ResolverInterface $localeResolver
  * @param string $dateFormat
  * @param array $data
  */
 public function __construct(Filter $filter, TimezoneInterface $localeDate, ResolverInterface $localeResolver, $dateFormat = 'M j, Y H:i:s A', array $data = [])
 {
     $this->filter = $filter;
     $this->localeDate = $localeDate;
     $this->locale = $localeResolver->getLocale();
     $this->dateFormat = $dateFormat;
     $this->data = $data;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:15,代码来源:MetadataProvider.php

示例3: getLang

 /**
  * Get current language
  *
  * @return string
  */
 public function getLang()
 {
     if (!$this->hasData('lang')) {
         $this->setData('lang', substr($this->_localeResolver->getLocale(), 0, 2));
     }
     return $this->getData('lang');
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:12,代码来源:Page.php

示例4: aroundAddNameToSelect

 /**
  * @param \Magento\Customer\Model\ResourceModel\Customer\Collection $subject
  * @param \Closure $proceed
  * @return \Magento\Customer\Model\ResourceModel\Customer\Collection
  */
 public function aroundAddNameToSelect(Collection $subject, \Closure $proceed)
 {
     $fields = [];
     $customerAccount = $this->fieldsetConfig->getFieldset('customer_account');
     foreach ($customerAccount as $code => $field) {
         if (isset($field['name'])) {
             $fields[$code] = $code;
         }
     }
     $connection = $subject->getConnection();
     $concatenate = [];
     if (isset($fields['prefix'])) {
         $concatenate[] = $connection->getCheckSql('{{prefix}} IS NOT NULL AND {{prefix}} != \'\'', $connection->getConcatSql(['LTRIM(RTRIM({{prefix}}))', '\' \'']), '\'\'');
     }
     if ($this->localeResolver->getLocale() != 'ja_JP') {
         $concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
     } else {
         $concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
     }
     $concatenate[] = '\' \'';
     if (isset($fields['middlename'])) {
         $concatenate[] = $connection->getCheckSql('{{middlename}} IS NOT NULL AND {{middlename}} != \'\'', $connection->getConcatSql(['LTRIM(RTRIM({{middlename}}))', '\' \'']), '\'\'');
     }
     if ($this->localeResolver->getLocale() != 'ja_JP') {
         $concatenate[] = 'LTRIM(RTRIM({{lastname}}))';
     } else {
         $concatenate[] = 'LTRIM(RTRIM({{firstname}}))';
     }
     if (isset($fields['suffix'])) {
         $concatenate[] = $connection->getCheckSql('{{suffix}} IS NOT NULL AND {{suffix}} != \'\'', $connection->getConcatSql(['\' \'', 'LTRIM(RTRIM({{suffix}}))']), '\'\'');
     }
     $nameExpr = $connection->getConcatSql($concatenate);
     $subject->addExpressionAttributeToSelect('name', $nameExpr, $fields);
     return $subject;
 }
开发者ID:magento-japan,项目名称:m2-jplocalize,代码行数:40,代码来源:ModifyName.php

示例5: getPriceFormat

 /**
  * Functions returns array with price formatting info
  *
  * @return array
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getPriceFormat()
 {
     $localeData = (new DataBundle())->get($this->_localeResolver->getLocale());
     $format = $localeData['NumberElements']['latn']['patterns']['currencyFormat'] ?: explode(';', $localeData['NumberPatterns'][1])[0];
     $decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal'] ?: $localeData['NumberElements'][0];
     $groupSymbol = $localeData['NumberElements']['latn']['symbols']['group'] ?: $localeData['NumberElements'][1];
     $pos = strpos($format, ';');
     if ($pos !== false) {
         $format = substr($format, 0, $pos);
     }
     $format = preg_replace("/[^0\\#\\.,]/", "", $format);
     $totalPrecision = 0;
     $decimalPoint = strpos($format, '.');
     if ($decimalPoint !== false) {
         $totalPrecision = strlen($format) - (strrpos($format, '.') + 1);
     } else {
         $decimalPoint = strlen($format);
     }
     $requiredPrecision = $totalPrecision;
     $t = substr($format, $decimalPoint);
     $pos = strpos($t, '#');
     if ($pos !== false) {
         $requiredPrecision = strlen($t) - $pos - $totalPrecision;
     }
     if (strrpos($format, ',') !== false) {
         $group = $decimalPoint - strrpos($format, ',') - 1;
     } else {
         $group = strrpos($format, '.');
     }
     $integerRequired = strpos($format, '.') - strpos($format, '0');
     $result = ['pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $decimalSymbol, 'groupSymbol' => $groupSymbol, 'groupLength' => $group, 'integerRequired' => $integerRequired];
     return $result;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:39,代码来源:Format.php

示例6: updateAndGetTranslations

 /**
  * Clears cache and updates translations file
  *
  * @return array
  */
 public function updateAndGetTranslations()
 {
     $this->eventManager->dispatch('adminhtml_cache_flush_system');
     $translations = $this->translateResource->getTranslationArray(null, $this->localeResolver->getLocale());
     $this->fileManager->updateTranslationFileContent(json_encode($translations));
     return $translations;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:12,代码来源:CacheManager.php

示例7: _toHtml

 /**
  * Render block HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     $localeData = (new DataBundle())->get($this->_localeResolver->getLocale());
     // get days names
     $daysData = $localeData['calendar']['gregorian']['dayNames'];
     $this->assign('days', ['wide' => $this->encoder->encode(array_values(iterator_to_array($daysData['format']['wide']))), 'abbreviated' => $this->encoder->encode(array_values(iterator_to_array($daysData['format']['abbreviated'])))]);
     // get months names
     $monthsData = $localeData['calendar']['gregorian']['monthNames'];
     $this->assign('months', ['wide' => $this->encoder->encode(array_values(iterator_to_array($monthsData['format']['wide']))), 'abbreviated' => $this->encoder->encode(array_values(iterator_to_array($monthsData['format']['abbreviated'])))]);
     // get "today" and "week" words
     $this->assign('today', $this->encoder->encode($localeData['fields']['day']['relative']['0']));
     $this->assign('week', $this->encoder->encode($localeData['fields']['week']['dn']));
     // get "am" & "pm" words
     $this->assign('am', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['0']));
     $this->assign('pm', $this->encoder->encode($localeData['calendar']['gregorian']['AmPmMarkers']['1']));
     // get first day of week and weekend days
     $this->assign('firstDay', (int) $this->_scopeConfig->getValue('general/locale/firstday', \Magento\Store\Model\ScopeInterface::SCOPE_STORE));
     $this->assign('weekendDays', $this->encoder->encode((string) $this->_scopeConfig->getValue('general/locale/weekend', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)));
     // define default format and tooltip format
     $this->assign('defaultFormat', $this->encoder->encode($this->_localeDate->getDateFormat(\IntlDateFormatter::MEDIUM)));
     $this->assign('toolTipFormat', $this->encoder->encode($this->_localeDate->getDateFormat(\IntlDateFormatter::LONG)));
     // get days and months for en_US locale - calendar will parse exactly in this locale
     $englishMonths = (new DataBundle())->get('en_US')['calendar']['gregorian']['monthNames'];
     $enUS = new \stdClass();
     $enUS->m = new \stdClass();
     $enUS->m->wide = array_values(iterator_to_array($englishMonths['format']['wide']));
     $enUS->m->abbr = array_values(iterator_to_array($englishMonths['format']['abbreviated']));
     $this->assign('enUS', $this->encoder->encode($enUS));
     return parent::_toHtml();
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:35,代码来源:Calendar.php

示例8: testGetLocale

 public function testGetLocale()
 {
     $expected = 'locale';
     $this->locale->expects($this->once())->method('getLocaleCode')->will($this->returnValue($expected));
     $actual = $this->model->getLocale();
     $this->assertSame($expected, $actual);
 }
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:7,代码来源:DesignTest.php

示例9: getCurrentLocale

 /**
  * return current locale code
  */
 public function getCurrentLocale()
 {
     if ($this->_localeResolver->getLocale() == 'ja_JP') {
         return 'ja';
     }
     return 'en';
 }
开发者ID:Magento-Japan,项目名称:m2-jpzip2address,代码行数:10,代码来源:Data.php

示例10: mockGridDateRendererBehaviorWithLocale

 /**
  * @param string $locale
  */
 private function mockGridDateRendererBehaviorWithLocale($locale)
 {
     $this->resolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
     $this->localeDate->expects($this->any())->method('getDateFormat')->willReturnCallback(function ($value) use($locale) {
         return (new \IntlDateFormatter($locale, $value, \IntlDateFormatter::NONE))->getPattern();
     });
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:10,代码来源:DateTest.php

示例11: setupAggregate

 /**
  * Set up aggregate
  *
  * @return \DateTime
  */
 protected function setupAggregate()
 {
     $this->localeResolverMock->expects($this->once())->method('emulate')->with(0);
     $this->localeResolverMock->expects($this->once())->method('revert');
     $date = (new \DateTime())->sub(new \DateInterval('PT25H'));
     $this->localeDateMock->expects($this->once())->method('date')->will($this->returnValue($date));
     return $date;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:AggregateSalesReportBestsellersDataTest.php

示例12: _initSelect

 /**
  * Initialize select object
  *
  * @return $this
  */
 protected function _initSelect()
 {
     parent::_initSelect();
     $locale = $this->_localeResolver->getLocale();
     $this->addBindParam(':region_locale', $locale);
     $this->getSelect()->joinLeft(['rname' => $this->_regionNameTable], 'main_table.region_id = rname.region_id AND rname.locale = :region_locale', ['name']);
     return $this;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:13,代码来源:Collection.php

示例13: testGetConfig

 /**
  * @dataProvider getConfigDataProvider
  */
 public function testGetConfig($configData, $locale, $expectedResult)
 {
     foreach ($configData as $key => $value) {
         $this->configMock->expects($this->any())->method($key)->willReturn($value);
     }
     $this->localResolverMock->expects($this->any())->method('getLocale')->willReturn($locale);
     $this->assertEquals($expectedResult, $this->model->getConfig());
 }
开发者ID:nja78,项目名称:magento2,代码行数:11,代码来源:PayPalTest.php

示例14: outputFilter

 /**
  * Returns the result of filtering $value
  *
  * @param string $value
  * @return string
  */
 public function outputFilter($value)
 {
     $filterInput = new \Zend_Filter_LocalizedToNormalized(['date_format' => DateTime::DATE_INTERNAL_FORMAT, 'locale' => $this->localeResolver->getLocale()]);
     $filterInternal = new \Zend_Filter_NormalizedToLocalized(['date_format' => $this->_dateFormat, 'locale' => $this->localeResolver->getLocale()]);
     $value = $filterInput->filter($value);
     $value = $filterInternal->filter($value);
     return $value;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:Date.php

示例15: execute

 /**
  * Refresh sales order report statistics for last day
  *
  * @return void
  */
 public function execute()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->sub(new \DateInterval('PT25H'));
     $this->orderFactory->create()->aggregate($date);
     $this->localeResolver->revert();
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:AggregateSalesReportOrderData.php


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