function it_should_assign_current_and_default_locale_to_given_translatable_entity(TranslationLocaleProviderInterface $translationLocaleProvider, TranslatableInterface $translatableEntity) { $translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US'); $translatableEntity->setCurrentLocale('en_US')->shouldBeCalled(); $translatableEntity->setFallbackLocale('en_US')->shouldBeCalled(); $this->assignLocale($translatableEntity); }
function it_should_use_default_locale_as_current_if_could_not_resolve_the_current_locale(LocaleContextInterface $localeContext, TranslationLocaleProviderInterface $translationLocaleProvider, TranslatableInterface $translatableEntity) { $localeContext->getLocaleCode()->willThrow(new LocaleNotFoundException()); $translationLocaleProvider->getDefaultLocaleCode()->willReturn('en_US'); $translatableEntity->setCurrentLocale('en_US')->shouldBeCalled(); $translatableEntity->setFallbackLocale('en_US')->shouldBeCalled(); $this->assignLocale($translatableEntity); }
/** * {@inheritdoc} */ public function assignLocale(TranslatableInterface $translatableEntity) { $fallbackLocale = $this->translationLocaleProvider->getDefaultLocaleCode(); try { $currentLocale = $this->localeContext->getLocaleCode(); } catch (LocaleNotFoundException $e) { $currentLocale = $fallbackLocale; } $translatableEntity->setCurrentLocale($currentLocale); $translatableEntity->setFallbackLocale($fallbackLocale); }
/** * {@inheritdoc} */ public function assignLocale(TranslatableInterface $translatableEntity) { $localeCode = $this->translationLocaleProvider->getDefaultLocaleCode(); $translatableEntity->setCurrentLocale($localeCode); $translatableEntity->setFallbackLocale($localeCode); }