示例#1
0
 protected function createComponentGrid()
 {
     $grid = new \App\Grid\Grid();
     $grid->setModel($this->model->getAll());
     $grid->addColumn(new \App\Grid\Column\Column('name', $this->translator->translate('admin.form.name')));
     $grid->addColumn(new \App\Grid\Column\Column('shortcut', $this->translator->translate('language.shortcut')));
     $grid->addColumn(new \App\Grid\Column\Column('id', $this->translator->translate('admin.grid.id')));
     $grid->addMenu(new \App\Grid\Menu\Update('edit', $this->translator->translate('admin.form.edit')));
     $grid->addMenu(new \App\Grid\Menu\Delete('delete', $this->translator->translate('admin.grid.delete')));
     return $grid;
 }
示例#2
0
 public function beforeRender()
 {
     parent::beforeRender();
     $this->template->setTranslator($this->translator);
     $this->template->menuPresenters = $this->menuModules;
     $this->template->languages = $this->languages->getAll();
     $this->template->webLanguage = $this->webLanguage;
 }
示例#3
0
 /**
  * @return Nette\Application\IRouter
  */
 public function createRouter()
 {
     $langRoute = array('language');
     foreach ($this->languages->getAll() as $language) {
         $langRoute[] = $language['link'];
     }
     $uri = explode('/', $_SERVER['REQUEST_URI']);
     if (isset($uri[1])) {
         $language = $this->languages->where('link', $uri[1])->fetch();
     } else {
         $language = $this->languages->get(1);
     }
     $router = new RouteList();
     $router[] = $adminRouter = new RouteList('Admin');
     $adminRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]admin/<presenter>/<action>', 'Homepage:default');
     $router[] = $frontRouter = new RouteList('Front');
     $pages = $this->pages->where('NOT module', null)->fetchAll();
     foreach ($pages as $page) {
         $link = $page['link'];
         //jen staticka
         if (in_array($page['module'], array())) {
             //vypis => detail s ID
         } elseif (in_array($page['module'], array())) {
             //katalog
             $frontRouter[] = new Route('[<locale=cs cs|en>/]' . $link . '/<link>/<id [0-9]+>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             $frontRouter[] = new Route('[<locale=cs cs|en>/]' . $link . '/<url>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             //jen specialni stranka modulu
         } else {
             $frontRouter[] = new Route('[<locale=cs cs|en>/]<presenter>/', array('action' => 'default', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
             $frontRouter[] = new Route('[<locale=cs cs|en>/]<presenter>/[<id>/]', array('action' => 'detail', 'presenter' => array(Route::FILTER_TABLE => array($link => $this->createPresenterName($page['module'])), Route::FILTER_STRICT => true)));
         }
     }
     //obrazky
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<presenter image>/<action preview>/', array('presenter' => 'Homepage', 'action' => 'default'));
     //stranky
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<url .*>/', array('presenter' => 'Page', 'action' => 'default'));
     //vychozi router
     $frontRouter[] = new Route('[<locale=cs ' . implode('|', $langRoute) . '>/]<presenter>/<action>/[<id>/]', array('presenter' => 'Homepage', 'action' => 'default'));
     return $router;
 }
示例#4
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($this->validate($input, $output) !== TRUE) {
         return 1;
     }
     $this->extractor->addExtractor('php', new PhpExtractor());
     $defaultLocale = null;
     foreach ($this->translator->getFallbackLocales() as $locale) {
         if (is_null($defaultLocale)) {
             $defaultLocale = $locale;
         }
         $catalogue = new MessageCatalogue($locale);
         $output->writeln(sprintf('<info>Locale %s</info>', $locale));
         foreach ($this->scanDirs as $dir) {
             $output->writeln(sprintf('<info>Extracting %s</info>', $dir));
             $this->extractor->extract($dir, $catalogue);
         }
     }
     $this->writer->writeTranslations($catalogue, $this->outputFormat, ['path' => $this->outputDir]);
     $output->writeln('');
     $output->writeln(sprintf('<info>Catalogue was written to %s</info>', $this->outputDir));
     $output->writeln('');
     $output->writeln(sprintf('<info>Zapisuji do DB</info>'));
     $toTranslate = (include dirname(__FILE__) . '/../../../../../temp/lang/messages.' . $defaultLocale . '.php');
     $texts = array('');
     foreach ($toTranslate as $translate) {
         $texts[] = $translate;
         $trans = $this->translates->where('text', $translate)->fetch();
         if (!$trans) {
             $this->translates->insert(array('text' => $translate));
         }
     }
     $this->translates->where('NOT text', $texts)->delete();
     $language = $this->languages->where('translate_locale', $defaultLocale)->fetch();
     $catalogue = new MessageCatalogue($language['translate_locale']);
     foreach ($this->translates->getAll() as $translate) {
         $translatesLocale = $translate->related('translate_locale')->where('language_id', $language['id'])->fetch();
         if ($translatesLocale) {
             $catalogue->set($translate['text'], $translatesLocale['translate']);
         } else {
             $catalogue->set($translate['text'], $translate['text']);
         }
     }
     $this->writer->writeTranslations($catalogue, 'neon', ['path' => $this->langDir]);
     return 0;
 }