Disable locale module breaks site 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 =&gt;$structure){

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

           set_time_limit(0);

          db_update($table)
            -&gt;fields(array('language' =&gt; 'und'))
            -&gt;condition('language','en')
            -&gt;execute();
   }    
}


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
Here is what I did to solve this problem:


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

&lt;?php

$query = new EntityFieldQuery();
$query-&gt;entityCondition('entity_type', 'node')-&gt;addMetaData('account', user_load(1));
$result = $query-&gt;execute();
$nids = array_keys($result['node']);
$n = count($nids);

foreach($nids as $i =&gt; $nid) { // go through ALL nodes
  $node = node_load($nid); // load the node
  $type = $node-&gt;type; // get the content type
  $field_langs = field_language('node', $node); // get the language of each field
  foreach($field_langs as $field =&gt; $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-&gt;{$field}[LANGUAGE_NONE] = $items; // put it under language neutral
        unset($node-&gt;{$field}[$lang]); // remove the old language
      }
    }
  }
  $node-&gt;language = LANGUAGE_NONE; // set the node language to neutral
  node_save($node); // commit changes
  echo ("$i/$n\tnid=$nid\t$type\n"); // progress report
}

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 &amp; uninstalling locale. Let me know in the comments if this works for you, too!