Download the PHP package gertjanroke/translations without Composer

On this page you can find all versions of the php package gertjanroke/translations. 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 translations

Translations

Easy way to make your database multilanguage

Install

After install

Publish files

If all your models are directly in your app folder and your using the laravel convention, you do not need to publish the config file. But if your somehow not following this convention, like putting your models in a own folder. Than you need to publish the config file and define where your translation models are stored.

If you need to publish the config file, than first do the following think before running the publish command.

Add the following line to config/app.php.

at providers:

To publish the config file run the following command:

Usage

Now comes the fun part:

To use the translations trait you only need to add a use inside your model class. You can do so by:

and add the use above your class like so:

Now your almost done.

The only thing you need to do is make a translation model for the model you just added the trait.

Something like:

The important part is that out of the box this package uses a model name like the one above. If you want to override this just edit the config file and your good to go.

Saving your translations

The first thing you need to do is check with way works best for you. This package comes with a default request attribute on with he he build a foreach to save all values per locale. This format is as following:

If your do not like the key word trans you can easly change this in the config. To something like:

or

or what ever you like.

After you made your forms you now need to save the data. This package comes with two ways to do so. Just call the following function from your model and send the request object with it. like so:

or the short version:

And the package will create a new row in your database table or it will update its existing row.

Magic funtions

This package als comes with two handy funtions that let you do things like:

and it will check if that attribute existing in your translations table. If it exists, the value will be returned in the currunt locale of your application.

The other magic function is dynamic getters. Let take the example from above and use that as a method.

This will get the title just like the funtion above, but now you can specify with locale version you want of the given attribute.

You can change 'en' for the require locale.

Custom Foreign key

If for some reason you do not like the way laravel handles the foreign keys and you want to use your own conventions, Thust do so by setting the transForeignKey variable in your main model. For example:


All versions of translations with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.4
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 gertjanroke/translations contains the following files

Loading the files please wait ....