I cannot programmatically create a node in anything other than en language.

My site has 3 languages:

  • en
  • fr
  • de

And the code for creating a node is:

define('DRUPAL_ROOT', ...); 
require_once DRUPAL_ROOT . 'includes/bootstrap.inc'; 

$node = new stdClass();
$node->type = "foobar";
$node->title = 'test title';
$node->uid = 1;
$node->language = 'fr'; // *** this doesn't seem to work

if ($node = node_submit($node)) {

No matter what I type in the $node->language = '...'; the result is always the same. The node is created in the English language. I confirm that via looking at admin/content.

I've even tried stuffing this variable with a proper language object which I got out of the enabled languages of my site:

$languages = language_list('enabled');
$lang = $languages[1]['de'];
$node->language = $lang;
  • 1
    As side note, node_submit() always returns the parameter passed to the function; there is no need to check the value returned from the function.
    – apaderno
    Jul 25, 2012 at 13:39

2 Answers 2


The behavior was an unfortunate side-effect of the admin_language module and the setting Force use of default language.

The "offending" code is at http://drupalcode.org/project/admin_language.git/blob/0167e36c45661502ee6907a5b2b7cad8538b19cf:/admin_language.module#l112

Disabling this options solves the issue.


Some of the hooks might not be firing, instead of node_save($node), try drupal_execute($form_id, $form_state)

That last link was bad... lullabot's should help:


doh... drupal 7. Looks like they have changed it to drupal_form_submit


  • Thanks for the answer. I've seen that sometimes people do suggest drupal_form_submit instead of node_save but I'd really like to know if and how this simple task (saving non English) can be achieved with node_save.
    – cherouvim
    Jul 25, 2012 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.