language.inc 1.2 KB

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