Download the PHP package omgdef/yii2-multilingual-behavior without Composer

On this page you can find all versions of the php package omgdef/yii2-multilingual-behavior. 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 yii2-multilingual-behavior

Yii2 multilingual behavior

Yii2 port of the yii-multilingual-behavior.

Packagist Version Total Downloads Build Status Code Quality Code Coverage

This behavior allows you to create multilingual models and almost use them as normal models. Translations are stored in a separate table in the database (ex: PostLang or ProductLang) for each model, so you can add or remove a language easily, without modifying your database.

*!!! IMPORTANT !!! Docs for vesions 1. here**

*In vesion 2. forceOverwrite property is deprecated**

Examples

Example #1: current language translations are inserted to the model as normal attributes by default.

Example #2: if you use multilingual() in a find() query, every model translation is loaded as virtual attributes (title_en, title_fr, title_de, ...).

Installation

Preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Behavior attributes

Attributes marked as bold are required

Attribute Description
languageField The name of the language field of the translation table. Default is 'language'
localizedPrefix The prefix of the localized attributes in the lang table. Is used to avoid collisions in queries. The columns in the translation table corresponding to the localized attributes have to be name like this: and the id column (primary key) like this :
requireTranslations If this property is set to true required validators will be applied to all translation models.
dynamicLangClass Dynamically create translation model class. If true, the translation model class will be generated on runtime with the use of the eval() function so no additionnal php file is needed
langClassName The name of translation model class. Dafault value is model name + Lang
languages Available languages. It can be a simple array: or an associative array:
defaultLanguage The default language
langForeignKey Name of the foreign key field of the translation table related to base model table.
tableName The name of the translation table
attributes Multilingual attributes

Usage

Here an example of base 'post' table :

And its associated translation table (configured as default), assuming translated fields are 'title' and 'content':

Attaching this behavior to the model (Post in the example). Commented fields have default values.

Then you have to overwrite the find() method in your model

As this behavior has , you can use it in your query classes

Form example:

Hint: has to be populated with relative data otherwise translations will not be updated after send.


All versions of yii2-multilingual-behavior with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 Version *
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 omgdef/yii2-multilingual-behavior contains the following files

Loading the files please wait ....