@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $query = TranslationIdentifier::with('translations'); |
| 36 | 36 | |
| 37 | 37 | if ($locale != '') { |
| 38 | - $query = $query->whereDoesntHave('translations', function ($query) use ($locale) |
|
| 38 | + $query = $query->whereDoesntHave('translations', function($query) use ($locale) |
|
| 39 | 39 | { |
| 40 | 40 | $query->where('translations.locale', 'like', $locale); |
| 41 | 41 | } |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | if ($search != '') { |
| 46 | - $query = $query->where(function ($query) use ($search) { |
|
| 47 | - $query ->where('identifier', 'LIKE', '%'.$search.'%') |
|
| 46 | + $query = $query->where(function($query) use ($search) { |
|
| 47 | + $query ->where('identifier', 'LIKE', '%'.$search.'%') |
|
| 48 | 48 | ->orWhere('parameters', 'LIKE', '%'.$search.'%') |
| 49 | - ->orWhere('group', 'LIKE', '%'.$search.'%') |
|
| 50 | - ->orWhere('page_name', 'LIKE', '%'.$search.'%') |
|
| 51 | - ->orWhere('description','LIKE', '%'.$search.'%'); |
|
| 49 | + ->orWhere('group', 'LIKE', '%'.$search.'%') |
|
| 50 | + ->orWhere('page_name', 'LIKE', '%'.$search.'%') |
|
| 51 | + ->orWhere('description', 'LIKE', '%'.$search.'%'); |
|
| 52 | 52 | }); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | * @param $state string 'enabled|disabled' |
| 169 | 169 | * @return \Illuminate\Http\RedirectResponse |
| 170 | 170 | */ |
| 171 | - public function changeLiveMode ($state) |
|
| 171 | + public function changeLiveMode($state) |
|
| 172 | 172 | { |
| 173 | 173 | if ($state == 'enable') { |
| 174 | 174 | session(['translation_live_mode' => true]); |
@@ -114,7 +114,7 @@ |
||
| 114 | 114 | { |
| 115 | 115 | $trans_identifier = new TranslationIdentifier(); |
| 116 | 116 | |
| 117 | - $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) |
|
| 117 | + $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function($item) use ($locale) |
|
| 118 | 118 | { |
| 119 | 119 | return $item->where('locale', $locale); |
| 120 | 120 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
| 28 | 28 | |
| 29 | - $this->app->singleton('Translator', function () { |
|
| 29 | + $this->app->singleton('Translator', function() { |
|
| 30 | 30 | return new Translator(); |
| 31 | 31 | } |
| 32 | 32 | ); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | public function boot() |
| 39 | 39 | { |
| 40 | 40 | $this->publishes([ |
| 41 | - __DIR__ . '/../config/translator.php' => config_path('translator.php'), |
|
| 41 | + __DIR__.'/../config/translator.php' => config_path('translator.php'), |
|
| 42 | 42 | ], |
| 43 | 43 | 'config' |
| 44 | 44 | ); |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | * @param $locale |
| 50 | 50 | */ |
| 51 | 51 | function __construct($locale){ |
| 52 | - $this->locale = $locale; |
|
| 52 | + $this->locale = $locale; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * |
| 49 | 49 | * @param $locale |
| 50 | 50 | */ |
| 51 | - function __construct($locale){ |
|
| 51 | + function __construct($locale) { |
|
| 52 | 52 | $this->locale = $locale; |
| 53 | 53 | } |
| 54 | 54 | |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return string |
| 59 | 59 | */ |
| 60 | - function getLocale(){ |
|
| 60 | + function getLocale() { |
|
| 61 | 61 | return $this->locale; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param string $group |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - function getTranslation($identifier, $group){ |
|
| 71 | + function getTranslation($identifier, $group) { |
|
| 72 | 72 | return $identifier; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @return bool |
| 79 | 79 | */ |
| 80 | - function refreshCache(){ |
|
| 80 | + function refreshCache() { |
|
| 81 | 81 | return true; |
| 82 | 82 | } |
| 83 | 83 | |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string $group |
| 88 | 88 | * @return array |
| 89 | 89 | */ |
| 90 | - function getAllTranslations($group){ |
|
| 90 | + function getAllTranslations($group) { |
|
| 91 | 91 | return []; |
| 92 | 92 | } |
| 93 | 93 | |
@@ -61,7 +61,7 @@ |
||
| 61 | 61 | $locale_dir = TranslatorFacade::getConfigValue('cache_path').$this->locale; |
| 62 | 62 | |
| 63 | 63 | try { |
| 64 | - $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
|
| 64 | + $trans_identifier = json_decode(file_get_contents($locale_dir.'/'.$group.'.json'), true); |
|
| 65 | 65 | } catch (\ErrorException $e) { |
| 66 | 66 | throw new TranslationCacheNotFound("The Translation cache file '".$locale_dir.'/'.$group.'.json'."' could not be found!"); |
| 67 | 67 | } |
@@ -44,8 +44,7 @@ |
||
| 44 | 44 | // the same identifier will not be found twice in the cache, which will result in a duplicate key sql error. |
| 45 | 45 | if (isset($this->translations[$group][$identifier])) { |
| 46 | 46 | return $this->translations[$group][$identifier]; |
| 47 | - } |
|
| 48 | - else { |
|
| 47 | + } else { |
|
| 49 | 48 | throw new TranslationNotInCacheException("The translation identifier '".$identifier."' could not be found in Cache"); |
| 50 | 49 | } |
| 51 | 50 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | public function refreshCache() |
| 59 | 59 | { |
| 60 | 60 | $translations = new TranslationIdentifier(); |
| 61 | - $translations = $translations->leftJoin('translations', function ($join) |
|
| 61 | + $translations = $translations->leftJoin('translations', function($join) |
|
| 62 | 62 | { |
| 63 | - $join->on( 'translation_identifiers.id', '=', 'translations.translation_identifier_id') |
|
| 63 | + $join->on('translation_identifiers.id', '=', 'translations.translation_identifier_id') |
|
| 64 | 64 | ->where('locale', $this->locale); |
| 65 | 65 | } |
| 66 | 66 | )->get(); |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | function getDatabaseID($identifier) |
| 100 | 100 | { |
| 101 | - if(isset($this->translations[$identifier])) { |
|
| 101 | + if (isset($this->translations[$identifier])) { |
|
| 102 | 102 | return $this->translations[$identifier]->id; |
| 103 | 103 | } else { |
| 104 | 104 | throw new NotFoundResourceException("The translation identifier '".$identifier."' could not be found"); |
@@ -131,12 +131,12 @@ |
||
| 131 | 131 | return $translation; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - /** |
|
| 135 | - * Sets the Handler |
|
| 136 | - * |
|
| 137 | - * @param $locale |
|
| 138 | - * @return DefaultHandler |
|
| 139 | - */ |
|
| 134 | + /** |
|
| 135 | + * Sets the Handler |
|
| 136 | + * |
|
| 137 | + * @param $locale |
|
| 138 | + * @return DefaultHandler |
|
| 139 | + */ |
|
| 140 | 140 | protected function createHandler($locale) |
| 141 | 141 | { |
| 142 | 142 | $handler_class = $this->config['handler']; |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | |
| 189 | 189 | $keys = []; |
| 190 | 190 | if (is_array($parameters)) { |
| 191 | - foreach($parameters as $key => $value) { |
|
| 191 | + foreach ($parameters as $key => $value) { |
|
| 192 | 192 | $keys[] = $key; |
| 193 | 193 | } |
| 194 | 194 | } |
@@ -304,12 +304,12 @@ discard block |
||
| 304 | 304 | $found_locales = []; |
| 305 | 305 | |
| 306 | 306 | foreach ($avail_locales as $avail_locale) { |
| 307 | - if (strpos($avail_locale, $locale) !== false){ |
|
| 307 | + if (strpos($avail_locale, $locale) !== false) { |
|
| 308 | 308 | $found_locales[] = $avail_locale; |
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if (in_array($default_locale, $found_locales) || count($found_locales) == 0){ |
|
| 312 | + if (in_array($default_locale, $found_locales) || count($found_locales) == 0) { |
|
| 313 | 313 | $message = 'Locale "'.$locale.'" was not found! Falling back to default locale "'.$default_locale.'"'; |
| 314 | 314 | $locale = $default_locale; |
| 315 | 315 | |
@@ -318,7 +318,9 @@ |
||
| 318 | 318 | $locale = $found_locales[0]; |
| 319 | 319 | } |
| 320 | 320 | |
| 321 | - if ($message !== '') $this->log($message, 'warning'); |
|
| 321 | + if ($message !== '') { |
|
| 322 | + $this->log($message, 'warning'); |
|
| 323 | + } |
|
| 322 | 324 | |
| 323 | 325 | return $locale; |
| 324 | 326 | } |
@@ -7,11 +7,11 @@ |
||
| 7 | 7 | * @license http://opensource.org/licenses/MIT MIT |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | -if (! Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
| 11 | - Route::group(['prefix' => 'translator'], function () { |
|
| 10 | +if (!Hokan22\LaravelTranslator\TranslatorFacade::getConfigValue('custom_routes')) { |
|
| 11 | + Route::group(['prefix' => 'translator'], function() { |
|
| 12 | 12 | Route::get('/test', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@test')->name('translator.test'); |
| 13 | 13 | |
| 14 | - Route::group(['prefix' => 'admin'], function () { |
|
| 14 | + Route::group(['prefix' => 'admin'], function() { |
|
| 15 | 15 | Route::get('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@index')->name('translator.admin'); |
| 16 | 16 | Route::post('/', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@postIdentifier')->name('translator.post.admin'); |
| 17 | 17 | Route::get('/{id}', 'Hokan22\LaravelTranslator\Controllers\TranslatorAdminController@edit')->where('id', '[0-9]+')->name('translator.admin.edit'); |