<?php namespace Transvision; use Cache\Cache; use VCS\Git; use VCS\Mercurial; use VCS\Subversion; foreach (Project::getRepositories() as $repo) { // Get the right locale for this repo $locale = Project::getLocaleInContext($page_locale, $repo); // We don't care about en-US if ($locale == 'en-US') { continue; } if (in_array($locale, Project::getRepositoryLocales($repo))) { $ref_locale = Project::getReferenceLocale($repo); // Get VCS data $repo_vcs = VersionControl::VCSRepoName($repo); $repo_path = $repo_vcs . '/' . $locale; switch (VersionControl::getVCS($repo)) { case 'hg': $vcs = new Mercurial(HG . $repo_path); break; case 'svn': $vcs = new Subversion(SVN . $repo_path); break; case 'git': $vcs = new Git(GIT . $repo_path); break; }
/** * @dataProvider getRepositoryLocalesDP */ public function testGetRepositoryLocales($a, $b) { $obj = new _Project(); $this->array($obj->getRepositoryLocales($a))->isEqualTo($b); }
/** * Check that a locale is available for a repository * * @param string $locale Locale code we want to check * @param string $repository Repository name we want to check the locale for * @return boolean True if we support the locale, False if we don't */ private function verifyLocaleExists($locale, $repository) { if (!in_array($locale, Project::getRepositoryLocales($repository))) { $this->log("The locale queried ({$locale}) is not " . "available for the repository ({$repository})."); return false; } return true; }
<?php namespace Transvision; use Cache\Cache; $cache_id = $repo . $entity . 'alllocales'; if (!($translations = Cache::getKey($cache_id))) { $translations = []; foreach (Project::getRepositoryLocales($repo) as $locale_code) { $strings = Utils::getRepoStrings($locale_code, $repo); if (isset($strings[$entity])) { $strings[$entity] = trim($strings[$entity]); if (Strings::endsWith(strtolower($strings[$entity]), '{ok}')) { $strings[$entity] = trim(substr($strings[$entity], 0, -4)); } $translations[$locale_code] = $strings[$entity]; } // Releasing memory in the loop saves 15% memory on the script unset($strings); } Cache::setKey($cache_id, $translations); } return $json = $translations;