Hello,

I have many problems with the translate behavior.
Here is my configuration.

At the top of bootstrap.php I have :

> Configure::write('Config.languages', array('eng', 'fra', 'ita'));
> Configure::write('Config.language', 'fra');


My model, a very simple Post model with id, title, content, created, 
modified :

class Post extends AppModel {
> public $displayField = 'title';
> public $actsAs = array(
> 'Translate' => array(
> 'title' => '_title',
> 'content' => '_content',
> )
> );
> public $validate = array(
> 'title' => array(
> 'notempty' => array(
> 'rule' => array('notempty'),
> 'message' => "Veuillez renseigner un titre",
> ),
> ),
> );
> }


An extract from my controler :

> public function admin_view($id = null) {
> if (!$this->Post->exists($id)) {
> throw new NotFoundException(__('Invalid post'));
> }
> $this->Post->id = $id;
> $this->set('post', $this->Post->read());
> }


And my view :

<h2><?php  echo __('Post'); ?></h2>
> <dl>
> <dt><?php echo __('Id'); ?></dt>
> <dd>
> <?php echo h($post['Post']['id']); ?>
> &nbsp;
> </dd>
> <dt><?php echo __('Title'); ?></dt>
> <dd>
> <?php echo h($post['Post']['title']); ?>
> &nbsp;
> </dd>
> <dt><?php echo __('Content'); ?></dt>
> <dd>
> <?php echo h($post['Post']['content']); ?>
> &nbsp;
> </dd>
> <dt><?php echo __('Created'); ?></dt>
> <dd>
> <?php echo h($post['Post']['created']); ?>
> &nbsp;
> </dd>
> <dt><?php echo __('Modified'); ?></dt>
> <dd>
> <?php echo h($post['Post']['modified']); ?>
> &nbsp;
> </dd>
> </dl>
> </div>


That's standard code mostly generated by bake.
An extract from my database :

CREATE TABLE `i18n` (
>   `id` int(10) NOT NULL AUTO_INCREMENT,
>   `locale` varchar(6) NOT NULL,
>   `model` varchar(255) NOT NULL,
>   `foreign_key` int(10) NOT NULL,
>   `field` varchar(255) NOT NULL,
>   `content` text,
>   PRIMARY KEY (`id`),
>   KEY `locale` (`locale`),
>   KEY `model` (`model`),
>   KEY `row_id` (`foreign_key`),
>   KEY `field` (`field`)
> ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
> INSERT INTO `i18n` VALUES(19, 'eng', 'Post', 4, 'title', 'en  title 4');
> INSERT INTO `i18n` VALUES(20, 'fra', 'Post', 4, 'title', 'fr titre 4');
> INSERT INTO `i18n` VALUES(21, 'ita', 'Post', 4, 'title', 'it titla 4');
> INSERT INTO `i18n` VALUES(22, 'eng', 'Post', 4, 'content', 'en content 4');
> INSERT INTO `i18n` VALUES(23, 'fra', 'Post', 4, 'content', 'fr contenu 4');
> INSERT INTO `i18n` VALUES(24, 'ita', 'Post', 4, 'content', 'it contena 4');
> CREATE TABLE `posts` (
>   `id` int(11) NOT NULL AUTO_INCREMENT,
>   `title` varchar(255) NOT NULL,
>   `content` text NOT NULL,
>   `created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE 
> CURRENT_TIMESTAMP,
>   `modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
>   PRIMARY KEY (`id`),
>   KEY `created` (`created`)
> ) ENGINE=InnoDB  DEFAULT CHARSET=utf8;
> INSERT INTO `posts` VALUES(4, 'en  title 4', 'en content 4', '0000-00-00 
> 00:00:00', '0000-00-00 00:00:00');



With this default configuration when I go to 
http://localhost/multilangues/admin/posts/view/4
The view displays :
Id4  Titre Contenu Créée le0000-00-00 00:00:00  Modifié0000-00-00 00:00:00  


Nothing for the title and the content.

If I modify my model like this :

public $actsAs = array(
> 'Translate' => array(
> 'title',
> 'content,
> )
> );


Then the display is "correct" :
Id4  Titrefr titre 4  Contenufr contenu 4  Créée le0000-00-00 00:00:00  
Modifié0000-00-00 00:00:00   

I have the title and the content.
But I will not have all the different translated values in the different 
locales to edit my post in all its languages...

Can someone help me please ?

Bye,
Hervé


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to