multilingual-crud Multilingual CRUD generator (Gii template). Automate creation of multilingual CRUDs for any structure models without data-losing

Did you have some discomfort, creating multilingual sites and Models? I didn't find any elegant interface for solving this problem. So, what i need? I'd like to create automatically CRUD for any model with multilingual support. Create model of any structure and create automatically CRUD for managing this model with any list of languages. I don't need any additional tables for translations, but out-of-the-box generator for any model structure. Certainly, there will be some constraints to make it workable:

<li>you need to make an additional field - varchar(10) 'language' to keep language in</li>
<li>change primary_key(id) to composite primary_key(id, language)</li>
<li>connect special multilingual behavior for more efficiency usage</li>

And that's all. After this you can:

<li>automatically generate CRUD for any multilingual CRUD</li>
<li>easily manipulate your model's data in your routines</li>

Installation routines

Unpack module files to your application.module path. Configurate config/main.php:

<li> add <a href="http://www.yiiframework.com/doc/guide/1.1/en/topics.gii" target="_blank">gii generator</a> additional templates path</li>

'modules' => array(
  ...
  'gii' => array(
  ...
  'generatorPaths' => array(
    'application.modules.MultilingualCrud.extensions.gii-templates'
  ),
  ...
),
...
'MultilingualCrud' => array(
  'defaultLayout' => 'application.custom.layout', /// you can set default layout for your controller here, or //layouts/column2 will be used
  'fieldsPk' => array('id', 'language'), /// you can set composite key fields names (not tested yet). It is better to keep default. Chabge before generating
),
...
configure your current language in config
...
'language' => 'en_us',
...
  • configure your exist model:
  1. add composite key ('id', 'language')
  2. add custom multilingual behavior to your model
....
public function behaviors()
{
  return array(
    ...
    'ml' => array( /// ml is neccessary name
      'class' => 'application.modules.MultilingualCrud.components.MultilingualActiveRecordBehavior'
    )
  );
}
....
  • manage your languages using predefined module controller

go 'MultilingualCrud/' and admin your languages list. You can easily disable/enable exist languages to provide access for translations in your models.

<li>go to the GII and create CRUD, using MultilingualCrud generator</li>

That's all.

Now you can access your CRUD like always:

  • <controller>/admin

  • <controller>/create

  • <controller>/index

  • view, delete, update, etc.

Additional documentation and links:

<li><a href="https://github.com/deeptowncitizen/MultilingualCrud" target="_blank">module repository</a>;</li>
<li><a href="http://www.yiiframework.com/doc/guide/1.1/en/topics.gii" target="_blank">Yii Automatic code generation</a>.</li>
<li><a href="http://all-of.me/yii-multilingual-crud/" target="_blank">Official website and free support</a>.</li>

3 0
7 followers
442 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Database
Developed by: deeptowncitizen
Created on: Jan 31, 2013
Last updated: 5 years ago

Downloads

show all

Related Extensions