示例#1
0
 /**
  * Show the form for editing the gettext entries.
  *
  * @param string $locale
  *
  * @return Response
  */
 public function edit($locale = '')
 {
     $config = $this->getConfig();
     if (empty($locale)) {
         $locale = $config['locales'][0];
     } elseif (!in_array($locale, $config['locales'], true)) {
         return redirect()->route('anavel-gettext.edit', $config['locales'][0]);
     }
     Gettext::setConfig($config);
     $entries = Gettext::getEntries($locale);
     $base = base_path();
     foreach ($entries as $entry) {
         $entry->lines = [];
         if (!($references = $entry->getReferences())) {
             continue;
         }
         foreach ($references as $index => $reference) {
             $entry->lines[] = str_replace($base, '', $reference[0] . '#' . $reference[1]);
         }
     }
     return view('anavel-gettext::pages.edit', ['current' => $locale, 'locales' => $config['locales'], 'entries' => $entries]);
 }
示例#2
0
 protected function show($form, $config, $locale)
 {
     if (empty($locale)) {
         $locale = $config['locales'][0];
     } elseif (!in_array($locale, $config['locales'], true)) {
         return Redirect::route('admin.management.gettext.app', $config['locales'][0]);
     }
     LGettext::setConfig($config);
     if (is_object($processor = $this->processor(['save', 'download'], $form, $config))) {
         return $processor;
     }
     $entries = LGettext::getEntries($locale);
     $base = base_path();
     foreach ($entries as $entry) {
         $entry->lines = [];
         if (!($references = $entry->getReferences())) {
             continue;
         }
         foreach ($references as $index => $reference) {
             $entry->lines[] = str_replace($base, '', $reference[0] . '#' . $reference[1]);
         }
     }
     return self::view('management.gettext.index', ['form' => $form, 'current' => $locale, 'locales' => $config['locales'], 'entries' => $entries]);
 }