Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 917fbd7c00
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (40 sloc) 1.636 kb
/**
* 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 <?php echo $i18nTablePhpName ?>
*/
public function getTranslation($locale = '<?php echo $defaultLocale ?>', PropelPDO $con = null)
{
if (!isset($this->currentTranslations[$locale])) {
if (null !== $this-><?php echo $i18nListVariable ?>) {
foreach ($this-><?php echo $i18nListVariable ?> as $translation) {
if ($translation->get<?php echo $localeColumnName ?>() == $locale) {
$this->currentTranslations[$locale] = $translation;
return $translation;
}
}
}
if ($this->isNew()) {
$translation = new <?php echo $i18nTablePhpName ?>();
$translation->set<?php echo $localeColumnName ?>($locale);
} else {
<?php if ($isCompositePrimaryKey): ?>
$pk = $this->getPrimaryKey();
$pk[] = $locale;
$translation = <?php echo $i18nQueryName ?>::create()
->filterByPrimaryKey($pk)
->findOneOrCreate($con);
<?php else: ?>
$translation = <?php echo $i18nQueryName ?>::create()
->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
->findOneOrCreate($con);
<?php endif; ?>
$this->currentTranslations[$locale] = $translation;
}
$this->add<?php echo $i18nSetterMethod ?>($translation);
}
return $this->currentTranslations[$locale];
}
Jump to Line
Something went wrong with that request. Please try again.