From e37959f4c05704b0d0e255589e5332a5b0865467 Mon Sep 17 00:00:00 2001 From: Christian Weber Date: Sat, 15 Sep 2007 00:39:29 +0000 Subject: @param $p['fallbacklanguage'] optional language to use for undefined texts (useful for partially translated projects) --- it_text.class | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'it_text.class') diff --git a/it_text.class b/it_text.class index e7b2533..0782a37 100644 --- a/it_text.class +++ b/it_text.class @@ -24,7 +24,8 @@ class it_text * Constructor * @param $p['cookiename'] optional cookie name (default: 'LANGUAGE') * @param $p['debug'] optional debug mode: display label of unknown texts, set to 'label' to always display labels instead of actual text - * @param $p['forcelanguage'] optional language to use instead of user's prefered language + * @param $p['fallbacklanguage'] optional language to use for undefined texts (useful for partially translated projects) + * @param $p['forcelanguage'] optional language to use instead of user's preferred language * @param $p['phpfile'] optional texts file, defaults to service's phpinclude/texts.php */ function it_text($p = null) @@ -107,14 +108,16 @@ function text($label, $raw = null, $language = null) if (isset($this->statictext[$label][$language])) return $this->statictext[$label][$language]; + elseif ($this->p['fallbacklanguage'] && isset($this->statictext[$label][$this->p['fallbacklanguage']])) + return $this->statictext[$label][$this->p['fallbacklanguage']]; if ($fh = fopen($GLOBALS['ULTRAHOME'] . "/log/text_log", "a")) { fputs($fh, date("Y-m-d H:i:s") . "\t" . $_SERVER['REQUEST_URI'] . "\t" . $label . "\t" . $language . "\t" . it::replace(array('auto_prepend\S+\s+'=>''), it_debug::backtrace()) . "\n"); - fclose($fh); + fclose($fh); } - return $this->p['debug'] ? "$label ($language)" : $this->statictext[$label][$this->language_failsafe]; + return $this->p['debug'] ? "$label ($language)" : ''; } -- cgit v1.2.3