From 7a06097ae7bfe4bbbe6499da3d3de1d650669286 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 12:51:20 +0200 Subject: [PATCH 01/10] Adding app/Http/Middleware/Locale.php --- app/Http/Kernel.php | 1 + app/Http/Middleware/Locale.php | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 app/Http/Middleware/Locale.php diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 30020a5..3ebd56d 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -33,6 +33,7 @@ class Kernel extends HttpKernel \App\Http\Middleware\EncryptCookies::class, \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, \Illuminate\Session\Middleware\StartSession::class, + \App\Http\Middleware\Locale::class, // \Illuminate\Session\Middleware\AuthenticateSession::class, \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, diff --git a/app/Http/Middleware/Locale.php b/app/Http/Middleware/Locale.php new file mode 100644 index 0000000..56f23bd --- /dev/null +++ b/app/Http/Middleware/Locale.php @@ -0,0 +1,25 @@ +has('locale')) { + app()->setlocale(session()->get('locale')); + } + return $next($request); + } +} From e4fd735acb8de2f4b8a292719f3f2f8f5bb93a6c Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 13:05:54 +0200 Subject: [PATCH 02/10] Adding config/lang.php --- config/lang.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 config/lang.php diff --git a/config/lang.php b/config/lang.php new file mode 100644 index 0000000..c21196b --- /dev/null +++ b/config/lang.php @@ -0,0 +1,17 @@ + 'English', + 'se' => 'Svenska', + +]; From 4b56c803a59cd6ae79accb6f3d4275c5c866a84b Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 13:06:13 +0200 Subject: [PATCH 03/10] Adding app/Http/Controllers/LocaleSessionController.php --- .../Controllers/LocaleSessionController.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 app/Http/Controllers/LocaleSessionController.php diff --git a/app/Http/Controllers/LocaleSessionController.php b/app/Http/Controllers/LocaleSessionController.php new file mode 100644 index 0000000..ea782ad --- /dev/null +++ b/app/Http/Controllers/LocaleSessionController.php @@ -0,0 +1,19 @@ +session()->put('locale', $locale); + } + return redirect()->back(); + } +} From 64eef7cd60170a5c6c0eb4389b433e1c3cf856a4 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 13:06:34 +0200 Subject: [PATCH 04/10] routes/web.php: setup "set locale" route. --- routes/web.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routes/web.php b/routes/web.php index c6fd846..d931034 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use Illuminate\Support\Facades\Route; +use App\Http\Controllers\LocaleSessionController; use App\Http\Controllers\UserController; use App\Http\Controllers\ProfileController; use App\Http\Controllers\CharacterController; @@ -38,6 +39,8 @@ Route::name('auth.')->group(function () { // Public section // ---------------------------- +Route::get('/lang/{locale}', [LocaleSessionController::class, 'store'])->name('locale.store'); + Route::prefix('user')->name('user.')->group(function() { Route::get('{user}', [UserController::class, 'show'])->name('show'); }); From 40b9cabff19ee3909747670c0ef5cbde4bd4acb6 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 13:25:58 +0200 Subject: [PATCH 05/10] icons: adding se/en flags. --- resources/icons/flags/en.svg | 7 +++++++ resources/icons/flags/se.svg | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 resources/icons/flags/en.svg create mode 100644 resources/icons/flags/se.svg diff --git a/resources/icons/flags/en.svg b/resources/icons/flags/en.svg new file mode 100644 index 0000000..bd0384d --- /dev/null +++ b/resources/icons/flags/en.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/resources/icons/flags/se.svg b/resources/icons/flags/se.svg new file mode 100644 index 0000000..9495fb1 --- /dev/null +++ b/resources/icons/flags/se.svg @@ -0,0 +1,5 @@ + + + + + From f5252052ff9ccfab20803ff8b687f468af52115a Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 30 Jul 2021 13:26:35 +0200 Subject: [PATCH 06/10] resources/views/partials/navigation.blade.php: add language links. --- resources/views/partials/navigation.blade.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/resources/views/partials/navigation.blade.php b/resources/views/partials/navigation.blade.php index e6a0f70..fb26c44 100644 --- a/resources/views/partials/navigation.blade.php +++ b/resources/views/partials/navigation.blade.php @@ -26,6 +26,15 @@ @else {{ __('Login') }} @endauth + +
+ @foreach(config('lang') as $locale => $name) + + + + @endforeach +
+ From 531da903aee2e66fb1394388d48bb041207839e9 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 31 Jul 2021 14:00:06 +0200 Subject: [PATCH 07/10] views: add translations to some strings. --- resources/views/auth/login.blade.php | 6 +++--- resources/views/character/profession/create.blade.php | 5 ++++- resources/views/character/show.blade.php | 2 +- resources/views/components/character-card.blade.php | 4 ++-- resources/views/livewire/form/character.blade.php | 2 +- resources/views/livewire/recipes.blade.php | 10 +++++----- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/resources/views/auth/login.blade.php b/resources/views/auth/login.blade.php index b564e97..1a8e4c0 100644 --- a/resources/views/auth/login.blade.php +++ b/resources/views/auth/login.blade.php @@ -1,17 +1,17 @@ -

