Przeglądaj źródła

Support for languages name localized

vbracco 16 lat temu
rodzic
commit
5b426eff0a
2 zmienionych plików z 140 dodań i 4 usunięć
  1. 3 3
      admin/settings.php
  2. 137 1
      classes/functions.php

+ 3 - 3
admin/settings.php Wyświetl plik

@@ -90,9 +90,9 @@ if ($user->isAdmin()) {
90 90
 										<select id="lang" name="lang">
91 91
 <?php									
92 92
 										$langs = getLangs();
93
-										foreach ($langs as $lang) {
94
-											$active = ($conf->lang==$lang) ? "selected" : "";
95
-											echo "<option value=\"".$lang."\" ".$active.">".$lang."</option>\n";
93
+										foreach ($langs as $key=>$lang) {
94
+											$active = ($conf->lang==$key) ? "selected" : "";
95
+											echo "<option value=\"".$key."\" ".$active.">".$lang."</option>\n";
96 96
 											
97 97
 										}
98 98
 ?>

+ 137 - 1
classes/functions.php Wyświetl plik

@@ -417,7 +417,7 @@ if(!defined('entry') || !entry) die('Not a valid page');
417 417
 							}
418 418
 							if (preg_match('|\.mo$|', $directory2)){
419 419
 								if(!in_array($directory2,$dirs)){
420
-									$dirs[$i]=trim($directory);
420
+									$dirs[$directory]=displayLanguage(trim($directory));
421 421
 									$i++;
422 422
 								}
423 423
 							}
@@ -510,4 +510,140 @@ if(!defined('entry') || !entry) die('Not a valid page');
510 510
 
511 511
 		return (strpos($string," ",$len))?substr_replace($string, "...", $len):$string;
512 512
 	}
