diff --git a/README.md b/README.md index faf1e99..af8ce43 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,11 @@ Export and import can also be used for the update of flox itself. Export your mo ### Translation -All movie titles are in english by default. You can change your language by setting `TRANSLATION` in `backend/.env`. The most commons are `DE`, `IT`, `FR`, `ES` and `RU`. You can try to use your language code. If there isn't a translation for your language, the english title will be used. +All movie titles are in english by default. You can change your language by setting `TRANSLATION` in `backend/.env`. The most commons are `DE`, `IT`, `FR`, `ES` and `RU`. You can try to use your language code. + +This will also affect the language of you website. See in `client/resources/languages` if your language is supported. Pull requests are welcome :) + +If there isn't a translation for your language, english will be used. ### Better Search diff --git a/backend/app/Http/Controllers/HomeController.php b/backend/app/Http/Controllers/HomeController.php new file mode 100644 index 0000000..4ac3feb --- /dev/null +++ b/backend/app/Http/Controllers/HomeController.php @@ -0,0 +1,16 @@ +parseLanguage(); + + return view('app') + ->withLang($language); + } + } \ No newline at end of file diff --git a/backend/app/Services/Storage.php b/backend/app/Services/Storage.php index 6f3a177..d997d7e 100644 --- a/backend/app/Services/Storage.php +++ b/backend/app/Services/Storage.php @@ -38,4 +38,22 @@ { LaravelStorage::delete($poster); } + + /** + * Parse language file. + * + * @return mixed + */ + public function parseLanguage() + { + $alternative = config('app.TRANSLATION') ?: 'EN'; + $filename = strtolower($alternative) . '.json'; + + // Get english fallback + if( ! LaravelStorage::disk('languages')->exists($filename)) { + $filename = 'en.json'; + } + + return LaravelStorage::disk('languages')->get($filename); + } } \ No newline at end of file diff --git a/backend/config/filesystems.php b/backend/config/filesystems.php index 0e8fe77..c102013 100644 --- a/backend/config/filesystems.php +++ b/backend/config/filesystems.php @@ -53,6 +53,11 @@ 'root' => base_path('../public/exports'), ], + 'languages' => [ + 'driver' => 'local', + 'root' => base_path('../client/resources/languages'), + ], + 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), diff --git a/backend/routes/web.php b/backend/routes/web.php index 41f4f1a..e555e89 100644 --- a/backend/routes/web.php +++ b/backend/routes/web.php @@ -30,6 +30,4 @@ }); }); - Route::get('/{uri?}', function($uri = null) { - return view('app'); - })->where('uri', '(.*)'); + Route::get('/{uri?}', 'HomeController@app')->where('uri', '(.*)'); diff --git a/client/app/components/Content/Content.vue b/client/app/components/Content/Content.vue index 855d05e..db98f23 100644 --- a/client/app/components/Content/Content.vue +++ b/client/app/components/Content/Content.vue @@ -7,10 +7,10 @@ :date="displayDate" > - No Movies Found + {{ lang('nothing found') }}