On Jul 24, 12:09 am, Gorka <[EMAIL PROTECTED]> wrote:
> Actually, $form->input('TransName.eng.content') renders something like
> this for me:
>
> <input name="data[TransName][content]" type="text" value=""
> id="TransNameContent" />
>
> This is obviously not very useful when editing multiple languages at
> the same time (mostly in the admin area for defining name,
> description, etc... of an item). Has anyone found a method for editing
> multiple languages at the sameview?
>
Yes, I did find this out to. Not very useful.
> Oleonav, did you manage to get any closer to a satisfying solution?
>
No, I did not. Not in the cake 1.2 way for that matter. Maybe some of
the core developers would be so nice to contribute on this subject.
Anyway, I'm working on a different approach to i18n. It does not use a
'global' i18n & i18n_content table. It stores translations in the same
table as the main, default language.
For example a article table:
id
article_id
locale
...
title
content
For the main article, in the default language, the field id & article
id have the same value. Locale is set to the default locale string.
Translations have their own id. The article_id is the same as the id
of the main default record. Each translation has it's own locale
string. The combination of article_id & locale is defined as unique in
the database.
Model assoc's:
var $belongsTo = array(
'MotherArticle' => array('className' => 'Article',
'foreignKey' => 'article_id',
);
var $hasMany = array(
'ChildArticle' => array('className' => 'Article',
'foreignKey' => 'article_id'
);
I have added a function to the main AppModel to fetch the article in
the preferred translation if available.
function readTranslated($fields=null,$id,$lang=null){
$res = $this->read($fields,$id);
$childs = 'Child' . $this->name;
if($res && $lang && is_array($res[$childs])){
foreach($res[$childs] as $trans){
if($trans['locale'] == $lang){
$resTrans = $trans;
$resTrans['translated'] = 'yes';
}
}
}
if(isset($resTrans)){
$res[$this->name] = $resTrans;
}
elseif($res != null){
$res[$this->name]['translated'] = 'no';
}
return $res;
}
In the view action of the article controller I use the following
function $this->Article->readTranslated(null,$id,'eng') for example to
fetch the article in the prefered language, if available.
I'm now busy coding the add & edit actions. Having some trouble with
validation....
This is work in progress. I will share my thoughts / solution when I'm
satisfied
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---