Login

+

{{ __('Login') }}

- + @if (config('services.discord.client_id'))
-
OR
+
{{ __('or') }}
diff --git a/resources/views/character/profession/create.blade.php b/resources/views/character/profession/create.blade.php index 4c56f66..cb1f3b8 100644 --- a/resources/views/character/profession/create.blade.php +++ b/resources/views/character/profession/create.blade.php @@ -10,7 +10,10 @@
-

Download this exporter addon +

+ {{ __('Download this') }} + {{ __('addon') }} +

diff --git a/resources/views/character/show.blade.php b/resources/views/character/show.blade.php index 3288582..8ff1596 100644 --- a/resources/views/character/show.blade.php +++ b/resources/views/character/show.blade.php @@ -30,7 +30,7 @@ -

Professions

+

{{ __('Professions') }}

@can('import_profession', $character) diff --git a/resources/views/components/character-card.blade.php b/resources/views/components/character-card.blade.php index 8552dcc..41cd186 100644 --- a/resources/views/components/character-card.blade.php +++ b/resources/views/components/character-card.blade.php @@ -25,8 +25,8 @@

- {{ Str::ucfirst($character->race) }} - {{ Str::ucfirst($character->class) }} + {{ __(Str::ucfirst($character->race)) }} + {{ __(Str::ucfirst($character->class)) }}

diff --git a/resources/views/livewire/form/character.blade.php b/resources/views/livewire/form/character.blade.php index b13968c..16b5f40 100644 --- a/resources/views/livewire/form/character.blade.php +++ b/resources/views/livewire/form/character.blade.php @@ -32,7 +32,7 @@
- +
diff --git a/resources/views/livewire/recipes.blade.php b/resources/views/livewire/recipes.blade.php index 4098923..dfe8782 100644 --- a/resources/views/livewire/recipes.blade.php +++ b/resources/views/livewire/recipes.blade.php @@ -1,8 +1,8 @@
- - + +
@@ -10,9 +10,9 @@ - - - + + + From fe7d275caf3eae5124caebe6761974eb0ac8e3af Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 31 Jul 2021 14:15:35 +0200 Subject: [PATCH 08/10] app/Http/Livewire/Recipes.php: translate the placeholder value in the profession option array. --- app/Http/Livewire/Recipes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Livewire/Recipes.php b/app/Http/Livewire/Recipes.php index 9cad6a7..62312e8 100644 --- a/app/Http/Livewire/Recipes.php +++ b/app/Http/Livewire/Recipes.php @@ -46,7 +46,7 @@ class Recipes extends Component return [Str::lower($item['name']) => $item['name']]; }); - $this->profession_options = collect(['' => '-- Profession --']) + $this->profession_options = collect(['' => '-- ' . __('Profession') . ' --']) ->merge($options) ->toArray(); } From bc544a79914bdb87bd561f02a8687e16e93d36d8 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 31 Jul 2021 14:16:11 +0200 Subject: [PATCH 09/10] resources/views/recipe/show.blade.php: rename heading from "Created item" to "Crafted item". --- resources/views/recipe/show.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/recipe/show.blade.php b/resources/views/recipe/show.blade.php index 49e36e7..9518937 100644 --- a/resources/views/recipe/show.blade.php +++ b/resources/views/recipe/show.blade.php @@ -12,7 +12,7 @@ @if ($recipe->craft)
-

