Download the PHP package corbinjurgens/qtrans without Composer

On this page you can find all versions of the php package corbinjurgens/qtrans. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package qtrans

Introduction

This package helps you access your key translations (json translations not supported) with some handy features, and allows you to modify how the translation is displayed by chaining 'processors'

Before

In cases where your translations in a certain area are all pointing to the same place, its not very DRY to do this

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 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

Pre-shift

Warning

QTrans by default escapes translation strings. You can edit this in config qtrans.processor. The intention is that you will not escape translations as generally they should be safe, so I recommend turning off escape default. However if you manually apply HTML processors to a translation and forget escape(), it will not be escaped, even if escape is in the defaults.

Installation

Composer

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)

and run

Add the following to config/app.php providers

Add alias to config/app.php alias

Usage

See introduction for basic usage

Multiple Options

When shifting, you can pass an array to declare that the translation key can be found in one of muliple places

In the following example, each key eg. 'name' will look to 'forms.signup.name', then if not found 'columns.users.name' to find the translation.

This is my preference for arranging table column translations, have general translations in one area, then translations specific to the current page in another area with only translations given that differ from the general.

Give a preference dynamically

Your translations may have a set list of places to be found, and the number 1 preference may depend on a variable. In such case use priority function. The given variable should be one that exisst in the given shift array, but it can also be one not in the array.

Shifting elsewhere, then back

When shifting a second, third or futher times, the history of you shifts is kept, and you can back out to the previous shift with back()

Deeper and deeper

When shifting, if you pass true as a second variable, the given shift value or values will be an extension of the previous shift. Only possible after the 1st shift

Of course you can give array each shift and it'll follow the following pattern when searching for translation. Actual use cases for this seem rare though.

The key "cell" will be searched for in

Use current() function to get an array like above showing the current shift levels bases

Reset

To clear shift history and start a new base, or start an empty base use base()

Temporary pause shift

Use pause() then later resume() to turn off shift features temporary and look for key raw as with normal translations

Or use skip() to pause shift feature for the next translation. You can pass a numer to skip if you want to skip a certain numer of times

Html processors

If the current instance $basic_setting property is set to false (determined by config 'qtrans.basic'), all returned translation values will be an 'Htmlable' instance. This allows you to chain processors.

Before

If you wanted to use the nl2br function and escape, you needed to do something like

Which is very messy.

After

Note the order of processors matters. Running br()->escape() will cause html
tags to show as plain text

Available Processors

Html processor defaults

To apply a set of default processors to all your translations, modify and add to the config qtrans.processor array.

For example, by default processors is set as

This means for the situation {{ ___('users.name') }}, the escape processor is applied. BUT if you manually call a processor such as {{ ___('users.name')->br() }} escape, or any other processors declared in default wont be used. This is for situations where you want to reorder the processors.

If you dont want to use the default processors for a specific translation but don't have any processors to replace it with call clear() for example {{ ___('users.name')->clear() }}. You may also modify the default processors by editing $processor_setting array property eg qtrans()->processor_setting = []

Custom Processor

Create a custom processor by calling Corbinjurgens\QTrans\Html::custom()

For example, in your AppServiceProvider register function


All versions of qtrans with dependencies

PHP Build Version
Package Version
Requires laravel/laravel Version >=5.8
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package corbinjurgens/qtrans contains the following files

Loading the files please wait ....