You are here

function i18n_languages in Internationalization 5

Same name and namespace in other branches
  1. 5.3 i18n.module \i18n_languages()
  2. 5.2 i18n.module \i18n_languages()

Get locale languages plus i18n language settings

Parameters

$key: Data to be returned, defaults to 'active' 'active' => array of enabled languages with native name 'enabled' => array of enabled languages with english name 'name' => all languages defined in locale module with english name 'site_default' => code of default site language

9 calls to i18n_languages()
i18n_default_language in ./i18n.module
Returns default language
i18n_get_lang_prefix in ./i18n.module
Get language code from path.
i18n_get_links in ./i18n.module
Function i18n_get_links
i18n_language_list in ./i18n.module
Get localized language list, sort alphabetically
i18n_language_property in ./i18n.module
Get language properties

... See full list

3 string references to 'i18n_languages'
i18n_admin_manage_screen_submit in ./i18n.module
Save language settings in variable
i18n_admin_settings in ./i18n.module
Form builder function.
i18n_form_alter in ./i18n.module
Implementation of hook_form_alter

File

./i18n.module, line 397
Internationalization (i18n) module

Code

function i18n_languages($key = 'active') {
  static $languages;
  if (!$languages) {
    if ($languages = variable_get('i18n_languages', 0)) {
      foreach ($languages['name'] as $code => $name) {
        if ($languages['enabled'][$code]) {
          $languages['active'][$code] = $name;
        }
      }
    }
    else {

      // It is possible that languages are not initialized
      if (function_exists('locale_supported_languages')) {
        $languages = locale_supported_languages();
      }
      else {

        // Worst case scenario: locale module not loaded, for cached pages, at least this won't break everything
        unset($languages);

        // There's some PHP bug: http://www.zend.com/zend/week/week98.php
        $languages['name'] = array(
          'en' => 'English',
        );
      }
      $languages['site_default'] = key($languages['name']);
      $languages['active'] = $languages['name'];
      $languages['native'] = $languages['name'];
    }

    // Sort everything alphabetically
    asort($languages['name']);
    asort($languages['active']);
    asort($languages['native']);
  }
  return $key ? $languages[$key] : $languages;
}