bug-1280: Handle more different types of "languages":
authorFelix Dörre <felix@dogcraft.de>
Wed, 11 Jun 2014 15:04:12 +0000 (17:04 +0200)
committerFelix Dörre <felix@dogcraft.de>
Wed, 11 Jun 2014 15:09:15 +0000 (17:09 +0200)
- zh_CN => zh-cn (in various cases: ZH_cn, zh_cn, ...)
- de => de (what the current GUI produces)
- de_DE => de, en_AU => en, EN_AU => en  (what may be left in the database)
... and more creative upper/lower-cases

includes/lib/l10n.php
pages/wot/9.php

index 85b7aff..468562c 100644 (file)
@@ -64,7 +64,7 @@ class L10n {
         * 
         * @var array(string => string)
         */
-       private static $locales = array(
+       public static $locales = array(
                                "ar" => "ar_JO",
                                "bg" => "bg_BG",
                                "cs" => "cs_CZ",
index 94523f2..d04c4fa 100644 (file)
   <tr>
     <td class="DataTD"><?=_("Language")?>:</td>
     <?
-    $parts = explode("_", $userlang ,2);
-    $printlang = strtolower($parts[0]);
+       $parts = explode("_", $userlang ,2);
+       if(count($parts == 2)){
+               $printlang = array_search( strtolower($parts[0])."_".strtoupper($parts[1]), L10n::$locales);
+               if($printlang === false){
+                       $printlang = $parts[0];
+               }
+       }else{
+               $printlang = strtolower($parts[0]);
+       }
     ?>
     <td class="DataTD" align="left"><? printf(_("%s prefers to be contacted in %s"), sanitizeHTML($user['fname']), L10n::$translations[$printlang]) ?></td>
   </tr>