Skip to content

Commit

Permalink
Update Readme to better show html processor example
Browse files Browse the repository at this point in the history
  • Loading branch information
Corbin committed May 2, 2021
1 parent 173768f commit ef0e457
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,34 @@ 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') !!}
```

## After
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**
```html
@php(qtrans()->shift('columns.users'))

{{ qtrans('name') }}
{{ qtrans('email') }}
{{ qtrans('description') }}
{{ qtrans('notes')->escape()->br() }}
{{ qtrans('description')->clear() }}
```

## Warning
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion src/Html.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// cj custom

namespace Corbinjurgens\QTrans;

use Illuminate\Contracts\Support\Htmlable;
Expand Down

0 comments on commit ef0e457

Please sign in to comment.