/**
  * Register the service provider.
  *
  * @return void
  */
 public function register()
 {
     $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'translaravel');
     $this->commands(['deArgonauten\\TransLaravel\\Commands\\InstallTransLaravel']);
     require_once __DIR__ . '/helpers.php';
     $this->app->singleton('translator', function ($app) {
         $trans = new TransLaravel();
         $trans->setLocale(config('app.fallback_locale'));
         return $trans;
     });
 }
 /**
  * Does translation exists?
  *
  * @param string $key
  * @param string|null $locale
  * @return bool
  */
 public function has(string $key, string $locale = null)
 {
     $locale = $locale || $this->locale;
     $language_id = $locale == $this->locale ? $this->language_id : TransLaravel::class()->localeToId($locale);
     return StringTranslations::whereSearchKey(md5($key))->whereLanguageId($language_id)->count() > 0;
 }
Пример #3
0
 /**
  * Remove a route translation
  *
  * @param string $route
  * @param string|null $locale
  */
 private function remove(string $route, string $locale = null)
 {
     $locale = $locale || $this->locale;
     $language_id = $locale == $this->locale ? $this->language_id : TransLaravel::class()->localeToId($locale);
     RouteTranslations::whereRoute($route)->whereLanguageId($language_id)->first()->delete();
 }