public function __construct(Project $project, $locale = "") { $this->project = $project; $this->locales = $project->getManagedLocales(); $this->locale = $locale; $this->bundle_file = false; }
protected function allLanguageCodes() { $managed_locales = explode(",", $this->project->getManagedLocales()); $managed_locales[] = self::WILD_KEY; return $managed_locales; }
/** * saves the message into $translation[$key][$locale][$message] and normalize rest of translations of this key * * @param Project $project * @param $criteria * @param $key * @param $locale * @param $message * * @return Translation */ public function putTranslation(Project $project, $criteria, $key, $locale, $message) { // first get the record if (strpos($criteria, "Bundle") != false) { $translation = $this->getTranslationRepository()->getTranslationByBundle($project->getId(), $criteria, $key); } else { $translation = $this->getTranslationRepository()->getTranslation($project->getId(), $criteria, $key); } if (!$translation) { return; } $managedLocales = explode(',', $project->getManagedLocales()); $translation = $this->normalizeTranslation($translation, $managedLocales); // now normalize (creates items for managed locales that not exists) $transArray = $translation->getTranslations(); $transArray[$locale] = array_merge($transArray[$locale], Translation::genTranslationItem($message)); $translation->setTranslations($transArray); // last, return return $translation; }