To correctly implement i18n and l10n for your purpose you need first
to create the following MySQL tables:

Categories table:

CREATE TABLE `categories` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `created` INT(10) UNSIGNED NOT NULL,
    `updated` INT(10) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    KEY `created` (`created`),
    KEY `updated` (`updated`)
) ENGINE=MyISAM, DEFAULT CHARACTER SET UTF8;

Note that the `name` field is only virtual and should not be present
on table schema.

In case if you use TreeBehavior categories table should be like this:

CREATE TABLE `categories` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `parent_id` INT(10) UNSIGNED,
    `lft` INT(10) UNSIGNED NOT NULL,
    `rght` INT(10) UNSIGNED NOT NULL,
    `created` INT(10) UNSIGNED NOT NULL,
    `updated` INT(10) UNSIGNED NOT NULL,
    PRIMARY KEY (`id`),
    KEY `parent_id` (`parent_id`),
    KEY `lft` (`lft`),
    KEY `rght` (`rght`),
    KEY `created` (`created`),
    KEY `updated` (`updated`)
) ENGINE=MyISAM, DEFAULT CHARACTER SET UTF8;

And of course the i18n table:

CREATE TABLE `i18n` (
    `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
    `foreign_key` INT(10) UNSIGNED NOT NULL,
    `locale` VARCHAR(6)   NOT NULL,
    `model` VARCHAR(255) NOT NULL,
    `field` VARCHAR(255) NOT NULL,
    `content` MEDIUMTEXT,
    PRIMARY KEY (`id`),
    KEY `row_id` (`foreign_key`),
    KEY `locale` (`locale`),
    KEY `model` (`model`),
    KEY `field` (`field`)
) ENGINE=MyISAM, DEFAULT CHARACTER SET UTF8;

The php code for Category model is:

<?php

class Category extend AppModel {

    public $name = 'Category';

    public $actsAs = array(
        'Translate' => array(
            'name'
        )
    );

}

?>

To correctly save a category to database (english and german) the data
array should be like the following (title field value should be an
associative array with locales as keys and titles as values) :

$data = array(
    'Category' => array(
        'title' => array(
            'eng' => 'some english title',
            'ger' => 'some german title'
        )
    )
);

And under the controller use this to save the category:

$this->Category->save($data);

Hope this will help!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to