You are here

function drush_language_enable in Drush Language Commands 7

Enable a language.

File

./language.drush.inc, line 115
Drush commands allowing languages to be added, switched, enabled, disabled, imported, exported and update prefix from the commandline. This module only provides drush commands, so you will see no functionality in the UI.

Code

function drush_language_enable() {
  $args = func_get_args();
  if (count($args) == 0) {
    drush_set_error(dt('Please provide one or more language codes as arguments.'));
    return;
  }
  foreach ($args as $langcode) {
    $languages = language_list();
    if (array_key_exists($langcode, $languages)) {
      if (!$languages[$langcode]->enabled) {

        // disable the default english
        db_update('languages')
          ->condition('language', $langcode)
          ->fields(array(
          'enabled' => 1,
        ))
          ->execute();

        // Changing the language settings impacts the interface.
        cache_clear_all('*', 'cache_page', TRUE);
        drush_log(dt("Enabled language : !language ", array(
          '!language' => $langcode,
        )), 'ok');
      }
      else {
        drush_log(dt("Language already enabled: !language ", array(
          '!language' => $langcode,
        )), 'warning');
      }
    }
    else {
      drush_log(dt("Specified language does not exist !language", array(
        '!language' => $langcode,
      )), 'warning');
    }
  }
}