Ejemplo n.º 1
0
 public function saveSectionTranslationsToFile(Section $section, Translations $translations)
 {
     $po = DIR_LANGUAGES_SITE_INTERFACE . '/' . $section->getLocale() . '.po';
     $mo = DIR_LANGUAGES_SITE_INTERFACE . '/' . $section->getLocale() . '.mo';
     PoGenerator::toFile($translations, $po);
     /* Do not generate mo for empty catalog, it crashes Zend\I18n gettext loader */
     $empty = true;
     foreach ($translations as $entry) {
         if ($entry->hasTranslation()) {
             $empty = false;
             break;
         }
     }
     if (!$empty) {
         MoGenerator::$includeEmptyTranslations = true;
         MoGenerator::toFile($translations, $mo);
     } else {
         if (is_file($mo)) {
             unlink($mo);
         }
     }
 }