1. Go to this page and download the library: Download yiimaker/yii2-translatable library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// product is an active record model with translatable behavior
$product = new Product();
// sets translation for default application language
$product->title = 'PhpStrom 2018.1';
$product->description = 'Лицензия PhpStrom IDE версия 2018.1';
// gets translation for English language
$translation = $product->getTranslation('en');
$translation->title = 'PhpStrom 2018.1';
$translation->description = 'License of the PhpStrom IDE version 2018.1';
// sets description for French language
$product->translateTo('fr')->description = 'La licence de PhpStorm IDE la version 2018.1';
$product->insert();
$product = Product::find()
->where(['id' => 1])
->with('translations')
->one()
;
// gets translation for English language
$product->translateTo('en')->description; // License of the PhpStrom IDE version 2018.1
// gets translation for French language
$product->translateTo('fr')->description; // La licence de PhpStorm IDE la version 2018.1
// check whether Ukrainian translation not exists
if (!$product->hasTranslation('uk')) {
$product->translateTo('uk')->description = 'Ліцензія PhpStrom IDE версія 2018.1';
}
// update Enlish translation
$product->translateTo('en')->title = 'PhpStorm IDE';
$product->update();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.