How to change Drupal's default language programmatically? I am trying to change the Drupal's default language programmatically  but haven't found the codes/function. Any suggestions?
Here is a corrected and tested version of the code posted by @Clive in a comment to the OP:

$langs = language_list(); // Note: No argument
// debug($langs, '$langs');
$langcode = 'en';
variable_set('language_default', $langs[$langcode]);


The code snippet above assumes that the two-character code that you assign to $langcode is enabled.  Uncomment the call to debug to see the languages that are enabled on your site and what array indices they use.

Note that the setting will not take effect until the next page load.