/**
  * Add or set the translation for the locale associated to the
  * given translation.
  *
  * @param Translation $translation
  */
 public function addTranslation(Translation $translation, $isUpdate = true)
 {
     $this->translations[$translation->getLocale()] = $translation;
     if ($isUpdate) {
         $this->setIsModified(true);
     }
 }
Example #2
0
 public function addTranslation(Translation $translation)
 {
     if (!in_array($translation->getLocale(), $this->translationLangs)) {
         $this->translationLangs[] = $translation->getLang();
         $this->translations->add($translation);
     } else {
         throw new ExistingTranslationException(sprintf('Project %s already has a translation for language: %s.', $this->caption, $translation->getLang()));
     }
 }
Example #3
0
/**
Short function to getcurrent lang
*/
function NormalizedLocale()
{
    $locale = Translation::getLocale();
    $aLocal = explode("-", $locale);
    $locale = $aLocal[0];
    if (isset($aLocal[1])) {
        $locale .= "_" . strtoupper($aLocal[1]);
    }
    return $locale;
}