Sets the path to a vendor package translation files.
public setPathToVendorPackage ( string $packageName ) : void | ||
$packageName | string | |
리턴 | void |
/** * Execute the console command. * * @return mixed */ public function handle() { if ($package = $this->option('package')) { $this->manager->setPathToVendorPackage($package); } $this->files = $this->manager->files(); if (empty($this->files)) { $this->warn('No language files were found!'); } $languages = $this->manager->languages(); $this->table(array_merge(['key'], $languages), $this->tableRows()); }
/** * Execute the console command. * * @return mixed */ public function handle() { try { list($file, $key) = explode('.', $this->argument('key'), 2); } catch (\ErrorException $e) { $this->error('Could not recognize the key you want to remove.'); return; } if ($this->confirm("Are you sure you want to remove \"{$file}.{$key}\"?")) { if (Str::contains($file, '::')) { try { $parts = explode('::', $file); $this->manager->setPathToVendorPackage($parts[0]); $file = $parts[1]; } catch (\ErrorException $e) { $this->error('Could not recognize the package.'); return; } } $this->manager->removeKey($file, $key); $this->info("{$file}.{$key} was removed successfully."); } }
/** * Parse the given key argument. * * @return void */ private function parseKey() { $parts = explode('.', $this->argument('key'), 2); $this->file = $parts[0]; $this->key = isset($parts[1]) ? $parts[1] : null; if (Str::contains($this->file, '::')) { try { $parts = explode('::', $this->file); $this->manager->setPathToVendorPackage($parts[0]); } catch (\ErrorException $e) { $this->error('Could not recognize the package.'); return; } } }
/** * Parse the given key argument. * * @return bool */ private function parseKey() { try { preg_match('/^([^\\.]*)\\.([^\\:]*)/', $this->argument('key'), $matches); $this->fileName = $matches[1]; $this->key = $matches[2]; } catch (\ErrorException $e) { if (!$this->key) { $this->error('Could not recognize the key you want to translate.'); return false; } } if (Str::contains($this->fileName, '::')) { try { $parts = explode('::', $this->fileName); $this->manager->setPathToVendorPackage($parts[0]); $this->packageName = $parts[0]; } catch (\ErrorException $e) { $this->error('Could not recognize the package.'); return false; } } return true; }