From 7479a3c2655bf44f0a58f2acb8e96a96fd980c9f Mon Sep 17 00:00:00 2001 From: RazorMeister Date: Thu, 11 Jul 2019 22:52:07 +0200 Subject: [PATCH] Create translation system --- src/Controllers/InstallerController.php | 8 +- src/InstallerServiceProvider.php | 9 +- src/Lang/pl/lang.php | 141 ++++++++++++++++++++++++ src/Middleware/CheckAccount.php | 2 +- src/Middleware/CheckPackages.php | 2 +- src/Middleware/CheckPermissions.php | 2 +- src/Middleware/CheckSettings.php | 2 +- src/Views/account.blade.php | 12 +- src/Views/finish.blade.php | 10 +- src/Views/layout/main.blade.php | 22 ++-- src/Views/mainSettings.blade.php | 12 +- src/Views/packages.blade.php | 24 ++-- src/Views/permissions.blade.php | 18 +-- src/Views/start.blade.php | 8 +- 14 files changed, 208 insertions(+), 64 deletions(-) create mode 100644 src/Lang/pl/lang.php diff --git a/src/Controllers/InstallerController.php b/src/Controllers/InstallerController.php index f95dd88..c2572ff 100644 --- a/src/Controllers/InstallerController.php +++ b/src/Controllers/InstallerController.php @@ -94,7 +94,7 @@ public function mainSettingsSave(Request $request) $result = $settingManager->saveEnvInfo($request->all()); if ($result['success']) - return redirect()->route('installer.account')->with('success', 'Ustawienia zostały zapisane'); + return redirect()->route('installer.account')->with('success', trans('installer::lang.controller.settingsSaved')); else return redirect()->back()->with('error', $result['error'])->withInput(); } @@ -128,14 +128,14 @@ public function accountSave(Request $request) $accountManager = new AccountManager(); if ($accountManager->isUserInDb()) - return redirect()->back()->with('error', 'Użytkownik w bazie już istnieje'); + return redirect()->back()->with('error', trans('installer::lang.controller.alreadyInDb')); $request->validate($this->configManager->getAccountRules()); if ($accountManager->createAccount($request->all())) - return redirect()->route('installer.finish')->with('success', 'Konto zostało dodane pomyślnie'); + return redirect()->route('installer.finish')->with('success', trans('installer::lang.controller.accountCreated')); else - return redirect()->back()->with('error', 'Błąd przy tworzeniu konta')->withInput(); + return redirect()->back()->with('error', trans('installer::lang.controller.errorAccount'))->withInput(); } /** diff --git a/src/InstallerServiceProvider.php b/src/InstallerServiceProvider.php index ed1ae1c..018a9c4 100644 --- a/src/InstallerServiceProvider.php +++ b/src/InstallerServiceProvider.php @@ -32,13 +32,18 @@ public function boot() { $this->loadRoutesFrom( __DIR__.'/routes.php'); $this->loadViewsFrom(__DIR__.'/Views/', 'installer'); + $this->loadTranslationsFrom(__DIR__.'/Lang/', 'installer'); $this->publishes([ __DIR__.'/Assets/' => public_path('vendor/installer') - ], 'public'); + ], 'laravelInstaller'); $this->publishes([ __DIR__.'/../config/config.php' => base_path('config/installer.php'), - ], 'public'); + ], 'laravelInstaller'); + + $this->publishes([ + __DIR__.'/Lang/' => resource_path('lang/vendor/installer'), + ], 'laravelInstaller'); } } diff --git a/src/Lang/pl/lang.php b/src/Lang/pl/lang.php new file mode 100644 index 0000000..7332d52 --- /dev/null +++ b/src/Lang/pl/lang.php @@ -0,0 +1,141 @@ + [ + 'title' => 'Laravel Instalator', + 'headerDesc' => 'Poniżej możesz zainstalować swoją aplikacje.', + 'start' => 'Start', + 'packages' => 'Pakiety', + 'permissions' => 'Permisje', + 'settings' => 'Ustawienia', + 'account' => 'Konto', + 'finish' => 'Koniec', + 'error' => 'Error', + 'success' => 'Sukces', + 'next' => 'Dalej', + 'refresh' => 'Odśwież', + 'save' => 'Zapisz', + 'createAccount' => 'Utwórz konto', + 'finish' => 'Zakończ' + ], + + /* + * + * Views/start.blade.php + * + */ + 'start' => [ + 'header' => 'Start', + 'desc' => 'Witaj w kreatorze instalacji Laravel!', + 'info' => 'Kliknij poniższy przycisk, aby przystąpić do instalacji!' + ], + + /* + * + * Views/packages.blade.php + * + */ + 'packages' => [ + 'header' => 'Pakiety', + 'desc' => 'Poniżej możesz zobaczyć status potrzebnych pakietów.', + 'phpVer' => 'Wersja PHP', + 'currentVer' => 'Obecna wersja', + 'minVer' => 'Minimalna wersja', + 'packetName' => 'Nazwa pakietu', + 'status' => 'Status', + ], + + /* + * + * Views/permissions.blade.php + * + */ + 'permissions' => [ + 'header' => 'Permisje', + 'desc' => 'Poniżej możesz zobaczyć czy są nadane odpowiednie permisje.', + 'folder' => 'Katalog', + 'currentPerms' => 'Obecna prawa', + 'minPerms' => 'Wymagane prawa', + ], + + /* + * + * Views/mainSettings.blade.php + * + */ + 'mainSettings' => [ + 'header' => 'Główne Ustawienia', + 'desc' => 'Poniżej skonfiguruj swoją aplikacje.', + ], + + /* + * + * Views/account.blade.php + * + */ + 'account' => [ + 'header' => 'Konto', + 'desc' => 'Poniżej możesz ustawić dane logowania do panelu.', + ], + + /* + * + * Views/finish.blade.php + * + */ + 'finish' => [ + 'header' => 'Koniec!', + 'desc' => 'Instalacja aplikacji dobiegła końca.', + 'thanks' => 'Dziękujemy za skorzystanie z Laravel Installatora by RazorMeister.', + 'time' => 'Czas Twojej instalacji wyniósł: ', + ], + + /* + * + * Controllers/InstallerController.php + * + */ + 'controller' => [ + 'settingsSaved' => 'Ustawienia zostały zapisane', + 'alreadyInDb' => 'Użytkownik w bazie już istnieje', + 'accountCreated' => 'Konto zostało utworzone pomyślnie', + 'errorAccount' => 'Błąd przy tworzeniu konta', + ], + + /* + * + * Middleware/CheckPackages.php + * + */ + 'checkPackages' => 'Najpierw sprawdź pakiety', + + /* + * + * Middleware/CheckPermissions.php + * + */ + 'checkPermissions' => 'Najpierw sprawdź permisje', + + /* + * + * Middleware/CheckSettings.php + * + */ + 'checkSettings' => 'Najpierw skonfiguruj aplikację', + + /* + * + * Middleware/CheckAccount.php + * + */ + 'checkAccount' => 'Najpier załóż konto!', +]; diff --git a/src/Middleware/CheckAccount.php b/src/Middleware/CheckAccount.php index b8b81b5..84e3c09 100644 --- a/src/Middleware/CheckAccount.php +++ b/src/Middleware/CheckAccount.php @@ -31,6 +31,6 @@ public function handle($request, Closure $next) if ($this->accountManager->isUserInDb()) return $next($request); else - return redirect(route('installer.account'))->with('error', 'Najpier załóż konto!'); + return redirect(route('installer.account'))->with('error', trans('installer::lang.checkAccount')); } } diff --git a/src/Middleware/CheckPackages.php b/src/Middleware/CheckPackages.php index b1c36a6..f02ae42 100644 --- a/src/Middleware/CheckPackages.php +++ b/src/Middleware/CheckPackages.php @@ -34,6 +34,6 @@ public function handle($request, Closure $next) if ($phpVerInfo['isOk'] && $packagesInfo['allOk']) return $next($request); else - return redirect(route('installer.packages'))->with('error', 'Najpierw sprawdź pakiety'); + return redirect(route('installer.packages'))->with('error', trans('installer::lang.checkPackages')); } } diff --git a/src/Middleware/CheckPermissions.php b/src/Middleware/CheckPermissions.php index 497fa79..b044208 100644 --- a/src/Middleware/CheckPermissions.php +++ b/src/Middleware/CheckPermissions.php @@ -33,6 +33,6 @@ public function handle($request, Closure $next) if ($permsInfo['allOk']) return $next($request); else - return redirect(route('installer.permissions'))->with('error', 'Najpierw sprawdź permisje'); + return redirect(route('installer.permissions'))->with('error', trans('installer::lang.checkPermissions')); } } diff --git a/src/Middleware/CheckSettings.php b/src/Middleware/CheckSettings.php index d0fec15..542fa30 100644 --- a/src/Middleware/CheckSettings.php +++ b/src/Middleware/CheckSettings.php @@ -31,6 +31,6 @@ public function handle($request, Closure $next) if ($this->settingsManager->envFileExists()) return $next($request); else - return redirect(route('installer.mainSettings'))->with('error', 'Najpierw skonfiguruj aplikację'); + return redirect(route('installer.mainSettings'))->with('error', trans('installer::lang.checkSettings')); } } diff --git a/src/Views/account.blade.php b/src/Views/account.blade.php index b5de885..ce0fcf6 100644 --- a/src/Views/account.blade.php +++ b/src/Views/account.blade.php @@ -3,8 +3,8 @@ @section('stepNumber', 5) @section('header') -

