/** * Bootstrap any application services. * * @return void */ public function boot(Localizer $localizer) { $localizer->setLocale(); $this->publishes([__DIR__ . '/Eloquent/Translation.php' => app_path() . '/Translation.php'], 'eloquent'); $this->publishes([__DIR__ . '/config/translator.php' => config_path('translator.php')], 'config'); $this->publishes([__DIR__ . '/migrations/2016_01_01_000000_create_translations_table.php' => base_path('database/migrations/2016_01_01_000000_create_translations_table.php')], 'migrations'); }
protected function parseLocaleGroupNeedle($string) { $parts = explode('.', $string); $obj = new \stdClass(); $obj->group = NULL; $obj->locale = NULL; $obj->needle = NULL; if (sizeof($parts) === 1) { $obj->group = $parts[0]; } else { if (sizeof($parts) === 2 || !in_array($parts[0], $this->localizer->getAvailable())) { $obj->group = $parts[0]; array_shift($parts); $obj->needle = implode('.', $parts); } else { $obj->locale = $parts[0]; $obj->group = $parts[1]; unset($parts[0], $parts[1]); $obj->needle = implode('.', $parts); } } return $obj; }
protected function parseLocaleUriAction($uri, $action) { if (!is_array($action)) { $action = ['uses' => $action]; } $action['base_localization'] = $uri; $action['locales'] = array_merge($this->getLastGroupLocales(), $this->getActionLocales($action)); $isAvailable = in_array($this->localizer->getLocale(), $action['locales']) || in_array('all', $action['locales']); if ($isAvailable) { if (!$this->localizer->isMain() || $this->localizer->isPrefixingMain()) { $uri = array_search($this->localizer->getLocale(), $this->localizer->getAvailable()) . '/' . $uri; } } else { // If current locale is not available for this route, uri must be // hidden for this request. $uri = md5($uri); } $uri = rtrim($uri, '/'); return compact('uri', 'action'); }