コード例 #1
0
 private static function getCache($locale)
 {
     if (is_file($file = self::getFile($locale) . 'po')) {
         return Extractors\Po::fromFile($file);
     }
     return false;
 }
コード例 #2
0
 public static function UpdateAll($refresh = true)
 {
     if (empty($refresh) && ($cache = self::getCache(self::$locale))) {
         return $cache;
     }
     $entries = clone self::scan();
     $file = self::getFile(self::$locale);
     if (is_file(base_path() . "/" . $file . 'mo')) {
         $entries->mergeWith(Extractors\Mo::fromFile(base_path() . "/" . $file . 'mo'));
         $entries->mergeWith(Extractors\Po::fromFile(base_path() . "/" . $file . 'po'));
     }
     self::setTranslationObject($entries);
     self::UpdateFiles();
 }
コード例 #3
0
 public function mergeTranslationsWithPackages(Section $section, Translations $translations)
 {
     foreach (PackageList::get()->getPackages() as $package) {
         /* @var $package \Concrete\Core\Package\Package */
         $baseDir = $package->getPackagePath() . '/' . DIRNAME_LANGUAGES . '/' . $section->getLocale() . '/LC_MESSAGES';
         $poFile = $baseDir . '/messages.po';
         $moFile = $baseDir . '/messages.mo';
         $packageTranslations = null;
         if (is_file($poFile)) {
             $packageTranslations = PoExtractor::fromFile($poFile);
         } elseif (is_file($moFile)) {
             $packageTranslations = MoExtractor::fromFile($moFile);
         }
         if (isset($packageTranslations)) {
             foreach ($translations as $translation) {
                 /* @var $translation \Gettext\Translation */
                 if (!$translation->hasTranslation()) {
                     $packageTranslation = $packageTranslations->find($translation);
                     if ($packageTranslation && $packageTranslation->hasTranslation()) {
                         $translation->mergeWith($packageTranslation);
                     }
                 }
             }
         }
     }
 }