Konto

-

Poniżej możesz ustawić dane logowania do panelu!

+

{{ trans('installer::lang.account.header') }}

+

{{ trans('installer::lang.account.desc') }}

@endsection @section('content') @@ -23,11 +23,11 @@ @endforeach
@if($isInDb) - - + + @else - - + + @endif
diff --git a/src/Views/finish.blade.php b/src/Views/finish.blade.php index 6339ac4..10f57ad 100644 --- a/src/Views/finish.blade.php +++ b/src/Views/finish.blade.php @@ -3,18 +3,18 @@ @section('stepNumber', 6) @section('header') -

Koniec!

-

Instalacja aplikacji dobiegła końca

+

{{ trans('installer::lang.finish.header') }}

+

{{ trans('installer::lang.finish.desc') }}

@endsection @section('content')

-

Dziękujemy za skorzystanie z Laravel Installatora by RazorMeister

-
Czas Twojej instalacji wyniósł: {{ $time }}
+

{{ trans('installer::lang.finish.thanks') }}

+
{{ trans('installer::lang.finish.time') }} {{ $time }}

- +
@endsection diff --git a/src/Views/layout/main.blade.php b/src/Views/layout/main.blade.php index 7163e4c..c0cb35f 100644 --- a/src/Views/layout/main.blade.php +++ b/src/Views/layout/main.blade.php @@ -7,7 +7,7 @@ - Laravel Installer + {{ trans('installer::lang.main.title') }} @@ -67,9 +67,7 @@

