From a35309799e93fe384d16ead531add16b98b634e1 Mon Sep 17 00:00:00 2001 From: Zak Nesler <7189795+zaknesler@users.noreply.github.com> Date: Thu, 14 Nov 2019 10:50:30 -0500 Subject: [PATCH] [5.0] Localization and password confirmation view (#14) * Update dependencies * Add confirm view * Allow all text to be localized * Add StyleCI configuration to repo --- readme.md | 6 ++ src/Tailwind.php | 10 ++-- src/stubs/en.stub | 40 +++++++++++++ src/stubs/views/auth/auth/login.stub | 20 ++++--- .../views/auth/auth/passwords/confirm.stub | 56 +++++++++++++++++++ .../views/auth/auth/passwords/email.stub | 11 ++-- .../views/auth/auth/passwords/reset.stub | 12 ++-- src/stubs/views/auth/auth/register.stub | 17 +++--- src/stubs/views/auth/auth/verify.stub | 11 ++-- src/stubs/views/auth/errors/404.stub | 8 ++- src/stubs/views/auth/errors/419.stub | 8 ++- src/stubs/views/auth/errors/500.stub | 8 ++- src/stubs/views/auth/errors/503.stub | 6 +- .../views/auth/layouts/partials/_header.stub | 12 ++-- src/stubs/views/auth/welcome.stub | 8 +-- styleci.yml | 7 +++ 16 files changed, 186 insertions(+), 54 deletions(-) create mode 100644 src/stubs/en.stub create mode 100644 src/stubs/views/auth/auth/passwords/confirm.stub create mode 100644 styleci.yml diff --git a/readme.md b/readme.md index cf264d7..9b57d6c 100644 --- a/readme.md +++ b/readme.md @@ -59,6 +59,12 @@ yarn dev // npm run dev Ensure that your database is properly configured and migrated, and you're done! +### Localization + +All of the text in the views that this preset provides are configured to be easily translatable. When you install the `tailwind-auth` preset, the file `en.json` will be copied into your application's `resources/lang` directory. + +This file includes all of the text found in this package. To update the default English text, simply update the values of any of the key-value pairs. To translate into a different language, duplicate `en.json` and rename it to `{locale}.json`; you can then translate the values into the destination language. For more about localization, please refer to the [Laravel documentation](https://laravel.com/docs/6.x/localization). + ### EditorConfig To ensure proper guide highlighting in your text editor, it is recommended that you add the following to the end of the `.editorconfig` file: diff --git a/src/Tailwind.php b/src/Tailwind.php index 3258105..fd2d86a 100644 --- a/src/Tailwind.php +++ b/src/Tailwind.php @@ -57,6 +57,7 @@ public static function installWithAuth() ]); static::installViews('auth', [ + 'auth/passwords/confirm.stub', 'auth/passwords/email.stub', 'auth/passwords/reset.stub', 'auth/login.stub', @@ -73,6 +74,7 @@ public static function installWithAuth() ]); file_put_contents(app_path('Http/Controllers/HomeController.php'), static::compileControllerStub()); + File::copy(__DIR__.'/stubs/en.stub', resource_path('lang/en.json')); } /** @@ -85,11 +87,11 @@ protected static function updatePackageArray(array $packages) { return [ '@tailwindcss/custom-forms' => '^0.2', - 'autoprefixer' => '^9.6', + 'autoprefixer' => '^9.7', 'axios' => '^0.19', - 'cross-env' => '^5.2', - 'laravel-mix' => '^4.1', - 'laravel-mix-purgecss' => '^4.1', + 'cross-env' => '^6.0', + 'laravel-mix' => '^5.0', + 'laravel-mix-purgecss' => '^4.2', 'tailwindcss' => '^1.1', 'vue' => '^2.6', 'vue-template-compiler' => '^2.6', diff --git a/src/stubs/en.stub b/src/stubs/en.stub new file mode 100644 index 0000000..af6e397 --- /dev/null +++ b/src/stubs/en.stub @@ -0,0 +1,40 @@ +{ + "404 Page Not Found": "404 Page Not Found", + "419 Page Expired": "419 Page Expired", + "500 Internal Server Error": "500 Internal Server Error", + "503 Service Unavailable": "503 Service Unavailable", + "Confirm New Password": "Confirm New Password", + "Confirm Password": "Confirm Password", + "Confirm your password": "Confirm your password", + "Confirm": "Confirm", + "Create a new account": "Create a new account", + "Create account": "Create account", + "Didn't get the email?": "Didn't get the email?", + "Email": "Email", + "Enter your email address and we'll send you a link to reset your password": "Enter your email address and we'll send you a link to reset your password", + "Forgot password?": "Forgot password?", + "Have an account?": "Have an account?", + "Home": "Home", + "Logout": "Logout", + "Name": "Name", + "New Password": "New Password", + "Page expired (Try refreshing)": "Page expired (Try refreshing)", + "Page not found": "Page not found", + "Password": "Password", + "Please confirm your password before continuing": "Please confirm your password before continuing", + "Remember it?": "Remember it?", + "Remember me": "Remember me", + "Resend it": "Resend it", + "Reset password": "Reset password", + "Reset your password": "Reset your password", + "Send Link": "Send Link", + "Sign in to your account": "Sign in to your account", + "Sign in": "Sign in", + "Sign up": "Sign up", + "Something went wrong": "Something went wrong", + "Verify your email": "Verify your email", + "We have sent you a fresh verification link, please check your email.": "We have sent you a fresh verification link, please check your email.", + "We're performing some maintenance, check back soon": "We're performing some maintenance, check back soon", + "Welcome": "Welcome", + "You must verify your email address before proceeding. Please check your email for a verification link.": "You must verify your email address before proceeding. Please check your email for a verification link." +} diff --git a/src/stubs/views/auth/auth/login.stub b/src/stubs/views/auth/auth/login.stub index b722005..1269dba 100644 --- a/src/stubs/views/auth/auth/login.stub +++ b/src/stubs/views/auth/auth/login.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Sign in') +@section('title', __('Sign in')) @section('show-header', false) @section('content-full') @@ -11,7 +11,7 @@
- Sign in to your account + {{ __('Sign in to your account') }}
@@ -19,7 +19,7 @@
@if (Route::has('register')) - Create account + + {{ __('Create account') }} + @endif @if (Route::has('register') && Route::has('password.request')) @@ -80,7 +82,9 @@ @endif @if (Route::has('password.request')) - Forgot password? + + {{ __('Forgot password?') }} + @endif
diff --git a/src/stubs/views/auth/auth/passwords/confirm.stub b/src/stubs/views/auth/auth/passwords/confirm.stub new file mode 100644 index 0000000..964f138 --- /dev/null +++ b/src/stubs/views/auth/auth/passwords/confirm.stub @@ -0,0 +1,56 @@ +@extends('layouts.base') + +@section('title', __('Confirm your password')) +@section('show-header', false) + +@section('content-full') +
+
+ + +
+ {{ __('Please confirm your password before continuing') }} +
+ + @if (session('status')) +
+ {{ session('status') }} +
+ @endif + +
+ @csrf + +
+ +
+ +
+ @if (Route::has('password.request')) + {{ __('Forgot password?') }} + @endif + + +
+
+
+
+@endsection diff --git a/src/stubs/views/auth/auth/passwords/email.stub b/src/stubs/views/auth/auth/passwords/email.stub index bddaf85..3f38d1e 100644 --- a/src/stubs/views/auth/auth/passwords/email.stub +++ b/src/stubs/views/auth/auth/passwords/email.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Reset your password') +@section('title', __('Reset your password')) @section('show-header', false) @section('content-full') @@ -11,7 +11,7 @@
- Enter your email address and we'll send you a link to reset your password + {{ __('Enter your email address and we\'ll send you a link to reset your password') }}
@if (session('status')) @@ -25,7 +25,7 @@
diff --git a/src/stubs/views/auth/auth/passwords/reset.stub b/src/stubs/views/auth/auth/passwords/reset.stub index 63dba52..71dc666 100644 --- a/src/stubs/views/auth/auth/passwords/reset.stub +++ b/src/stubs/views/auth/auth/passwords/reset.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Reset your password') +@section('title', __('Reset your password')) @section('show-header', false) @section('content-full') @@ -11,7 +11,7 @@
- Reset your password + {{ __('Reset your password') }}
@@ -21,7 +21,7 @@
diff --git a/src/stubs/views/auth/auth/register.stub b/src/stubs/views/auth/auth/register.stub index 7ceb9b9..d4ba85a 100644 --- a/src/stubs/views/auth/auth/register.stub +++ b/src/stubs/views/auth/auth/register.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Sign up') +@section('title', __('Sign up')) @section('show-header', false) @section('content-full') @@ -11,7 +11,7 @@
- Create a new account + {{ __('Create a new account') }}
@@ -19,7 +19,7 @@
diff --git a/src/stubs/views/auth/auth/verify.stub b/src/stubs/views/auth/auth/verify.stub index 9e0f12b..93655fa 100644 --- a/src/stubs/views/auth/auth/verify.stub +++ b/src/stubs/views/auth/auth/verify.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Verify your email') +@section('title', __('Verify your email')) @section('show-header', false) @section('content-full') @@ -13,15 +13,18 @@
@if (session('resent')) - We have sent you a fresh verification link, please check your email. + {{ __('We have sent you a fresh verification link, please check your email.') }} @else - You must verify your email address before proceeding. Please check your email for a verification link. + {{ __('You must verify your email address before proceeding. Please check your email for a verification link.') }} @endif
-
Didn't get the email? Resend it
+
+ {{ __('Didn\'t get the email?') }} + {{ __('Resend it') }} +
diff --git a/src/stubs/views/auth/errors/404.stub b/src/stubs/views/auth/errors/404.stub index a4403d7..ba04a81 100644 --- a/src/stubs/views/auth/errors/404.stub +++ b/src/stubs/views/auth/errors/404.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', '404 Page Not Found') +@section('title', __('404 Page Not Found')) @section('show-header', false) @section('content-full') @@ -9,10 +9,12 @@
404
-
Page not found
+
{{ __('Page not found') }}
- ← Home + + ← {{ __('Home') }} +
diff --git a/src/stubs/views/auth/errors/419.stub b/src/stubs/views/auth/errors/419.stub index d6729e5..d95c569 100644 --- a/src/stubs/views/auth/errors/419.stub +++ b/src/stubs/views/auth/errors/419.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', '419 Page Expired') +@section('title', __('419 Page Expired')) @section('show-header', false) @section('content-full') @@ -9,10 +9,12 @@
419
-
Page expired (Try refreshing)
+
{{ __('Page expired (Try refreshing)') }}
- ← Home + + ← {{ __('Home') }} +
diff --git a/src/stubs/views/auth/errors/500.stub b/src/stubs/views/auth/errors/500.stub index f4f0948..0462cca 100644 --- a/src/stubs/views/auth/errors/500.stub +++ b/src/stubs/views/auth/errors/500.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', '500 Internal Server Error') +@section('title', __('500 Internal Server Error')) @section('show-header', false) @section('content-full') @@ -9,10 +9,12 @@
500
-
Something went wrong
+
{{ __('Something went wrong') }}
- ← Home + + ← {{ __('Home') }} +
diff --git a/src/stubs/views/auth/errors/503.stub b/src/stubs/views/auth/errors/503.stub index 640e32b..98c7bd0 100644 --- a/src/stubs/views/auth/errors/503.stub +++ b/src/stubs/views/auth/errors/503.stub @@ -1,13 +1,15 @@ @extends('layouts.base') -@section('title', '503 Service Unavailable') +@section('title', __('503 Service Unavailable')) @section('show-header', false) @section('content-full')
-
{{ $exception->getMessage() ?: 'We\'re performing some maintenance, check back soon' }}
+
+ {{ $exception->getMessage() ?: __('We\'re performing some maintenance, check back soon') }} +
diff --git a/src/stubs/views/auth/layouts/partials/_header.stub b/src/stubs/views/auth/layouts/partials/_header.stub index dbc5155..78b6253 100644 --- a/src/stubs/views/auth/layouts/partials/_header.stub +++ b/src/stubs/views/auth/layouts/partials/_header.stub @@ -29,7 +29,7 @@ > @@ -37,12 +37,16 @@ diff --git a/src/stubs/views/auth/welcome.stub b/src/stubs/views/auth/welcome.stub index 6b3c33f..f18b3cd 100644 --- a/src/stubs/views/auth/welcome.stub +++ b/src/stubs/views/auth/welcome.stub @@ -1,6 +1,6 @@ @extends('layouts.base') -@section('title', 'Welcome') +@section('title', __('Welcome')) @section('show-header', false) @section('content-full') @@ -10,16 +10,16 @@