i18n support on node import

millette - June 6, 2008 - 15:47
Project:Node import
Version:5.x-1.6
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

I needed to import content in different languages, using i18n for multilingual content. This short patch is a single file to add i18n support.

AttachmentSize
i18n.inc_.gz0 bytes

#1

millette - June 6, 2008 - 15:54

First patch was empty, sorry.

Move the uncompressed file (upload didn't like the ".inc" extension, so I gzipped it) to node_import/supported/i18n.inc and you should now see a "I18N: Language code" field taking "en", "fr" and other supported language codes.

AttachmentSize
i18n.inc_.gz157 bytes

#2

samirjusic - June 14, 2008 - 16:12

I've tried the patch with 5.x-1.2 and 5.x-1.6 of node_import, but did not get the "I18N: Language code" field shown in any of the steps of the import process. Any ideas what might be missing, or what version would you recommend this with?

#3

Ozeuss - July 20, 2008 - 08:25

I added a few stuff:

<?php

/**
* Implementation of hook_node_import_fields().
*/
function i18n_node_import_fields($type) {
    return array(
      'language' => t('i18n: Language for node, supply iso code'),
    );
}

/**
* Implementation of hook_node_import_prepare().
*/
function i18n_node_import_prepare(&$node, $preview = FALSE) {
  $errors = array();
  $list= i18n_language_list();
    if (empty($node->language)){// || $node->language) {
      unset($node->language);
    }
}

/**
* Implementation of hook_node_import_global().
*/
function i18n_node_import_global($type, $global_values) {
  $list = i18n_language_list();
  $default= i18n_default_language();
  $form = array();
    $form['language'] = array(
      '#type' => 'select',
      '#title' => t('Language'),
      '#description' => t('Select the default values you want to assign to language fields unless specifically set otherwise in the CSV file'),
      '#options' => $list,
      '#default_value' => i18n_default_language()
    );
  return $form;
}

 
 

Drupal is a registered trademark of Dries Buytaert.