コード例 #1
0
ファイル: TaxRule.php プロジェクト: margery/thelia
 /**
  * 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 ChildTaxRuleI18n */
 public function getTranslation($locale = 'en_US', ConnectionInterface $con = null)
 {
     if (!isset($this->currentTranslations[$locale])) {
         if (null !== $this->collTaxRuleI18ns) {
             foreach ($this->collTaxRuleI18ns as $translation) {
                 if ($translation->getLocale() == $locale) {
                     $this->currentTranslations[$locale] = $translation;
                     return $translation;
                 }
             }
         }
         if ($this->isNew()) {
             $translation = new ChildTaxRuleI18n();
             $translation->setLocale($locale);
         } else {
             $translation = ChildTaxRuleI18nQuery::create()->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))->findOneOrCreate($con);
             $this->currentTranslations[$locale] = $translation;
         }
         $this->addTaxRuleI18n($translation);
     }
     return $this->currentTranslations[$locale];
 }