/** * Execute the console command. * * @return void */ public function fire() { $group = $this->input->getArgument('group'); $line = $this->input->getArgument('line'); $this->manager->removeLine($group, $line); $this->info("Translation '{$group}.{$line}' has been removed."); }
/** * Execute the console command. * * @return void */ public function fire() { $htmlentities = !$this->input->getOption('no-entities'); $this->info("It's time to DIGG for some translations!"); $this->info(' '); foreach ($this->manager->getDiggFiles() as $file) { $path = str_replace(base_path() . '/', '', $file); $this->comment("Digging translations for {$path}"); foreach ($this->getTranlations($file) as $translate) { if (!$translate['valid'] and !$this->confirm('Translation "' . $translate['lang_query'] . '" seems wrong. Want to try to translate it anyway? [yes|no]')) { continue; } foreach ($this->manager->getLanguages() as $language) { $lang_query = array_get($translate, 'lang_query'); $parameters = array_get($translate, 'parameters'); $group = array_get($translate, 'group'); $line = array_get($translate, 'line'); if (Lang::get($lang_query, $parameters) == $lang_query) { if (is_null($translation = $this->ask("Translate '{$lang_query}'" . (!empty($parameters) ? " [" . implode(',', $parameters) . "]" : null) . " in " . strtoupper($language) . ": "))) { continue; } $this->manager->setLanguage($language)->addLine($group, $line, $translation, $htmlentities); } } } } }
/** * Generate example for easy copy paste * @param string $file * @param string $line * @param string $translation * @return void */ protected function createExample($file, $line, $translation) { if ($variables = $this->manager->getTranslationVariables($translation)) { $variables = '"' . implode('" => "", "', $variables) . '" => ""'; array_push($this->examples, "{{{ trans('{$file}.{$line}', [{$variables}]) }}}"); } else { array_push($this->examples, "{{{ trans('{$file}.{$line}') }}}"); } }
protected function processGroup($group, $lines) { // Do nothing if there is no line if (empty($lines) || is_string($lines)) { return; } array_set($this->missing, $group, array()); $this->line("Processing {$group} group..."); $this->progress->start($this->output, count($lines, COUNT_RECURSIVE)); // Iterate over passed lines foreach ($lines as $line => $translation) { // Run recursive if translation is an array if (is_array($translation)) { $this->processGroup($group . '.' . $line, $line); } else { if ($this->manager->findLineCount($group, $line) == 0) { array_push($this->missing[$group], $line); } $this->progress->advance(); } } $this->line(" "); // Add line break to stop lines from joining if ($missing = array_get($this->missing, $group)) { foreach ($missing as $m) { if ($this->input->getOption('silent') or $confirm = $this->confirm("{$group}.{$m} is missing. Remove? [yes/no]")) { $this->manager->removeLine($group, $m); $this->info("Removed {$m} from {$group}"); } } } }