Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip i18n #4

Merged
merged 6 commits into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 20 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Http/Middleware/TrongateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
Expand Down
7 changes: 6 additions & 1 deletion src/TrongateServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
}
7 changes: 7 additions & 0 deletions src/lang/da/translation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'title' => 'Du har begået en kæmpe fejl ved at bruge Laravel.',
'subtitle' => 'Brug Trongate!',
'message' => 'Du vil blive omdirigeret om :countdown sekund(er)',
];
7 changes: 7 additions & 0 deletions src/lang/dc/translation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'title' => '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',
];
7 changes: 7 additions & 0 deletions src/lang/en/translation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'title' => 'You\'ve made a huge mistake for using Laravel.',
'subtitle' => 'Use Trongate!',
'message' => 'You will be redirected in :countdown second(s)',
];
7 changes: 7 additions & 0 deletions src/lang/nl/translation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

return [
'title' => 'Je hebt een hele grote fout gemaakt bij het gebruik van Laravel',
'subtitle' => 'Gebruik Trongate!',
'message' => 'Je wordt doorgestuurd over :countdown seconde(n)',
];
11 changes: 3 additions & 8 deletions src/resources/views/trongate.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@
<title>Trongate > Laravel</title>
</head>
<body style="text-align: center;">
<h1>You've made a <u>huge</u> mistake for using Laravel.</h1>
<h2>Use Trongate!</h2>

<h1>{{ __('trongate::translation.title') }}</h1>
<h2>{{ __('trongate::translation.subtitle') }}</h2>
<p>
You will be redirected in
<span _="on load set $timer to {{ config('trongate.countdown') }} repeat {{ config('trongate.countdown') }} times decrement $timer then put it into my innerHTML wait 1s end then go to url 'https://trongate.io'">
{{ config('trongate.countdown') }}
</span>
seconds.
{!! __('trongate::translation.message', ['countdown' => '<span _="on load set $timer to '.config('trongate.countdown').' repeat '.config('trongate.countdown').' times decrement $timer then put it into my innerHTML wait 1s end then go to url \'https://trongate.io\'">'.config('trongate.countdown').'</span>']) !!}
</p>
</body>
</html>