From 90cfd9aeb3c3e5026b9abcfd1451c49a14a340d9 Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 23:26:55 +0200 Subject: [PATCH 1/5] wip i18n --- src/Http/Middleware/TrongateMiddleware.php | 4 ++-- src/TrongateServiceProvider.php | 4 +++- src/lang/da/translation.php | 7 +++++++ src/lang/en/translation.php | 7 +++++++ src/resources/views/trongate.blade.php | 11 +++-------- 5 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 src/lang/da/translation.php create mode 100644 src/lang/en/translation.php 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..654ff09 100644 --- a/src/TrongateServiceProvider.php +++ b/src/TrongateServiceProvider.php @@ -16,12 +16,14 @@ 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'); + __DIR__.'/lang' => lang_path('vendor/trongate'), + ]); } } } 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/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/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').'']) !!}

From 87841bff2374c994096b85693c124bbe60379aa7 Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 23:33:23 +0200 Subject: [PATCH 2/5] godverdomme --- src/lang/nl/translation.php | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/lang/nl/translation.php 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)', +]; From 1a7b0782b2bf2d7b659e941d9ff70f8553710ff0 Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 23:56:54 +0200 Subject: [PATCH 3/5] move lang and config --- src/TrongateServiceProvider.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TrongateServiceProvider.php b/src/TrongateServiceProvider.php index 654ff09..f5c574b 100644 --- a/src/TrongateServiceProvider.php +++ b/src/TrongateServiceProvider.php @@ -22,8 +22,11 @@ public function boot(Kernel $kernel) if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/config/trongate.php' => config_path('trongate.php'), - __DIR__.'/lang' => lang_path('vendor/trongate'), ]); + + $this->publishes([ + __DIR__.'/lang' => lang_path('vendor/trongate'), + ], 'lang'); } } } From 74d82e7cf4facce9d3e49d0e6050632007914c7d Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 23:57:02 +0200 Subject: [PATCH 4/5] update readme --- README.md | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0ffdb36..0d25e76 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,28 @@ 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` -We understand that the default countdown of `5` seconds and `1` second delay 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 From 58088e200d8eff35c26702d9e8085b8366d32708 Mon Sep 17 00:00:00 2001 From: Mathias Jorgensen Date: Tue, 4 Oct 2022 23:58:43 +0200 Subject: [PATCH 5/5] add i18n for dc --- README.md | 1 + src/lang/dc/translation.php | 7 +++++++ 2 files changed, 8 insertions(+) create mode 100644 src/lang/dc/translation.php diff --git a/README.md b/README.md index 0d25e76..4a6a2eb 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ Supported languages: - `en` - `da` - `nl` +- `dc` ## Configuration 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', +];