Download the PHP package zai/laravel-eloquent-multilingualization without Composer

On this page you can find all versions of the php package zai/laravel-eloquent-multilingualization. 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 laravel-eloquent-multilingualization

laravel-eloquent-multilingualization

Add multilingual support to your laravel eloquent models in a breeze

Installation

Step 1: Install package

Executing the following command to add the package in your composer.json

For laravel 5.4, add the service provider to app/config/app.php

For laravel 5.5, because of package auto-discovery, there is no need to add service provider to app/config/app.php

Step 2: Migration

Executing the following commands to add translations table. Only one table is needed for translating any Eloquent models

Usage

Use Translatable trait in the model you want to translate

Let's say the model is called Article. In the Article model

Define translatables property in the model

Take the same Article model as example. We want to translate title and body of an article

Add Translation

Using method: addTranslation. It takes an associative array as parameter. Simply put the translation data in the array, including which language it is using key locale.

The method only adds keys that exist in the translatables property of the model. Any other keys will be ignored. If a key in the translatables property is missing in the parameter. It will still be inserted, but the value will become empty string.

If you submit the translation data in the form. In your ArticleTranslationsController, simply using

Remember to include locale input filed in your form, so it can be posted in the request. If addTranslation method is applied to an existing translation, it will update the existing translation with values in the parameter.

Display translation

Using translation attribute provided by the trait, e.g, $article->translation->title. It will return correct translation based on what the current locale is (the value returned by App::getLocale())

For default locale or if the translation of a locale is missing, it will return the values in the model.

Update translation

Using method: updateTranslation. It takes an associative array as parameter. Simply put the updated translation data in the array, including which language it is.

If you update the translation using form, in your ArticleTranslationsController

If you update to a translation which doesn't exist, it will insert a new translation.

Delete a translation

Using method deleteTranslation. It takes a string which specifies which language of the translation you want to delete as parameter.

Delete all translations

Using method deleteTranslations which takes no parmaters

Check translations exist

Using method hasTranslations which takes no paramters. The method returns boolean to indicate if the record has translations or not.

Check translation of a locale exists

Using method hasTranslation. It takes a string as parameter which specifies the locale you are checking. The method returns boolean to indicate if the translation of a specific locale exists or not.

Prevent N+1 problem

To prevent N+1 problem, eager load translations in your model

Appending Values To JSON

Add the attribute translation to the appends property on the model


All versions of laravel-eloquent-multilingualization with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version ~5.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 zai/laravel-eloquent-multilingualization contains the following files

Loading the files please wait ....