From ef0e45765a123beb7b0d9ad306def7e5ad320fb2 Mon Sep 17 00:00:00 2001 From: Corbin Date: Sun, 2 May 2021 19:54:06 +0900 Subject: [PATCH] Update Readme to better show html processor example --- README.md | 19 +++++++++++++------ src/Facade.php | 2 +- src/Html.php | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 03ac87c..a666010 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ In cases where your translations in a certain area are all pointing to the same ```html {{ __('columns.users.name') }} -{{ __('columns.users.email') }} +{!! nl2br( e( __('columns.users.notes') ) ) !!} {!! __('columns.users.description') !!} ``` @@ -15,13 +15,17 @@ In cases where your translations in a certain area are all pointing to the same Instead of __() or trans(), use ___() or qtrans() Use "shift" function to declare that all following translations should look in a certain area -You can use qtrans($key) or qtrans()->get($key), the latter useful for when you want to call other functions +You can use qtrans($key) or qtrans()->get($key), the latter useful for when you want to call other functions before getting the translation. + +If in your config 'qtrans.processor' array 'escape' is active, then by default all translations will be escaped unless you manually apply processors by chaining off the translation, or chain clear(). In the below example, the config will be as shipped in the package, with escape processor active + +There is no longer any need to switch between {{ }} and {!! !!} blade functions. Always use {{ }} and whether or not the text is escaped will depend on your html processor defaults, or on what processors you manually chain **Inline shift** ```html {{ qtrans()->shift('columns.users')->get('name') }} -{{ qtrans('email') }} -{{ qtrans('description') }} +{{ qtrans('notes')->escape()->br() }} +{{ qtrans('description')->clear() }} ``` **Pre-shift** @@ -29,8 +33,8 @@ You can use qtrans($key) or qtrans()->get($key), the latter useful for when you @php(qtrans()->shift('columns.users')) {{ qtrans('name') }} -{{ qtrans('email') }} -{{ qtrans('description') }} +{{ qtrans('notes')->escape()->br() }} +{{ qtrans('description')->clear() }} ``` ## Warning @@ -42,6 +46,9 @@ QTrans by default escapes translation strings. You can edit this in config qtran `composer require corbinjurgens/qtrans` +## Config +`php artisan vendor:publish --tag="qtrans-config"` + ## Manual Installation Copy the following to main composer.(in the case that the package is added to packages/corbinjurgens/qroute) diff --git a/src/Facade.php b/src/Facade.php index 02f16b8..fb2e5ba 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -4,7 +4,7 @@ use Illuminate\Support\Facades\Facade as BaseFacade; -use Corbinjurgens\QRoute\ServiceProvider as S; +use Corbinjurgens\QTrans\ServiceProvider as S; class Facade extends BaseFacade { protected static function getFacadeAccessor() { return S::$name; } diff --git a/src/Html.php b/src/Html.php index 07e6c0c..fbf8236 100644 --- a/src/Html.php +++ b/src/Html.php @@ -1,5 +1,5 @@