{{ __('Created item') }}

+

{{ __('Crafted item') }}

@if ($recipe->craft->external_id) From 528178a3eed11522444ff5fd424bfaacac2d82c0 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sat, 31 Jul 2021 14:24:50 +0200 Subject: [PATCH 10/10] Adding Swedish language --- resources/lang/se.json | 39 ++++++++ resources/lang/se/auth.php | 20 ++++ resources/lang/se/pagination.php | 19 ++++ resources/lang/se/validation.php | 164 +++++++++++++++++++++++++++++++ 4 files changed, 242 insertions(+) create mode 100644 resources/lang/se.json create mode 100644 resources/lang/se/auth.php create mode 100644 resources/lang/se/pagination.php create mode 100644 resources/lang/se/validation.php diff --git a/resources/lang/se.json b/resources/lang/se.json new file mode 100644 index 0000000..0a36746 --- /dev/null +++ b/resources/lang/se.json @@ -0,0 +1,39 @@ +{ + "Add character": "Lägg till karaktär", + "Character": "Karaktär", + "Characters": "Karaktärer", + "Class": "Klass", + "Crafted item": "Tillverkat föremål", + "Crafter": "Hantverkare", + "Crafters": "Hantverkare", + "Create": "Skapa", + "Download this": "Ladda ner detta", + "Gender": "Kön", + "Import Profession": "Importera yrke", + "Import string": "Import sträng", + "Import": "Importera", + "Items": "Föremål", + "Login": "Logga in", + "Logout": "Logga ut", + "Name": "Namn", + "None": "Ingen", + "Only reagents": "Bara reagenser", + "Owner": "Ägare", + "Password": "Lösenord", + "Profession": "Yrke", + "Professions": "Yrken", + "Race": "Ras", + "Reagent for": "Reagens för", + "Reagents": "Reagenser", + "Recipe": "Recept", + "Recipes": "Recept", + "Roster": "Medlemmar", + "Save": "Spara", + "Showing": "Visar", + "User": "Användare", + "Username": "Användarnamn", + "of": "av", + "or": "eller", + "results": "resultat", + "to": "till" +} diff --git a/resources/lang/se/auth.php b/resources/lang/se/auth.php new file mode 100644 index 0000000..7b06b70 --- /dev/null +++ b/resources/lang/se/auth.php @@ -0,0 +1,20 @@ + 'Dessa uppgifter stämmer inte överens med vårt register.', + 'password' => 'Lösenordet var inte korrekt', + 'throttle' => 'För många inloggningsförsök. Var vänlig försök igen om :seconds sekunder.', + +]; diff --git a/resources/lang/se/pagination.php b/resources/lang/se/pagination.php new file mode 100644 index 0000000..f48366d --- /dev/null +++ b/resources/lang/se/pagination.php @@ -0,0 +1,19 @@ + '« Föregående', + 'next' => 'Nästa »', + +]; diff --git a/resources/lang/se/validation.php b/resources/lang/se/validation.php new file mode 100644 index 0000000..e43ac83 --- /dev/null +++ b/resources/lang/se/validation.php @@ -0,0 +1,164 @@ + ':Attribute måste accepteras.', + 'active_url' => ':Attribute är inte en giltig webbadress.', + 'after' => ':Attribute måste vara ett datum efter :date.', + 'after_or_equal' => ':Attribute måste vara ett datum senare eller samma dag som :date.', + 'alpha' => ':Attribute får endast innehålla bokstäver.', + 'alpha_dash' => ':Attribute får endast innehålla bokstäver, siffror och bindestreck.', + 'alpha_num' => ':Attribute får endast innehålla bokstäver och siffror.', + 'array' => ':Attribute måste vara en array.', + 'attached' => 'Denna :attribute är redan bifogad.', + 'before' => ':Attribute måste vara ett datum innan :date.', + 'before_or_equal' => ':Attribute måste vara ett datum före eller samma dag som :date.', + 'between' => [ + 'array' => ':Attribute måste innehålla mellan :min - :max objekt.', + 'file' => ':Attribute måste vara mellan :min till :max kilobyte stor.', + 'numeric' => ':Attribute måste vara en siffra mellan :min och :max.', + 'string' => ':Attribute måste innehålla :min till :max tecken.', + ], + 'boolean' => ':Attribute måste vara sant eller falskt.', + 'confirmed' => ':Attribute bekräftelsen matchar inte.', + 'current_password' => 'The password is incorrect.', + 'date' => ':Attribute är inte ett giltigt datum.', + 'date_equals' => ':Attribute måste vara ett datum lika med :date.', + 'date_format' => ':Attribute matchar inte formatet :format.', + 'different' => ':Attribute och :other får inte vara lika.', + 'digits' => ':Attribute måste vara :digits tecken.', + 'digits_between' => ':Attribute måste vara mellan :min och :max tecken.', + 'dimensions' => ':Attribute har felaktiga bilddimensioner.', + 'distinct' => ':Attribute innehåller fler än en repetition av samma element.', + 'email' => ':Attribute måste innehålla en korrekt e-postadress.', + 'ends_with' => ':Attribute måste sluta med en av följande: :values.', + 'exists' => ':Attribute är ogiltigt.', + 'file' => ':Attribute måste vara en fil.', + 'filled' => ':Attribute är obligatoriskt.', + 'gt' => [ + 'array' => ':Attribute måste innehålla fler än :value objekt.', + 'file' => ':Attribute måste vara större än :value kilobyte stor.', + 'numeric' => ':Attribute måste vara större än :value.', + 'string' => ':Attribute måste vara längre än :value tecken.', + ], + 'gte' => [ + 'array' => ':Attribute måste innehålla lika många eller fler än :value objekt.', + 'file' => ':Attribute måste vara lika med eller större än :value kilobyte stor.', + 'numeric' => ':Attribute måste vara lika med eller större än :value.', + 'string' => ':Attribute måste vara lika med eller längre än :value tecken.', + ], + 'image' => ':Attribute måste vara en bild.', + 'in' => ':Attribute är ogiltigt.', + 'in_array' => ':Attribute finns inte i :other.', + 'integer' => ':Attribute måste vara en siffra.', + 'ip' => ':Attribute måste vara en giltig IP-adress.', + 'ipv4' => ':Attribute måste vara en giltig IPv4-adress.', + 'ipv6' => ':Attribute måste vara en giltig IPv6-adress.', + 'json' => ':Attribute måste vara en giltig JSON-sträng.', + 'lt' => [ + 'array' => ':Attribute måste innehålla färre än :value objekt.', + 'file' => ':Attribute måste vara mindre än :value kilobyte stor.', + 'numeric' => ':Attribute måste vara mindre än :value.', + 'string' => ':Attribute måste vara kortare än :value tecken.', + ], + 'lte' => [ + 'array' => ':Attribute måste innehålla lika många eller färre än :value objekt.', + 'file' => ':Attribute måste vara lika med eller mindre än :value kilobyte stor.', + 'numeric' => ':Attribute måste vara lika med eller mindre än :value.', + 'string' => ':Attribute måste vara lika med eller kortare än :value tecken.', + ], + 'max' => [ + 'array' => ':Attribute får inte innehålla mer än :max objekt.', + 'file' => ':Attribute får max vara :max kilobyte stor.', + 'numeric' => ':Attribute får inte vara större än :max.', + 'string' => ':Attribute får max innehålla :max tecken.', + ], + 'mimes' => ':Attribute måste vara en fil av typen: :values.', + 'mimetypes' => ':Attribute måste vara en fil av typen: :values.', + 'min' => [ + 'array' => ':Attribute måste innehålla minst :min objekt.', + 'file' => ':Attribute måste vara minst :min kilobyte stor.', + 'numeric' => ':Attribute måste vara större än :min.', + 'string' => ':Attribute måste innehålla minst :min tecken.', + ], + 'multiple_of' => ':attribute måste vara en multipel av :value', + 'not_in' => ':Attribute är ogiltigt.', + 'not_regex' => 'Formatet för :attribute är ogiltigt.', + 'numeric' => ':Attribute måste vara en siffra.', + 'password' => 'Lösenordet är fel.', + 'present' => ':Attribute måste finnas med.', + 'prohibited' => 'Fältet :attribute är förbjudet.', + 'prohibited_if' => ':attribute är förbjudet när :other är :value.', + 'prohibited_unless' => ':attribute är förbjudet om inte :other är :values.', + 'regex' => ':Attribute har ogiltigt format.', + 'relatable' => 'Denna :attribute kanske inte är associerad med den här resursen.', + 'required' => ':Attribute är obligatoriskt.', + 'required_if' => ':Attribute är obligatoriskt när :other är :value.', + 'required_unless' => ':Attribute är obligatoriskt när inte :other finns bland :values.', + 'required_with' => ':Attribute är obligatoriskt när :values är ifyllt.', + 'required_with_all' => ':Attribute är obligatoriskt när :values är ifyllt.', + 'required_without' => ':Attribute är obligatoriskt när :values ej är ifyllt.', + 'required_without_all' => ':Attribute är obligatoriskt när ingen av :values är ifyllt.', + 'same' => ':Attribute och :other måste vara lika.', + 'size' => [ + 'array' => ':Attribute måste innehålla :size objekt.', + 'file' => ':Attribute får endast vara :size kilobyte stor.', + 'numeric' => ':Attribute måste vara :size.', + 'string' => ':Attribute måste innehålla :size tecken.', + ], + 'starts_with' => ':Attribute måste börja med en av följande: :values', + 'string' => ':Attribute måste vara en sträng.', + 'timezone' => ':Attribute måste vara en giltig tidszon.', + 'unique' => ':Attribute används redan.', + 'uploaded' => ':Attribute kunde inte laddas upp.', + 'url' => ':Attribute har ett ogiltigt format.', + 'uuid' => ':Attribute måste vara ett giltigt UUID.', + + /* + |-------------------------------------------------------------------------- + | Custom Validation Language Lines + |-------------------------------------------------------------------------- + | + | Here you may specify custom validation messages for attributes using the + | convention "attribute.rule" to name the lines. This makes it quick to + | specify a specific custom language line for a given attribute rule. + | + */ + + 'custom' => [ + 'attribute-name' => [ + 'rule-name' => 'custom-message', + ], + ], + + /* + |-------------------------------------------------------------------------- + | Custom Validation Attributes + |-------------------------------------------------------------------------- + | + | The following language lines are used to swap our attribute placeholder + | with something more reader friendly such as "E-Mail Address" instead + | of "email". This simply helps us make our message more expressive. + | + */ + + 'attributes' => [ + 'username' => 'användarnamn', + 'password' => 'lösenord', + 'name' => 'namn', + 'race' => 'ras', + 'class' => 'klass', + ], + +];

RecipeProfessionCrafters{{ __('Recipe') }}{{ __('Profession') }}{{ __('Crafters') }}