[med-svn] r662 - in trunk/community/website: . inc

hanska-guest at alioth.debian.org hanska-guest at alioth.debian.org
Sat Oct 6 16:47:06 UTC 2007


Author: hanska-guest
Date: 2007-10-06 16:47:06 +0000 (Sat, 06 Oct 2007)
New Revision: 662

Added:
   trunk/community/website/inc/locale.inc.php
Removed:
   trunk/community/website/inc/dynlocale.inc.php
   trunk/community/website/inc/locale.inc.php
Modified:
   trunk/community/website/index.php
Log:
The bug has been found. YEAH!
Now let's work on the add-locale script ;)


Deleted: trunk/community/website/inc/dynlocale.inc.php
===================================================================
--- trunk/community/website/inc/dynlocale.inc.php	2007-10-06 16:44:57 UTC (rev 661)
+++ trunk/community/website/inc/dynlocale.inc.php	2007-10-06 16:47:06 UTC (rev 662)
@@ -1,101 +0,0 @@
-<?php
-// _SERVER["HTTP_ACCEPT_LANGUAGE"] it-it,it;q=0.8,en-gb;q=0.6,en-us;q=0.4,en;q=0.2
-
-// this odd name is to avoid conflict with
-// po-stats.inc.php's clean()
-function __clean__($item) {
-	if (is_array($item)) {
-		if (!count($item))
-			$item = null;
-		else {
-			foreach ($item as $key => $value) {
-				$item[$key] = __clean__($value);
-				if (empty($item[$key]))
-					unset($item[$key]);
-			}
-		}
-	} else {
-		if (empty($item))
-			$item = null;
-	}
-	return $item;
-}
-
-$languages = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
-//$languages = "it-it,it;q=0.8,en-gb;q=0.6,en-us;q=0.4,en;q=0.2";
-$lang_arr = explode(",", $languages);
-$lang_arr[0] .= ";q=1.0";
-
-$def_locale = "en_US";
-$priority = "0.0";
-
-$i = 0;
-foreach ($lang_arr as $lang_code) {
-	$tmp[] = explode(";", $lang_code);
-	
-	// let's use the aa_BB format
-	preg_match("/([a-zA-Z]+)-([a-zA-Z]+)/", $tmp[$i][0], $matches);
-	$tmp[$i][0] = ($matches) ? strtolower($matches[1]) . "_" . strtoupper($matches[2]) : $tmp[$i][0];
-	$langs[str_replace("q=", "", $tmp[$i][1])] = $tmp[$i][0];
-	$i++;
-}
-
-// let's sort them by priority, highest first
-krsort($langs);
-
-$__debug = $_SERVER["PHP_SELF"];
-
-if ($fp = fopen("./inc/locales.txt", "r")) {
-//if ($fp = fopen("http://debian-med.alioth.debian.org/inc/locales.txt", "r")) {
-	while (!feof($fp)) {
-		$raw .= fgets($fp, 4096);
-	}
-	fclose($fp);
-} else {
-	die ("Please contact the site administrators: debian-med at lists.debian.org -- Cannot open locales.txt");
-}
-
-// let's remove comments and empty lines
-$raw = preg_replace("/^\\#.*\\n/m", "", $raw);
-$raw = preg_replace("/^[ ]*\\n/m", "", $raw);
-
-$tmp_installed = __clean__(explode("\n", $raw));
-foreach ($tmp_installed as $pair) {
-	$row = explode("\t", $pair);
-	$installed[$row[0]] = $row[1];
-}
-
-print_r($installed);
-
-foreach ($langs as $index => $language) {
-//	var_dump($language);
-//	var_dump($installed[$language]);
-	if ($installed[$language]) {
-		$locale = $installed[$language];
-		$priority = $index;
-		break;
-	} else {
-		$locale = $def_locale;
-	}
-}
-
-//var_dump($locale);
-
-// we'll use this in a <meta> tag in our header
-// and in the xml declaration.
-preg_match("/([a-z]+)_[A-Z]+/", $locale, $matches);
-$lang = $matches[1];
-
-if ($priority < "0.8") {
-	$show_locale_warning = true;
-}
-
-putenv("LC_ALL=$locale.UTF-8");
-putenv("LANG=$locale.UTF-8");
-putenv("LANGUAGE=$locale.UTF-8");
-setlocale(LC_ALL, "$locale.UTF-8");
-$domain = "messages";
-bindtextdomain($domain, "./locale");
-textdomain($domain);
-
-?>

