Exemplo n.º 1
0
 /**
  * Returns the code for the panel itself
  *
  * @return string
  */
 public function getPanel()
 {
     $lang_code = $this->translator->getActiveLanguageAndPlural()->getLanguage()->getIso639_1();
     ob_start();
     require __DIR__ . '/Templates/panel.phtml';
     return ob_get_clean();
 }
 protected function saveTextAction(array $request_data)
 {
     if ($request_data['texts']) {
         $translator = $this->translator->getTranslator();
         $translator->removeText($request_data['key']);
         $active_language_and_plural = $this->translator->getActiveLanguageAndPlural();
         $plurals_count = $active_language_and_plural->getPlural()->getPluralsCount();
         for ($plural = 0; $plural < $plurals_count; $plural += 1) {
             if (isset($request_data['texts'][$plural]) && $request_data['texts'][$plural] != '') {
                 $translator->setText($request_data['key'], $request_data['texts'][$plural], $plural);
             }
         }
     }
     $this->loadListAction();
     $this->payload['select'] = $this->createHash($request_data['key']);
     $this->payload['actions'][] = 'selectItem';
 }
 public function testGetActiveLanguageAndPluralWithException()
 {
     $translator = new Translator();
     $this->setExpectedException('Nette\\InvalidStateException');
     $translator->getActiveLanguageAndPlural();
 }