1 bootstrap.inc language_default()

Returns the default language used on the site.

Return value

A language object.:

File

core/includes/bootstrap.inc, line 3752
Functions that need to be loaded on every Backdrop request.

Code

function language_default() {
  $default = &backdrop_static(__FUNCTION__);

  if (!isset($default)) {
    try {
      $default_langcode = config_get('system.core', 'language_default');
    }
    catch (ConfigException $e) {
    }
    if (empty($default_langcode)) {
      $default_langcode = 'en';
    }

    if ($default_langcode !== 'en') {
      $languages = language_list();
      if (isset($languages[$default_langcode])) {
        $default = $languages[$default_langcode];
      }
      else {
        $default = (object) array(
          'langcode' => $default_langcode,
          'name' => 'Default',
          'direction' => 0,
          'enabled' => TRUE,
          'weight' => 0,
        );
      }
    }
    else {
      $default = (object) array(
        'langcode' => 'en',
        'name' => 'English',
        'direction' => 0,
        'enabled' => TRUE,
        'weight' => 0,
      );
    }
    $default->default = TRUE;
  }

  return $default;
}