Merge pull request #10588 from JMAConsulting/CRM-20793
[civicrm-core.git] / CRM / Core / I18n.php
index ca7706cd9d5caf7f5c428b7b35fc1df71ebef29f..9e20536dfe3854345203734dca639356d89a4872 100644 (file)
@@ -163,6 +163,14 @@ class CRM_Core_I18n {
     if (!$all) {
       $all = CRM_Contact_BAO_Contact::buildOptions('preferred_language');
 
+      // get labels
+      $rows = array();
+      $labels = array();
+      CRM_Core_OptionValue::getValues(array('name' => 'languages'), $rows);
+      foreach ($rows as $id => $row) {
+        $labels[$row['name']] = $row['label'];
+      }
+
       // check which ones are available; add them to $all if not there already
       $codes = array();
       if (is_dir(CRM_Core_I18n::getResourceDir()) && $dir = opendir(CRM_Core_I18n::getResourceDir())) {
@@ -170,7 +178,7 @@ class CRM_Core_I18n {
           if (preg_match('/^[a-z][a-z]_[A-Z][A-Z]$/', $filename)) {
             $codes[] = $filename;
             if (!isset($all[$filename])) {
-              $all[$filename] = $filename;
+              $all[$filename] = $labels[$filename];
             }
           }
         }
@@ -186,6 +194,8 @@ class CRM_Core_I18n {
           unset($all[$code]);
         }
       }
+
+      ksort($all);
     }
 
     if ($enabled === NULL) {