/** * Returns the current translation for a given locale * * @param string $locale Locale to use for the translation, e.g. 'fr_FR' * @param ConnectionInterface $con an optional connection object * * @return ChildVariationI18n */ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collVariationI18ns) { foreach ($this->collVariationI18ns as $translation) { if ($translation->getLocale() == $locale) { $this->currentTranslations[$locale] = $translation; return $translation; } } } if ($this->isNew()) { $translation = new ChildVariationI18n(); $translation->setLocale($locale); } else { $translation = ChildVariationI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; } $this->addVariationI18n($translation); } return $this->currentTranslations[$locale]; }