예제 #1
0
 /**
  * @param Project $project
  *
  * @return Translations
  */
 public function addProject(Project $project)
 {
     if ($this->getProject($project->getId())) {
         throw new \InvalidArgumentException(sprintf('Project "%s" already added', $project->getId()));
     }
     $this->projects[] = $project;
     return $this;
 }
예제 #2
0
파일: Loader.php 프로젝트: Appsco/translato
 /**
  * @param Project $project
  *
  * @return LoadedProject|null
  */
 public function load(Project $project, $preferedDomain, $preferedLocale)
 {
     $domain = $project->pickDomain($preferedDomain);
     if (null == $domain) {
         return null;
     }
     $locale = $project->pickLocale($domain, $preferedLocale);
     $catalogue = $this->loader->loadFile($project->getFilePathName($domain, $locale), $project->getFileFormat($domain, $locale), $locale, $domain);
     $alternativeMessages = [];
     foreach ($project->getLocales($domain) as $otherLocale) {
         if ($locale === $otherLocale) {
             continue;
         }
         $altCatalogue = $this->loader->loadFile($project->getFilePathName($domain, $otherLocale), $project->getFileFormat($domain, $otherLocale), $otherLocale, $domain);
         foreach ($altCatalogue->getDomain($domain)->all() as $id => $message) {
             $alternativeMessages[$id][$otherLocale] = $message;
         }
     }
     $newMessages = $existingMessages = array();
     foreach ($catalogue->getDomain($domain)->all() as $id => $message) {
         if ($message->isNew()) {
             $newMessages[$id] = $message;
             continue;
         }
         $existingMessages[$id] = $message;
     }
     return new LoadedProject($project, $domain, $locale, $catalogue, $newMessages, $existingMessages, $alternativeMessages);
 }
예제 #3
0
파일: Store.php 프로젝트: Appsco/translato
 public function deleteProject(Account $account, Project $project)
 {
     $dir = $this->getUserDirPath($account->getUsername());
     $filesystem = new Filesystem();
     $filesystem->remove($dir . '/' . $project->getId());
     $account->getTranslations()->removeProject($project->getId());
     $this->save($account->getUsername(), $account->getTranslations());
 }