Posted by mariano86 on November 21, 2008 at 1:33pm
Hello:
I have i18n module installed in Drupal 6. Using drupal_execute I have a created a lot of nodes with the info in a database.
I have also the translated data into the database. Therefore I like to create the "translation" of these nodes using the same system.
Here is the code:
<?php
$sql = "SELECT DISTINCT city, td.tid province, n.nid orig
FROM programs p
INNER JOIN node n ON n.title = p.city AND n.type = 'city'
INNER JOIN term_data td ON td.name = p.province AND td.vid = 1";
$res = db_query($sql);
while ($ob = db_fetch_object($res)) {
$node = array();
$node['type'] = 'city';
$form_state = array();
$form_state['values']['title'] = $ob->city;
$form_state['values']['taxonomy'] = array(1 => array($ob->province));
// For i18n
$form_state['values']['language'] = 'en';
$form_state['values']['translation_source'] = node_load($ob->orig);
$form_state['values']['op'] = t('Save');
$form_state['values']['name'] = 'admin';
drupal_execute('city_node_form', $form_state, (object)$node);
}
?>But this code doesn't create a translation of the node. Instead of that its create a new node with english language by default.
Any ideas?
Thanks
Mariano
Comments
A translation is a new node
Hi Mariano,
That seems to be the correct behavior.
from "Pro Drupal Development" (http://www.drupalbook.com), p. 437
hth
Frank
PS:
Some more related information:
Support for displaying translation sets
http://drupal.org/node/307032
Enable fields to be stored by translation set (tnid)
http://drupal.org/node/340355
Frank
My LinkedIn profile