@@ -34,8 +34,7 @@ |
||
| 34 | 34 | * |
| 35 | 35 | * @return string |
| 36 | 36 | */ |
| 37 | - protected static function getFacadeAccessor() |
|
| 38 | - { |
|
| 37 | + protected static function getFacadeAccessor() { |
|
| 39 | 38 | return 'Translator'; |
| 40 | 39 | } |
| 41 | 40 | } |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | * @param string $locale The locale of the translations |
| 23 | 23 | * @throws TranslationCacheNotFound |
| 24 | 24 | */ |
| 25 | - public function __construct($locale) |
|
| 26 | - { |
|
| 25 | + public function __construct($locale) { |
|
| 27 | 26 | parent::__construct($locale); |
| 28 | 27 | |
| 29 | 28 | $this->refreshCache(); |
@@ -37,15 +36,13 @@ discard block |
||
| 37 | 36 | * @throws TranslationNotInCacheException |
| 38 | 37 | * @return string returns the found translation for locale and identifier |
| 39 | 38 | */ |
| 40 | - public function getTranslation($identifier, $group = 'default') |
|
| 41 | - { |
|
| 39 | + public function getTranslation($identifier, $group = 'default') { |
|
| 42 | 40 | // NOTE: This should never trigger the addition of the identifier to the database! |
| 43 | 41 | // Because the cache will not be updated automatically. |
| 44 | 42 | // the same identifier will not be found twice in the cache, which will result in a duplicate key sql error. |
| 45 | 43 | if (isset($this->translations[$group][$identifier])) { |
| 46 | 44 | return $this->translations[$group][$identifier]; |
| 47 | - } |
|
| 48 | - else { |
|
| 45 | + } else { |
|
| 49 | 46 | throw new TranslationNotInCacheException("The translation identifier '".$identifier."' could not be found in Cache"); |
| 50 | 47 | } |
| 51 | 48 | } |
@@ -56,8 +53,7 @@ discard block |
||
| 56 | 53 | * @param string $group |
| 57 | 54 | * @throws TranslationCacheNotFound |
| 58 | 55 | */ |
| 59 | - public function refreshCache($group = 'default') |
|
| 60 | - { |
|
| 56 | + public function refreshCache($group = 'default') { |
|
| 61 | 57 | $locale_dir = TranslatorFacade::getConfigValue('cache_path').$this->locale; |
| 62 | 58 | |
| 63 | 59 | try { |
@@ -75,8 +71,7 @@ discard block |
||
| 75 | 71 | * @param string $group Group of the translations to return |
| 76 | 72 | * @return array|mixed Translations of the given group |
| 77 | 73 | */ |
| 78 | - public function getAllTranslations($group) |
|
| 79 | - { |
|
| 74 | + public function getAllTranslations($group) { |
|
| 80 | 75 | return $this->translations[$group]; |
| 81 | 76 | } |
| 82 | 77 | } |
| 83 | 78 | \ No newline at end of file |
@@ -60,8 +60,7 @@ |
||
| 60 | 60 | * |
| 61 | 61 | * @return \Illuminate\Database\Eloquent\Relations\BelongsTo |
| 62 | 62 | */ |
| 63 | - public function translationIdentifier() |
|
| 64 | - { |
|
| 63 | + public function translationIdentifier() { |
|
| 65 | 64 | return $this->belongsTo(TranslationIdentifier::class); |
| 66 | 65 | } |
| 67 | 66 | } |
| 68 | 67 | \ No newline at end of file |
@@ -62,8 +62,7 @@ |
||
| 62 | 62 | * |
| 63 | 63 | * @return \Illuminate\Database\Eloquent\Relations\HasMany |
| 64 | 64 | */ |
| 65 | - public function translations() |
|
| 66 | - { |
|
| 65 | + public function translations() { |
|
| 67 | 66 | return $this->hasMany(Translations::class); |
| 68 | 67 | } |
| 69 | 68 | |
@@ -45,8 +45,7 @@ discard block |
||
| 45 | 45 | /** |
| 46 | 46 | * Create a new command instance. |
| 47 | 47 | */ |
| 48 | - public function __construct() |
|
| 49 | - { |
|
| 48 | + public function __construct() { |
|
| 50 | 49 | parent::__construct(); |
| 51 | 50 | } |
| 52 | 51 | |
@@ -56,8 +55,7 @@ discard block |
||
| 56 | 55 | * @return mixed |
| 57 | 56 | * @throws \Exception |
| 58 | 57 | */ |
| 59 | - public function handle() |
|
| 60 | - { |
|
| 58 | + public function handle() { |
|
| 61 | 59 | $start = microtime(true); |
| 62 | 60 | |
| 63 | 61 | $this->line(''); |
@@ -132,8 +130,7 @@ discard block |
||
| 132 | 130 | * @param array $result Array with |
| 133 | 131 | * @param string $group |
| 134 | 132 | */ |
| 135 | - protected function addMissing($result, $group) |
|
| 136 | - { |
|
| 133 | + protected function addMissing($result, $group) { |
|
| 137 | 134 | foreach ($result as $item) { |
| 138 | 135 | try { |
| 139 | 136 | $identifier = trim($item['identifier']); |
@@ -177,7 +174,7 @@ discard block |
||
| 177 | 174 | $this->dupl_identifier++; |
| 178 | 175 | } |
| 179 | 176 | |
| 180 | - } catch(\Exception $e){ |
|
| 177 | + } catch(\Exception $e) { |
|
| 181 | 178 | $this->bar->clear(); |
| 182 | 179 | $this->info($identifier.' '.strlen($identifier)); |
| 183 | 180 | $this->info($e->getMessage()); |
@@ -39,8 +39,7 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * Create a new command instance. |
| 41 | 41 | */ |
| 42 | - public function __construct() |
|
| 43 | - { |
|
| 42 | + public function __construct() { |
|
| 44 | 43 | parent::__construct(); |
| 45 | 44 | } |
| 46 | 45 | |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | * |
| 50 | 49 | * @throws \Exception |
| 51 | 50 | */ |
| 52 | - public function handle() |
|
| 53 | - { |
|
| 51 | + public function handle() { |
|
| 54 | 52 | $locale = $this->argument('locale'); |
| 55 | 53 | |
| 56 | 54 | if (!is_string($locale)) |
@@ -99,8 +97,7 @@ discard block |
||
| 99 | 97 | * |
| 100 | 98 | * @return array |
| 101 | 99 | */ |
| 102 | - protected function getGroups() |
|
| 103 | - { |
|
| 100 | + protected function getGroups() { |
|
| 104 | 101 | return DB::table('translation_identifiers')->select('group')->groupBy(['group'])->get()->pluck('group'); |
| 105 | 102 | } |
| 106 | 103 | |
@@ -110,12 +107,10 @@ discard block |
||
| 110 | 107 | * @param string $locale The locale from which the translations to load |
| 111 | 108 | * @return TranslationIdentifier|\Illuminate\Database\Eloquent\Collection|static[] |
| 112 | 109 | */ |
| 113 | - protected function loadFromDB($locale) |
|
| 114 | - { |
|
| 110 | + protected function loadFromDB($locale) { |
|
| 115 | 111 | $trans_identifier = new TranslationIdentifier(); |
| 116 | 112 | |
| 117 | - $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) |
|
| 118 | - { |
|
| 113 | + $trans_identifier = $trans_identifier->with('translations')->whereHas('translations', function ($item) use ($locale) { |
|
| 119 | 114 | return $item->where('locale', $locale); |
| 120 | 115 | } |
| 121 | 116 | )->orWhereHas('translations', null, '<=', 0) |
@@ -21,13 +21,11 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @return void |
| 23 | 23 | */ |
| 24 | - public function up() |
|
| 25 | - { |
|
| 24 | + public function up() { |
|
| 26 | 25 | DB::beginTransaction(); |
| 27 | 26 | |
| 28 | 27 | // Create table for storing roles |
| 29 | - Schema::create('translation_identifiers', function (Blueprint $table) |
|
| 30 | - { |
|
| 28 | + Schema::create('translation_identifiers', function (Blueprint $table) { |
|
| 31 | 29 | $table->increments('id')->unique(); |
| 32 | 30 | $table->text('identifier'); |
| 33 | 31 | |
@@ -41,8 +39,7 @@ discard block |
||
| 41 | 39 | }); |
| 42 | 40 | |
| 43 | 41 | // Create table for storing roles |
| 44 | - Schema::create('translations', function (Blueprint $table) |
|
| 45 | - { |
|
| 42 | + Schema::create('translations', function (Blueprint $table) { |
|
| 46 | 43 | $table->integer('translation_identifier_id')->unsigned(); |
| 47 | 44 | $table->foreign('translation_identifier_id')->references('id')->on('translation_identifiers')->onDelete('no action')->onUpdate('no action'); |
| 48 | 45 | |
@@ -64,8 +61,7 @@ discard block |
||
| 64 | 61 | * |
| 65 | 62 | * @return void |
| 66 | 63 | */ |
| 67 | - public function down() |
|
| 68 | - { |
|
| 64 | + public function down() { |
|
| 69 | 65 | Schema::drop('translations'); |
| 70 | 66 | Schema::drop('translation_identifiers'); |
| 71 | 67 | } |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Register any application services. |
| 24 | 24 | */ |
| 25 | - public function register() |
|
| 26 | - { |
|
| 25 | + public function register() { |
|
| 27 | 26 | $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
| 28 | 27 | |
| 29 | 28 | $this->app->singleton('Translator', function () { |
@@ -35,8 +34,7 @@ discard block |
||
| 35 | 34 | /** |
| 36 | 35 | * Bootstrap any application services. |
| 37 | 36 | */ |
| 38 | - public function boot() |
|
| 39 | - { |
|
| 37 | + public function boot() { |
|
| 40 | 38 | $this->publishes([ |
| 41 | 39 | __DIR__ . '/../config/translator.php' => config_path('translator.php'), |
| 42 | 40 | ], |
@@ -22,8 +22,7 @@ discard block |
||
| 22 | 22 | /** |
| 23 | 23 | * Bootstrap any application services. |
| 24 | 24 | */ |
| 25 | - public function boot() |
|
| 26 | - { |
|
| 25 | + public function boot() { |
|
| 27 | 26 | Blade::directive('translate', function ($expression) { |
| 28 | 27 | |
| 29 | 28 | $expression = $this->stripParentheses($expression); |
@@ -49,8 +48,7 @@ discard block |
||
| 49 | 48 | * @param string $expression |
| 50 | 49 | * @return string |
| 51 | 50 | */ |
| 52 | - public function stripParentheses($expression) |
|
| 53 | - { |
|
| 51 | + public function stripParentheses($expression) { |
|
| 54 | 52 | if (Str::startsWith($expression, '(')) { |
| 55 | 53 | $expression = substr($expression, 1, -1); |
| 56 | 54 | } |