/** * Returns the locale used to look for translations, which may not be the * same as $this->locale * * @return Locale Locale */ public function getTranslationsLocale() { $localeIso = $this->locale->getIso(); if (isset($this->localeTranslationAssociations[$localeIso])) { return new Locale($this->localeTranslationAssociations[$localeIso]); } return $this->locale; }
/** * @expectedException \Exception */ public function testCurrencyRateNotFoundThrowsException() { $locale = $this->getMock('Elcodi\\Component\\Language\\Entity\\Interfaces\\LocaleInterface'); $locale->expects($this->any())->method('getIso')->willReturn('es_ES'); $priceExtension = new MoneyPrinter($this->getMock('Elcodi\\Component\\Currency\\Services\\CurrencyConverter', [], [], '', false), $this->getMock('Elcodi\\Component\\Currency\\Wrapper\\CurrencyWrapper', [], [], '', false), Locale::create($locale)); $currencyFactory = new CurrencyFactory(); $currencyFactory->setEntityNamespace('Elcodi\\Component\\Currency\\Entity\\Currency'); $currencyFactory->setDateTimeFactory(new DateTimeFactory()); $priceExtension->printMoney(Money::create(1000, $currencyFactory->create()->setIso('US1')), 'US1'); }
/** * Get usable locale from current request environment * * @return Locale Locale loaded */ public function getLocale() { $locale = $this->requestStack->getCurrentRequest() instanceof Request ? $this->requestStack->getCurrentRequest()->getLocale() : $this->defaultLocale; return Locale::create($locale); }