/** * @param Section $section * @return StackCategory */ public static function createFromMultilingualSection(Section $section) { $parent = \Page::getByPath(STACKS_PAGE_PATH); $data = array(); $data['name'] = $section->getLocale(); $data['cHandle'] = $section->getLocale(); $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE); $page = $parent->add($type, $data); $sc = new StackCategory($page); return $sc; }
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); } } }