language.inc 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Returns array of language names.
  4. *
  5. * This is a one to one copy of locale_language_list because we can't rely on enabled locale module.
  6. *
  7. * @param $field
  8. * 'name' => names in current language, localized
  9. * 'native' => native names
  10. * @param $all
  11. * Boolean to return all languages or only enabled ones
  12. *
  13. * @see locale_language_list
  14. */
  15. function ctools_language_list($field = 'name', $all = FALSE) {
  16. if ($all) {
  17. $languages = language_list();
  18. }
  19. else {
  20. $languages = language_list('enabled');
  21. $languages = $languages[1];
  22. }
  23. $list = array();
  24. foreach ($languages as $language) {
  25. $list[$language->language] = ($field == 'name') ? t($language->name) : $language->$field;
  26. }
  27. return $list;
  28. }
  29. /**
  30. * Returns an array of language names similar to ctools_language_list() except
  31. * that additional choices have been added for ease of use.
  32. */
  33. function ctools_language_list_all() {
  34. $languages = array(
  35. '***CURRENT_LANGUAGE***' => t("Current user's language"),
  36. '***DEFAULT_LANGUAGE***' => t("Default site language"),
  37. LANGUAGE_NONE => t('Language neutral'),
  38. );
  39. $languages = array_merge($languages, ctools_language_list());
  40. return $languages;
  41. }