Пример #1
0
 /**
  * Returns the current translation for a given locale
  *
  * @param     string $locale Locale to use for the translation, e.g. 'fr_FR'
  * @param     PropelPDO $con an optional connection object
  *
  * @return PrincipalI18n */
 public function getTranslation($locale = 'en_US', PropelPDO $con = null)
 {
     if (!isset($this->currentTranslations[$locale])) {
         if (null !== $this->collPrincipalI18ns) {
             foreach ($this->collPrincipalI18ns as $translation) {
                 if ($translation->getLocale() == $locale) {
                     $this->currentTranslations[$locale] = $translation;
                     return $translation;
                 }
             }
         }
         if ($this->isNew()) {
             $translation = new PrincipalI18n();
             $translation->setLocale($locale);
         } else {
             $translation = PrincipalI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->findOneOrCreate($con);
             $this->currentTranslations[$locale] = $translation;
         }
         $this->addPrincipalI18n($translation);
     }
     return $this->currentTranslations[$locale];
 }