diff --git a/README.md b/README.md index f6aedd1..4a6a2eb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ ![banner](https://banners.beyondco.de/Laravel%20Trongate.png?theme=dark&packageManager=composer+require&packageName=shitware-ltd%2Flaravel-trongate&pattern=architect&style=style_1&description=A+Trongate+adapter+for+Laravel.&md=1&showWatermark=0&fontSize=100px&images=https%3A%2F%2Flaravel.com%2Fimg%2Flogomark.min.svg) +## Installation + +```bash +composer require shitware-ltd/laravel-trongate +``` + ## Supported Laravel versions We believe in backwards compatability just as much as Trongate, below are the supported Laravel versions. @@ -8,22 +14,29 @@ We believe in backwards compatability just as much as Trongate, below are the su - 8.x - 9.x -## Installation +## i18n -```bash -composer require shitware-ltd/laravel-trongate -``` +Supported languages: -## Configuration +- `en` +- `da` +- `nl` +- `dc` -We understand that the default countdown of `5` seconds before redirect might not suit your needs. +## Configuration -To fix this, publish the configuration file and modify just to your needs! +To publish the configuration for the countdown, use the following command: ```bash php artisan vendor:publish --provider="ShitwareLtd\LaravelTrongate\TrongateServiceProvider" --tag="config" ``` +To publish translation files, use the following command: + +```bash +php artisan vendor:publish --provider="ShitwareLtd\LaravelTrongate\TrongateServiceProvider" --tag="lang" +``` + ## License MIT diff --git a/src/Http/Middleware/TrongateMiddleware.php b/src/Http/Middleware/TrongateMiddleware.php index 16da673..02ce602 100644 --- a/src/Http/Middleware/TrongateMiddleware.php +++ b/src/Http/Middleware/TrongateMiddleware.php @@ -10,8 +10,8 @@ public function handle(Request $request) { if ($request->wantsJson()) { return response()->json([ - 'title' => "You've made a huge mistake for using Laravel.", - 'subtitle' => 'Use Trongate!', + 'title' => __('trongate::translation.title'), + 'subtitle' => __('trongate::translation.subtitle'), 'meta' => [ 'homepage' => 'https://trongate.io' ] diff --git a/src/TrongateServiceProvider.php b/src/TrongateServiceProvider.php index 49bdede..f5c574b 100644 --- a/src/TrongateServiceProvider.php +++ b/src/TrongateServiceProvider.php @@ -16,12 +16,17 @@ public function register() public function boot(Kernel $kernel) { $this->loadViewsFrom(__DIR__.'/resources/views', 'trongate'); + $this->loadTranslationsFrom(__DIR__.'/lang/', 'trongate'); $kernel->pushMiddleware(TrongateMiddleware::class); if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/config/trongate.php' => config_path('trongate.php'), - ], 'config'); + ]); + + $this->publishes([ + __DIR__.'/lang' => lang_path('vendor/trongate'), + ], 'lang'); } } } diff --git a/src/lang/da/translation.php b/src/lang/da/translation.php new file mode 100644 index 0000000..2ba8866 --- /dev/null +++ b/src/lang/da/translation.php @@ -0,0 +1,7 @@ + 'Du har begået en kæmpe fejl ved at bruge Laravel.', + 'subtitle' => 'Brug Trongate!', + 'message' => 'Du vil blive omdirigeret om :countdown sekund(er)', +]; diff --git a/src/lang/dc/translation.php b/src/lang/dc/translation.php new file mode 100644 index 0000000..9551a06 --- /dev/null +++ b/src/lang/dc/translation.php @@ -0,0 +1,7 @@ + 'Why you using Larabloat you fuckin school leaver?', + 'subtitle' => 'Join the revolution! Use Trongate!', + 'message' => 'I\'ll come to your house in :countdown n\' bash ye fookin head in', +]; diff --git a/src/lang/en/translation.php b/src/lang/en/translation.php new file mode 100644 index 0000000..394cabf --- /dev/null +++ b/src/lang/en/translation.php @@ -0,0 +1,7 @@ + 'You\'ve made a huge mistake for using Laravel.', + 'subtitle' => 'Use Trongate!', + 'message' => 'You will be redirected in :countdown second(s)', +]; diff --git a/src/lang/nl/translation.php b/src/lang/nl/translation.php new file mode 100644 index 0000000..950c90a --- /dev/null +++ b/src/lang/nl/translation.php @@ -0,0 +1,7 @@ + 'Je hebt een hele grote fout gemaakt bij het gebruik van Laravel', + 'subtitle' => 'Gebruik Trongate!', + 'message' => 'Je wordt doorgestuurd over :countdown seconde(n)', +]; diff --git a/src/resources/views/trongate.blade.php b/src/resources/views/trongate.blade.php index db3649e..c345622 100644 --- a/src/resources/views/trongate.blade.php +++ b/src/resources/views/trongate.blade.php @@ -6,15 +6,10 @@ Trongate > Laravel -

You've made a huge mistake for using Laravel.

-

Use Trongate!

- +

{{ __('trongate::translation.title') }}

+

{{ __('trongate::translation.subtitle') }}

- You will be redirected in - - {{ config('trongate.countdown') }} - - seconds. + {!! __('trongate::translation.message', ['countdown' => ''.config('trongate.countdown').'']) !!}