We want to disable the locale module in Drupal site. Because some content was saved as language 'en' previously, disabling locale does not reset content and field database tables language field to 'und' or LANGUAGE_NONE. After disabling the module any nodes or fields that have been saved as 'en' are not displayed.

to fix this I created a module to update the entire database.

    $schema = drupal_get_schema();

    foreach($schema as $table =>$structure){

     if(isset($structure['fields']) && isset($structure['fields']['language'])){


            ->fields(array('language' => 'und'))

This code does not update the language field and i'm not sure why. Is it because the language field is an index?

also this should be incorporated into the locale module uninstall function to avoid other sites breaking in future.

Any help is appreciated

Origional post -- https://drupal.org/node/2106247

  • Have you try to simply uninstall it?
    – Mołot
    Commented Oct 28, 2013 at 7:14

1 Answer 1


Here is what I did to solve this problem:

  1. Learn how to run scripts with Drush http://www.oliverdavies.uk/blog/dont-bootstrap-drupal-use-drush/
  2. Write this script:

    $query = new EntityFieldQuery();
    $query->entityCondition('entity_type', 'node')->addMetaData('account', user_load(1));
    $result = $query->execute();
    $nids = array_keys($result['node']);
    $n = count($nids);
    foreach($nids as $i => $nid) { // go through ALL nodes
      $node = node_load($nid); // load the node
      $type = $node->type; // get the content type
      $field_langs = field_language('node', $node); // get the language of each field
      foreach($field_langs as $field => $lang) { // go through ALL field of this node
        if ($lang != LANGUAGE_NONE) { // if the field is in the wrong language
          $items = field_get_items('node',$node,$field,$lang); // get all field values
          if (!empty($items)) {
            $node->{$field}[LANGUAGE_NONE] = $items; // put it under language neutral
            unset($node->{$field}[$lang]); // remove the old language
      $node->language = LANGUAGE_NONE; // set the node language to neutral
      node_save($node); // commit changes
      echo ("$i/$n\tnid=$nid\t$type\n"); // progress report
  3. Run it to translate every node on the site back to language neutral

I cannot guarantee that this works for nodes with fields that have values in more than one language at a time. Feel free to use and improve this code. I have tested this on my development site, and all seems fine after disabling & uninstalling locale. Let me know in the comments if this works for you, too!


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.