Esempio n. 1
0
 public function save($form, $config)
 {
     if (!($data = $this->check(__FUNCTION__))) {
         return false;
     }
     LGettext::setEntries(Input::get('locale'), $data['translations']);
     Session::flash('flash-message', ['message' => __('Gettext was saved successfully'), 'status' => 'success']);
     return Redirect::back();
 }
 public function load(array $config)
 {
     $config['storage'] = base_path($config['storage']);
     foreach ($config['directories'] as $key => $directory) {
         $config['directories'][$key] = base_path($directory);
     }
     $cookie = $config['cookie'];
     $path = parse_url(url('/'), PHP_URL_PATH) ?: '/';
     $_COOKIE[$cookie] = isset($_COOKIE[$cookie]) ? $_COOKIE[$cookie] : null;
     Gettext::setConfig($config);
     Gettext::setLocale($_COOKIE[$cookie], Input::get($cookie));
     Gettext::load();
     setcookie($cookie, $_COOKIE[$cookie] = Gettext::getLocale(), time() + 3600 * 24 * 30 * 12, $path);
     App::setLocale(preg_replace('/_.*$/', '', $_COOKIE[$cookie]));
 }
Esempio n. 3
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]);
 }
Esempio n. 4
0
 /**
  * Update the gettext entries in storage.
  *
  * @param Request $request
  * @param string  $locale
  *
  * @return Response
  */
 public function update(Request $request, $locale)
 {
     Gettext::setEntries($locale, $request->get('translations'));
     session()->flash('anavel-alert', ['type' => 'success', 'icon' => 'fa-check', 'title' => trans('anavel-gettext::messages.alert_success_update_title'), 'text' => trans('anavel-gettext::messages.alert_success_update_text')]);
     return redirect()->route('anavel-gettext.edit', $locale);
 }