Laravel Installator

-

- Poniżej możesz zainstalować swoją aplikacje. -

+

{{ trans('installer::lang.main.headerDesc') }}

@@ -83,37 +81,37 @@
-

Start

+

{{ trans('installer::lang.main.start') }}

-

Pakiety

+

{{ trans('installer::lang.main.packages') }}

-

Permisje

+

{{ trans('installer::lang.main.permissions') }}

-

Ustawienia

+

{{ trans('installer::lang.main.settings') }}

-

Konto

+

{{ trans('installer::lang.main.account') }}

-

Koniec

+

{{ trans('installer::lang.main.finish') }}

@if (session('error')) @endif @if (session('success')) @endif diff --git a/src/Views/mainSettings.blade.php b/src/Views/mainSettings.blade.php index ffd8415..25f8f75 100644 --- a/src/Views/mainSettings.blade.php +++ b/src/Views/mainSettings.blade.php @@ -3,8 +3,8 @@ @section('stepNumber', 4) @section('header') -

Główne ustawienia

-

Poniżej skonfiguruj swoją aplikacje.

+

{{ trans('installer::lang.mainSettings.header') }}

+

{{ trans('installer::lang.mainSettings.desc') }}

@endsection @section('content') @@ -27,11 +27,11 @@ @endforeach
@if($isEnvFile) - - + + @else - - + + @endif
diff --git a/src/Views/packages.blade.php b/src/Views/packages.blade.php index 368567a..5b2d19b 100644 --- a/src/Views/packages.blade.php +++ b/src/Views/packages.blade.php @@ -3,8 +3,8 @@ @section('stepNumber', 2) @section('header') -

Pakiety

-

Poniżej został wypisany status wymaganych pakietów.

+

{{ trans('installer::lang.packages.header') }}

+

{{ trans('installer::lang.packages.desc') }}

@endsection @section('content') @@ -13,16 +13,16 @@ - + @@ -39,26 +39,26 @@
Wersja PHP{{ trans('installer::lang.packages.phpVer') }}
- Obecna wersja + {{ trans('installer::lang.packages.currentVer') }} - Minimalna wymagana + {{ trans('installer::lang.packages.minVer') }}
- - + + @foreach($packagesInfo['packages'] as $package => $installed) - + @endforeach
Nazwa pakietuStatus{{ trans('installer::lang.packages.packetName') }}{{ trans('installer::lang.packages.status') }}
{{ $package }}
@if($phpVerInfo['isOk'] && $packagesInfo['allOk']) - - + + @else - - + + @endif
diff --git a/src/Views/permissions.blade.php b/src/Views/permissions.blade.php index f41373e..85ccd12 100644 --- a/src/Views/permissions.blade.php +++ b/src/Views/permissions.blade.php @@ -3,8 +3,8 @@ @section('stepNumber', 3) @section('header') -

Permisje

-

Poniżej możesz zobaczyć czy są nadane odpowiednie permisje.

+

{{ trans('installer::lang.permissions.header') }}

+

{{ trans('installer::lang.permissions.desc') }}

@endsection @section('content') @@ -13,9 +13,9 @@ - - - + + + @@ -30,11 +30,11 @@
KatalogObecne prawaMinimalne prawa{{ trans('installer::lang.permissions.folder') }}{{ trans('installer::lang.permissions.currentPerms') }}{{ trans('installer::lang.permissions.minPerms') }}
@if($permsInfo['allOk']) - - + + @else - - + + @endif
diff --git a/src/Views/start.blade.php b/src/Views/start.blade.php index ef0111f..dd67c4e 100644 --- a/src/Views/start.blade.php +++ b/src/Views/start.blade.php @@ -3,17 +3,17 @@ @section('stepNumber', 1) @section('header') -

Start

-

Witaj w kreatorze instalacji Laravel!

+

{{ trans('installer::lang.start.header') }}

+

{{ trans('installer::lang.start.desc') }}

@endsection @section('content')

-

Kliknij poniższy przycisk, aby przystąpić do instalacji!

+

{{ trans('installer::lang.start.info') }}


- +
@endsection