From 1e35dc01cf94ba1ec4923b8f040e49b4dc399860 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 18 Jun 2004 16:23:14 +0000 Subject: finishing touches on genpopo, started playing with _real_ PHP code and svn keywords --- web/lib/translator.inc | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'web/lib/translator.inc') diff --git a/web/lib/translator.inc b/web/lib/translator.inc index 2d45f2a..79eb39c 100644 --- a/web/lib/translator.inc +++ b/web/lib/translator.inc @@ -24,20 +24,30 @@ include_once("common_po.inc"); function _($tag, $args=array()) { global $_t; + global $_REQUEST; global $LANG; - # default to English if the lang hasn't been provided + $supported_langs = array( + "en" => 1, # English + "es" => 1, # Español + "de" => 1, # Deutsch + "fr" => 1, # Français + ); + + # default to English if the lang hasn't been provided or isn't supported # - if (!$LANG) { - $lang = "en"; - } else { - $lang = $LANG; + $LANG = $_REQUEST['LANG']; + if (!$LANG || !array_key_exists($LANG, $supported_langs)) { + $LANG = "en"; } # create the translation, if it doesn't exist, highlight it # - $translated = $_t[$lang][$tag]; + $translated = $_t[$LANG][$tag]; if (!$translated) { + # if it's a supported language, but there isn't a translation, + # alert the visitor to the missing translation. + # $translated = "_" . $tag . "_"; } -- cgit v1.2.3-70-g09d2