513
+	
514
+	function displayLanguage($lang){
515
+		$out = "";
516
+		if(strpos($lang, '-')==2){
517
+			$lang = explode('-',$lang);
518
+		}
519
+		$language = is_array($lang)? $lang[0] : $lang;
520
+		switch($language){
521
+			case 'af': $out = __('Afrikaans'); break;
522
+			case 'sq': $out = __('Albanian'); break;
523
+			case 'ar': $out = __('Arabic'); break;
524
+			case 'eu': $out = __('Basque'); break;
525
+			case 'bg': $out = __('Bulgarian'); break;
526
+			case 'be': $out = __('Belarusian'); break;
527
+			case 'ca': $out = __('Catalan'); break;
528
+			case 'zh': $out = __('Chinese'); break;
529
+			case 'hr': $out = __('Croatian'); break;
530
+			case 'cs': $out = __('Czech'); break;
531
+			case 'da': $out = __('Danish'); break;
532
+			case 'nl': $out = __('Dutch'); break;
533
+			case 'en': $out = __('English'); break;
534
+			case 'et': $out = __('Estonian'); break;
535
+			case 'fo': $out = __('Faeroese'); break;
536
+			case 'fa': $out = __('Farsi'); break;
537
+			case 'fi': $out = __('Finnish'); break;
538
+			case 'fr': $out = __('French'); break;
539
+			case 'gd': $out = __('Gaelic'); break;
540
+			case 'de': $out = __('German'); break;
541
+			case 'el': $out = __('Greek'); break;
542
+			case 'he': $out = __('Hebrew'); break;
543
+			case 'hi': $out = __('Hindi'); break;
544
+			case 'hu': $out = __('Hungarian'); break;
545
+			case 'is': $out = __('Icelandic'); break;
546
+			case 'id': $out = __('Indonesian'); break;
547
+			case 'it': $out = __('Italian'); break;
548
+			case 'ja': $out = __('Japanese'); break;
549
+			case 'ko': $out = __('Korean'); break;
550
+			case 'lv': $out = __('Latvian'); break;
551
+			case 'lt': $out = __('Lithuanian'); break;
552
+			case 'mk': $out = __('Macedonian'); break;
553
+			case 'ms': $out = __('Malaysian'); break;
554
+			case 'mt': $out = __('Maltese'); break;
555
+			case 'no': $out = __('Norwegian'); break;
556
+			case 'pl': $out = __('Polish'); break;
557
+			case 'pt': $out = __('Portuguese'); break;
558
+			case 'rm': $out = __('Rhaeto-Romanic'); break;
559
+			case 'ro': $out = __('Romanian'); break;
560
+			case 'ru': $out = __('Russian'); break;
561
+			case 'sz': $out = __('Sami'); break;
562
+			case 'sr': $out = __('Serbian'); break;
563
+			case 'sk': $out = __('Slovak'); break;
564
+			case 'sl': $out = __('Slovenian'); break;
565
+			case 'sb': $out = __('Sorbian'); break;
566
+			case 'es': $out = __('Spanish'); break;
567
+			case 'sx': $out = __('Sutu'); break;
568
+			case 'sv': $out = __('Swedish'); break;
569
+			case 'th': $out = __('Thai'); break;
570
+			case 'ts': $out = __('Tsonga'); break;
571
+			case 'tn': $out = __('Tswana'); break;
572
+			case 'tr': $out = __('Turkish'); break;
573
+			case 'uk': $out = __('Ukrainian'); break;
574
+			case 'ur': $out = __('Urdu'); break;
575
+			case 've': $out = __('Venda'); break;
576
+			case 'vi': $out = __('Vietnamese'); break;
577
+			case 'xh': $out = __('Xhosa'); break;
578
+			case 'ji': $out = __('Yiddish'); break;
579
+			case 'zu': $out = __('Zulu'); break;
580
+			default: $out = $language;
581
+		}
582
+		if(is_array($lang)){
583
+			$country = strtolower($lang[1]);
584
+			switch($country){
585
+				//Aca una lista con los paises. No se como tendría que hacer para hacer insensible a mayusculas o minusculas: es-MX o es-mx ¿?
586
+				case 'sa': $out .= " (". __('Saudi Arabia'). ")"; break;
587
+				case 'iq': $out .= " (". __('Iraq'). ")"; break;
588
+				case 'eg': $out .= " (". __('Egypt'). ")"; break;
589
+				case 'ly': $out .= " (". __('Libya'). ")"; break;
590
+				case 'dz': $out .= " (". __('Algeria'). ")"; break;
591
+				case 'ma': $out .= " (". __('Morocco'). ")"; break;
592
+				case 'tn': $out .= " (". __('Tunisia'). ")"; break;
593
+				case 'om': $out .= " (". __('Oman'). ")"; break;
594
+				case 'ye': $out .= " (". __('Yemen'). ")"; break;
595
+				case 'sy': $out .= " (". __('Syria'). ")"; break;
596
+				case 'jo': $out .= " (". __('Jordan'). ")"; break;
597
+				case 'lb': $out .= " (". __('Lebanon'). ")"; break;
598
+				case 'kw': $out .= " (". __('Kuwait'). ")"; break;
599
+				case 'ae': $out .= " (". __('U.A.E.'). ")"; break;
600
+				case 'bh': $out .= " (". __('Bahrain'). ")"; break;
601
+				case 'qa': $out .= " (". __('Qatar'). ")"; break;
602
+				case 'tw': $out .= " (". __('Taiwan'). ")"; break;
603
+				case 'cn': $out .= " (". __('PRC'). ")"; break;
604
+				case 'hk': $out .= " (". __('Hong Kong SAR'). ")"; break;
605
+				case 'sg': $out .= " (". __('Singapore'). ")"; break;
606
+				case 'be': $out .= " (". __('Belgium'). ")"; break;
607
+				case 'us': $out .= " (". __('United States'). ")"; break;
608
+				case 'gb': $out .= " (". __('United Kingdom'). ")"; break;
609
+				case 'au': $out .= " (". __('Australia'). ")"; break;
610
+				case 'ca': $out .= " (". __('Canada'). ")"; break;
611
+				case 'nz': $out .= " (". __('New Zealand'). ")"; break;
612
+				case 'ie': $out .= " (". __('Ireland'). ")"; break;
613
+				case 'za': $out .= " (". __('South Africa'). ")"; break;
614
+				case 'jm': $out .= " (". __('Jamaica'). ")"; break;
615
+				case 'bz': $out .= " (". __('Belize'). ")"; break;
616
+				case 'tt': $out .= " (". __('Trinidad'). ")"; break;
617
+				case 'ch': $out .= " (". __('Switzerland'). ")"; break;
618
+				case 'lu': $out .= " (". __('Luxembourg'). ")"; break;
619
+				case 'at': $out .= " (". __('Austria'). ")"; break;
620
+				case 'li': $out .= " (". __('Liechtenstein'). ")"; break;
621
+				case 'br': $out .= " (". __('Brazil'). ")"; break;
622
+				case 'pt': $out .= " (". __('Portugal'). ")"; break;
623
+				case 'mo': $out .= " (". __('Republic of Moldova'). ")"; break;
624
+				case 'sz': $out .= " (". __('Lappish'). ")"; break;
625
+				case 'mx': $out .= " (". __('Mexico'). ")"; break;
626
+				case 'gt': $out .= " (". __('Guatemala'). ")"; break;
627
+				case 'cr': $out .= " (". __('Costa Rica'). ")"; break;
628
+				case 'pa': $out .= " (". __('Panama'). ")"; break;
629
+				case 'do': $out .= " (". __('Dominican Republic'). ")"; break;
630
+				case 've': $out .= " (". __('Venezuela'). ")"; break;
631
+				case 'co': $out .= " (". __('Colombia'). ")"; break;
632
+				case 'pe': $out .= " (". __('Peru'). ")"; break;
633
+				case 'ar': $out .= " (". __('Argentina'). ")"; break;
634
+				case 'ec': $out .= " (". __('Ecuador'). ")"; break;
635
+				case 'cl': $out .= " (". __('Chile'). ")"; break;
636
+				case 'uy': $out .= " (". __('Uruguay'). ")"; break;
637
+				case 'py': $out .= " (". __('Paraguay'). ")"; break;
638
+				case 'bo': $out .= " (". __('Bolivia'). ")"; break;
639
+				case 'sv': $out .= " (". __('El Salvador'). ")"; break;
640
+				case 'hn': $out .= " (". __('Honduras'). ")"; break;
641
+				case 'ni': $out .= " (". __('Nicaragua'). ")"; break;
642
+				case 'pr': $out .= " (". __('Puerto Rico'). ")"; break;
643
+				case 'fi': $out .= " (". __('Finland'). ")"; break;
644
+				default: $out .= "(".$country.")";
645
+			}
646
+		}
647
+		return $out;
648
+	}
513 649
 ?>