Beispiel #1
0
 /**
  * Return an array of strings for a locale from a repository
  * @param  string $locale     Locale we want to have strings for
  * @param  string $repository string repository such as gaia_2_0, central...
  * @return array  Localized strings or empty array if no match
  */
 public static function getRepoStrings($locale, $repository)
 {
     $locale = Project::getLocaleInContext($locale, $repository);
     $file = TMX . "{$locale}/cache_{$locale}_{$repository}.php";
     if (!is_file($file)) {
         return [];
     }
     include $file;
     if (!isset($tmx)) {
         error_log('$tmx not set in file: ' . $file);
     }
     return $tmx;
 }
Beispiel #2
0
<?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;
        }
Beispiel #3
0
 /**
  * Return an array of strings for a locale from a repository
  * @param  string $locale     Locale we want to have strings for
  * @param  string $repository string repository such as gaia_1_3, central...
  * @return array  Localized strings or empty array if no match
  */
 public static function getRepoStrings($locale, $repository)
 {
     $locale = Project::getLocaleInContext($locale, $repository);
     $file = TMX . "{$locale}/cache_{$locale}_{$repository}.php";
     if (!($tmx = Cache::getKey($file))) {
         if (is_file($file)) {
             include $file;
             Cache::setKey($file, $tmx);
         }
     }
     return isset($tmx) ? $tmx : [];
 }
Beispiel #4
0
 /**
  * @dataProvider getLocaleInContextDP
  */
 public function testGetLocaleInContext($a, $b, $c)
 {
     $obj = new _Project();
     $this->string($obj->getLocaleInContext($a, $b))->isEqualTo($c);
 }