Deleted: trunk/community/website/inc/locale.inc.php
===================================================================
--- trunk/community/website/inc/locale.inc.php	2007-10-06 16:44:57 UTC (rev 661)
+++ trunk/community/website/inc/locale.inc.php	2007-10-06 16:47:06 UTC (rev 662)
@@ -1,97 +0,0 @@
-<?php
-// _SERVER["HTTP_ACCEPT_LANGUAGE"] it-it,it;q=0.8,en-gb;q=0.6,en-us;q=0.4,en;q=0.2
-
-$languages = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
-$lang_arr = explode(",", $languages);
-$lang_arr[0] .= ";q=1.0";
-
-$locales_dir = "../locale/";
-
-$available = array(
-	"en" => true,
-		"en_US" => true, "en_GB" => true,
-		"en_AU" => true, "en_BW" => true,
-		"en_CA" => true, "en_DK" => true,
-		"en_HK" => true, "en_IE" => true,
-		"en_IN" => true, "en_NZ" => true,
-		"en_PH" => true, "en_SG" => true,
-		"en_ZA" => true, "en_ZW" => true,
-	"it" => true,
-		"it_IT" => true, "it_CH" => true,
-	"de" => true,
-		"de_DE" => true, "de_AT" => true,
-		"de_CH" => true, "de_LU" => true,
-		"de_BE" => true,
-	"fr" => true,
-		"fr_FR" => true, "fr_BE" => true,
-		"fr_CA" => true, "fr_CH" => true,
-		"fr_LU" => true,
-	);
-
-$i = 0;
-foreach ($lang_arr as $lang_code) {
-	$tmp[] = explode(";", $lang_code);
-	
-	// let's use the aa_BB format
-	preg_match("/([a-zA-Z]+)-([a-zA-Z]+)/", $tmp[$i][0], $matches);
-	$tmp[$i][0] = ($matches) ? strtolower($matches[1]) . "_" . strtoupper($matches[2]) : $tmp[$i][0];
-	$langs[str_replace("q=", "", $tmp[$i][1])] = $tmp[$i][0];
-	$i++;
-}
-
-// let's sort them by priority, highest first
-krsort($langs);
-
-$locale = "en_US";
-$priority = "0.0";
-
-foreach ($langs as $index => $language) {
-	if ($available[$language]) {
-		switch ($language) {
-			case "it":
-				case "it_IT": case "it_CH":
-					$locale = "it_IT"; break;
-			case "de":
-				case "de_DE": case "de_AT":
-				case "de_BE": case "de_CH":
-				case "de_LU":
-					$locale = "de_DE"; break;
-			case "fr":
-				case "fr_FR": case "fr_BE":
-				case "fr_CA": case "fr_CH":
-				case "fr_LU":
-					$locale = "fr_FR"; break;
-			case "en":
-				case "en_US": case "en_GB":
-				case "en_AU": case "en_BW":
-				case "en_CA": case "en_DK":
-				case "en_HK": case "en_IE":
-				case "en_IN": case "en_NZ":
-				case "en_PH": case "en_SG":
-				case "en_ZA": case "en_ZW":
-			default:
-					$locale = "en_US"; break;
-		}
-		$priority = $index;
-		break;
-	}
-}
-
-// we'll use this in a <meta> tag in our header
-// and in the xml declaration.
-preg_match("/([a-z]+)_[A-Z]+/", $locale, $matches);
-$lang = $matches[1];
-
-if ($priority < "0.8") {
-	$show_locale_warning = true;
-}
-
-putenv("LC_ALL=$locale.UTF-8");
-putenv("LANG=$locale.UTF-8");
-putenv("LANGUAGE=$locale.UTF-8");
-setlocale(LC_ALL, "$locale.UTF-8");
-$domain = "messages";
-bindtextdomain($domain, "./locale");
-textdomain($domain);
-
-?>

