private function saveDescription(Module $module, \SimpleXMLElement $content, ConnectionInterface $con) { foreach ($content->descriptive as $description) { $locale = $description->attributes()->locale; $moduleI18n = new ModuleI18n(); $moduleI18n->setLocale($locale)->setModule($module)->setTitle($description->title)->setDescription(isset($description->description) ? $description->description : null)->setPostscriptum(isset($description->postscriptum) ? $description->postscriptum : null)->setChapo(isset($description->subtitle) ? $description->subtitle : null)->save($con); } }
/** * 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 ChildModuleI18n */ public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) { if (!isset($this->currentTranslations[$locale])) { if (null !== $this->collModuleI18ns) { foreach ($this->collModuleI18ns as $translation) { if ($translation->getLocale() == $locale) { $this->currentTranslations[$locale] = $translation; return $translation; } } } if ($this->isNew()) { $translation = new ChildModuleI18n(); $translation->setLocale($locale); } else { $translation = ChildModuleI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->findOneOrCreate($con); $this->currentTranslations[$locale] = $translation; } $this->addModuleI18n($translation); } return $this->currentTranslations[$locale]; }