@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | try { |
192 | 192 | return app()->getLocale(); |
193 | 193 | } catch (Exception $e) { |
194 | - if($this->request->request->has('locale')){ |
|
194 | + if ($this->request->request->has('locale')) { |
|
195 | 195 | return strtolower($this->request->input('locale')); |
196 | 196 | } |
197 | 197 | if ($this->request->hasHeader('locale')) { |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | if ($this->request->hasSession() and $this->request->session()->has('locale')) { |
204 | 204 | return $this->request->session()->get('locale'); |
205 | 205 | } |
206 | - if ($locale = substr($this->request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2) and in_array($locale, config('translation.locales'))){ |
|
206 | + if ($locale = substr($this->request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2) and in_array($locale, config('translation.locales'))) { |
|
207 | 207 | return $locale; |
208 | 208 | } |
209 | 209 | return $this->getConfigDefaultLocale(); |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | * Detects the Default Locale Based on |
658 | 658 | */ |
659 | 659 | |
660 | - public function detectLocale($request){ |
|
660 | + public function detectLocale($request) { |
|
661 | 661 | if (!$request->hasCookie('locale')) { |
662 | 662 | $locale = substr($request->server('HTTP_ACCEPT_LANGUAGE'), 0, 2); |
663 | 663 |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | private function unsignedRightShift($a, $b) |
113 | 113 | { |
114 | 114 | if ($b >= 32 || $b < -32) { |
115 | - $m = (int)($b / 32); |
|
115 | + $m = (int) ($b / 32); |
|
116 | 116 | $b = $b - ($m * 32); |
117 | 117 | } |
118 | 118 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function JS_charCodeAt($str, $index) { |
148 | 148 | $utf16 = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8'); |
149 | - return ord($utf16[$index*2]) + (ord($utf16[$index*2+1]) << 8); |
|
149 | + return ord($utf16[$index * 2]) + (ord($utf16[$index * 2 + 1]) << 8); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -158,6 +158,6 @@ discard block |
||
158 | 158 | */ |
159 | 159 | private function JS_length($str) { |
160 | 160 | $utf16 = mb_convert_encoding($str, 'UTF-16LE', 'UTF-8'); |
161 | - return strlen($utf16)/2; |
|
161 | + return strlen($utf16) / 2; |
|
162 | 162 | } |
163 | 163 | } |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | 'client' => 'webapp', |
57 | 57 | 'hl' => 'en', |
58 | 58 | 'dt' => [ |
59 | - 't', // Translate |
|
60 | - 'bd', // Full translate with synonym ($bodyArray[1]) |
|
61 | - 'at', // Other translate ($bodyArray[5] - in google translate page this shows when click on translated word) |
|
62 | - 'ex', // Example part ($bodyArray[13]) |
|
63 | - 'ld', // I don't know ($bodyArray[8]) |
|
64 | - 'md', // Definition part with example ($bodyArray[12]) |
|
59 | + 't', // Translate |
|
60 | + 'bd', // Full translate with synonym ($bodyArray[1]) |
|
61 | + 'at', // Other translate ($bodyArray[5] - in google translate page this shows when click on translated word) |
|
62 | + 'ex', // Example part ($bodyArray[13]) |
|
63 | + 'ld', // I don't know ($bodyArray[8]) |
|
64 | + 'md', // Definition part with example ($bodyArray[12]) |
|
65 | 65 | 'qca', // I don't know ($bodyArray[8]) |
66 | - 'rw', // Read also part ($bodyArray[14]) |
|
67 | - 'rm', // I don't know |
|
66 | + 'rw', // Read also part ($bodyArray[14]) |
|
67 | + 'rm', // I don't know |
|
68 | 68 | 'ss' // Full synonym ($bodyArray[11]) |
69 | 69 | ], |
70 | 70 | 'sl' => null, // Source language |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | return $responseArray; |
270 | 270 | } else { |
271 | 271 | if (is_array($responseArray[0])) { |
272 | - return (string) array_reduce($responseArray[0], function ($carry, $item) { |
|
272 | + return (string) array_reduce($responseArray[0], function($carry, $item) { |
|
273 | 273 | $carry .= $item[0]; |
274 | 274 | return $carry; |
275 | 275 | }); |
@@ -50,7 +50,7 @@ |
||
50 | 50 | if (!$this->translationCodeFor($attribute)) { |
51 | 51 | $reflected = new \ReflectionClass($this); |
52 | 52 | $group = 'translatable'; |
53 | - $item = strtolower($reflected->getShortName()) . '.' . strtolower($attribute) . '.' . Str::random(); |
|
53 | + $item = strtolower($reflected->getShortName()).'.'.strtolower($attribute).'.'.Str::random(); |
|
54 | 54 | $this->attributes["{$attribute}_translation"] = "$group.$item"; |
55 | 55 | } |
56 | 56 | } |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | ->whereGroup($group) |
238 | 238 | ->get() |
239 | 239 | ->keyBy('item') |
240 | - ->map(function ($translation) { |
|
240 | + ->map(function($translation) { |
|
241 | 241 | return $translation['text']; |
242 | 242 | }) |
243 | 243 | ->toArray(); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $elements = explode('.', $partialCode); |
282 | 282 | foreach ($elements as $element) { |
283 | 283 | if ($element) { |
284 | - $query = $query->where(function ($query) use ($element) { |
|
284 | + $query = $query->where(function($query) use ($element) { |
|
285 | 285 | $query->where('group', 'like', "%{$element}%")->orWhere('item', 'like', "%{$element}%")->orWhere('text', 'like', "%{$element}%"); |
286 | 286 | }); |
287 | 287 | } |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | |
362 | 362 | return $this->model |
363 | 363 | ->newQuery() |
364 | - ->select($table . '.text') |
|
364 | + ->select($table.'.text') |
|
365 | 365 | ->from($table) |
366 | - ->leftJoin("{$table} as e", function ($join) use ($table, $text, $textLocale) { |
|
366 | + ->leftJoin("{$table} as e", function($join) use ($table, $text, $textLocale) { |
|
367 | 367 | $join->on('e.namespace', '=', "{$table}.namespace") |
368 | 368 | ->on('e.group', '=', "{$table}.group") |
369 | 369 | ->on('e.item', '=', "{$table}.item"); |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | return $this->database->table("$table as $table") |
468 | 468 | ->select("$table.id") |
469 | - ->leftJoin("$table as e", function (JoinClause $query) use ($table, $locale) { |
|
469 | + ->leftJoin("$table as e", function(JoinClause $query) use ($table, $locale) { |
|
470 | 470 | $query->on('e.namespace', '=', "$table.namespace") |
471 | 471 | ->on('e.group', '=', "$table.group") |
472 | 472 | ->on('e.item', '=', "$table.item") |
@@ -106,8 +106,8 @@ discard block |
||
106 | 106 | // Load all files inside subdirectories: |
107 | 107 | $directories = $this->files->directories($path); |
108 | 108 | foreach ($directories as $directory) { |
109 | - $directoryName = str_replace($path . '/', '', $directory); |
|
110 | - $dirGroup = $group . basename($directory) . '/'; |
|
109 | + $directoryName = str_replace($path.'/', '', $directory); |
|
110 | + $dirGroup = $group.basename($directory).'/'; |
|
111 | 111 | $this->loadDirectory($directory, $locale, $namespace, $dirGroup); |
112 | 112 | } |
113 | 113 | |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | public function loadFile($file, $locale, $namespace = '*', $group = '') |
131 | 131 | { |
132 | - $group = $group . basename($file, '.php'); |
|
132 | + $group = $group.basename($file, '.php'); |
|
133 | 133 | $translations = $this->files->getRequire($file); |
134 | 134 | $this->translationRepository->loadArray($translations, $locale, $group, $namespace, $locale == $this->defaultLocale); |
135 | 135 | } |
@@ -109,7 +109,7 @@ |
||
109 | 109 | */ |
110 | 110 | protected function pathFromParsedUrl($parsedUrl) |
111 | 111 | { |
112 | - $path = '/' . implode('/', $parsedUrl['segments']); |
|
112 | + $path = '/'.implode('/', $parsedUrl['segments']); |
|
113 | 113 | if ($parsedUrl['query']) { |
114 | 114 | $path .= "?{$parsedUrl['query']}"; |
115 | 115 | } |
@@ -41,7 +41,7 @@ |
||
41 | 41 | |
42 | 42 | // Remove segments from group prefix that are equal to one of the available locales: |
43 | 43 | $groupSegments = explode('/', $this->router->getLastGroupPrefix()); |
44 | - $groupSegments = array_filter($groupSegments, function ($segment) use ($availableLocales) { |
|
44 | + $groupSegments = array_filter($groupSegments, function($segment) use ($availableLocales) { |
|
45 | 45 | return !in_array($segment, $availableLocales); |
46 | 46 | }); |
47 | 47 | $group = trim(implode('.', $groupSegments), '.'); |
@@ -40,15 +40,15 @@ discard block |
||
40 | 40 | public function boot() |
41 | 41 | { |
42 | 42 | $this->publishes([ |
43 | - __DIR__ . '/../config/translator.php' => config_path('translator.php'), |
|
44 | - __DIR__ . '/../config/translation.php' => config_path('translation.php'), |
|
43 | + __DIR__.'/../config/translator.php' => config_path('translator.php'), |
|
44 | + __DIR__.'/../config/translation.php' => config_path('translation.php'), |
|
45 | 45 | ]); |
46 | - $this->loadMigrationsFrom(__DIR__ . '/../database/migrations/'); |
|
46 | + $this->loadMigrationsFrom(__DIR__.'/../database/migrations/'); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Provider Antigo |
50 | 50 | */ |
51 | - Blade::directive('t', function ($args) { |
|
51 | + Blade::directive('t', function($args) { |
|
52 | 52 | return "<?php echo App::make('translation')->translate{$args}; ?>"; |
53 | 53 | }); |
54 | 54 | } |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function register() |
62 | 62 | { |
63 | - $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator'); |
|
64 | - $this->mergeConfigFrom(__DIR__ . '/../config/translation.php', 'translation'); |
|
63 | + $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator'); |
|
64 | + $this->mergeConfigFrom(__DIR__.'/../config/translation.php', 'translation'); |
|
65 | 65 | |
66 | 66 | parent::register(); |
67 | 67 | $this->registerCacheRepository(); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $this->app->bind(ClientInterface::class, Client::class); |
77 | 77 | |
78 | 78 | // Bind translation to the IoC. |
79 | - $this->app->bind('translation', function (Application $app) { |
|
79 | + $this->app->bind('translation', function(Application $app) { |
|
80 | 80 | return new Translation($app); |
81 | 81 | }); |
82 | 82 | |
@@ -105,20 +105,20 @@ discard block |
||
105 | 105 | protected function registerLoader() |
106 | 106 | { |
107 | 107 | $app = $this->app; |
108 | - $this->app->singleton('translation.loader', function ($app) { |
|
108 | + $this->app->singleton('translation.loader', function($app) { |
|
109 | 109 | $defaultLocale = $app['config']->get('app.locale'); |
110 | 110 | $loader = null; |
111 | 111 | $source = $app['config']->get('translator.source'); |
112 | 112 | |
113 | 113 | switch ($source) { |
114 | 114 | case 'mixed': |
115 | - $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath() . '/resources/lang'); |
|
115 | + $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath().'/resources/lang'); |
|
116 | 116 | $fileLoader = new FileLoader($defaultLocale, $laravelFileLoader); |
117 | 117 | $databaseLoader = new DatabaseLoader($defaultLocale, $app->make(TranslationRepository::class)); |
118 | 118 | $loader = new MixedLoader($defaultLocale, $fileLoader, $databaseLoader); |
119 | 119 | break; |
120 | 120 | case 'mixed_db': |
121 | - $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath() . '/resources/lang'); |
|
121 | + $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath().'/resources/lang'); |
|
122 | 122 | $fileLoader = new FileLoader($defaultLocale, $laravelFileLoader); |
123 | 123 | $databaseLoader = new DatabaseLoader($defaultLocale, $app->make(TranslationRepository::class)); |
124 | 124 | $loader = new MixedLoader($defaultLocale, $databaseLoader, $fileLoader); |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | $loader = new DatabaseLoader($defaultLocale, $app->make(TranslationRepository::class)); |
128 | 128 | break; |
129 | 129 | default:case 'files': |
130 | - $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath() . '/resources/lang'); |
|
130 | + $laravelFileLoader = new LaravelFileLoader($app['files'], $app->basePath().'/resources/lang'); |
|
131 | 131 | $loader = new FileLoader($defaultLocale, $laravelFileLoader); |
132 | 132 | break; |
133 | 133 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | public function registerCacheRepository() |
147 | 147 | { |
148 | - $this->app->singleton('translation.cache.repository', function ($app) { |
|
148 | + $this->app->singleton('translation.cache.repository', function($app) { |
|
149 | 149 | $cacheStore = $app['cache']->getStore(); |
150 | 150 | return CacheRepositoryFactory::make($cacheStore, $app['config']->get('translator.cache.suffix')); |
151 | 151 | }); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | $defaultLocale = $app['config']->get('app.locale'); |
163 | 163 | $languageRepository = $app->make(LanguageRepository::class); |
164 | 164 | $translationRepository = $app->make(TranslationRepository::class); |
165 | - $translationsPath = $app->basePath() . '/resources/lang'; |
|
165 | + $translationsPath = $app->basePath().'/resources/lang'; |
|
166 | 166 | $command = new FileLoaderCommand($languageRepository, $translationRepository, $app['files'], $translationsPath, $defaultLocale); |
167 | 167 | |
168 | 168 | $this->app['command.translator:load'] = $command; |