Copied: trunk/community/website/inc/locale.inc.php (from rev 661, trunk/community/website/inc/dynlocale.inc.php)
===================================================================
--- trunk/community/website/inc/locale.inc.php	                        (rev 0)
+++ trunk/community/website/inc/locale.inc.php	2007-10-06 16:47:06 UTC (rev 662)
@@ -0,0 +1,91 @@
+<?php
+// _SERVER["HTTP_ACCEPT_LANGUAGE"] it-it,it;q=0.8,en-gb;q=0.6,en-us;q=0.4,en;q=0.2
+
+// this odd name is to avoid conflict with
+// po-stats.inc.php's clean()
+function __clean__($item) {
+	if (is_array($item)) {
+		if (!count($item))
+			$item = null;
+		else {
+			foreach ($item as $key => $value) {
+				$item[$key] = __clean__($value);
+				if (empty($item[$key]))
+					unset($item[$key]);
+			}
+		}
+	} else {
+		if (empty($item))
+			$item = null;
+	}
+	return $item;
+}
+
+$languages = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
+$lang_arr = explode(",", $languages);
+$lang_arr[0] .= ";q=1.0";
+
+$def_locale = "en_US";
+$priority = "0.0";
+
+$i = 0;
+foreach ($lang_arr as $lang_code) {
+	$tmp[] = explode(";", $lang_code);
+	
+	// let's use the aa_BB format
+	preg_match("/([a-zA-Z]+)-([a-zA-Z]+)/", $tmp[$i][0], $matches);
+	$tmp[$i][0] = ($matches) ? strtolower($matches[1]) . "_" . strtoupper($matches[2]) : $tmp[$i][0];
+	$langs[str_replace("q=", "", $tmp[$i][1])] = $tmp[$i][0];
+	$i++;
+}
+
+// let's sort them by priority, highest first
+krsort($langs);
+
+if ($fp = fopen("./inc/locales.txt", "r")) {
+	while (!feof($fp)) {
+		$raw .= fgets($fp, 4096);
+	}
+	fclose($fp);
+} else {
+	die ("Please contact the site administrators: debian-med at lists.debian.org -- Cannot open locales.txt");
+}
+
+// let's remove comments and empty lines
+$raw = preg_replace("/^\\#.*\\n/m", "", $raw);
+$raw = preg_replace("/^[ ]*\\n/m", "", $raw);
+
+$tmp_installed = __clean__(explode("\n", $raw));
+foreach ($tmp_installed as $pair) {
+	$row = explode("\t", $pair);
+	$installed[$row[0]] = $row[1];
+}
+
+foreach ($langs as $index => $language) {
+	if ($installed[$language]) {
+		$locale = $installed[$language];
+		$priority = $index;
+		break;
+	} else {
+		$locale = $def_locale;
+	}
+}
+
+// we'll use this in a <meta> tag in our header
+// and in the xml declaration.
+preg_match("/([a-z]+)_[A-Z]+/", $locale, $matches);
+$lang = $matches[1];
+
+if ($priority < "0.8") {
+	$show_locale_warning = true;
+}
+
+putenv("LC_ALL=$locale.UTF-8");
+putenv("LANG=$locale.UTF-8");
+putenv("LANGUAGE=$locale.UTF-8");
+setlocale(LC_ALL, "$locale.UTF-8");
+$domain = "messages";
+bindtextdomain($domain, "./locale");
+textdomain($domain);
+
+?>

Modified: trunk/community/website/index.php
===================================================================
--- trunk/community/website/index.php	2007-10-06 16:44:57 UTC (rev 661)
+++ trunk/community/website/index.php	2007-10-06 16:47:06 UTC (rev 662)
@@ -13,8 +13,6 @@
 			</div>
 			<div class="row">
 				<?=_("The Debian-Med project presents packages that are associated with <ul><li>medicine</li><li>pre-clinical research</li><li>life science.</li></ul> Its developments are mostly focused on three areas for the moment: <ul><li>medical practice</li><li>imaging</li><li>bioinformatics.</li></ul>")?>
-				<br />
-				<?=$__debug?>
 			</div>
 		<?php
 			if ($show_locale_warning) {




More information about the debian-med-commit mailing list