Viewing File server/base/nats.lang.inc.php of 1.17.7a
|
1: <?php 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008-2010 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: class TNATS_Lang 24: { 25: var $items; 26: var $languages; 27: var $language; 28: var $baselanguage="en"; 29: 30: function GetLanguages() 31: { 32: global $BaseDir; 33: if ( !is_array($this->languages) ) 34: { 35: $pathlen=strlen($BaseDir."lang/"); 36: $this->languages=array(); 37: foreach(glob($BaseDir."lang/*.lang.php") as $langfile) 38: { 39: $langfile=substr($langfile,$pathlen); 40: $parts=explode(".",$langfile); 41: if (count($parts)==4) // valid language format Language.code.lang.php 42: { 43: $this->languages[$parts[1]]=$parts[0]; 44: } 45: } 46: } 47: return $this->languages; 48: } 49: 50: function Load($language="") 51: { 52: global $BaseDir,$NATS; 53: $this->GetLanguages(); 54: if ($language == "") $language=$this->baselanguage; 55: if ($language != $this->baselanguage) $this->Load($this->baselanguage); 56: if (!is_array($this->items)) $this->items=array(); 57: 58: if ( isset($this->languages[$language]) ) 59: { 60: $file=$BaseDir."lang/".$this->languages[$language].".".$language.".lang.php"; 61: if (file_exists($file)) 62: { 63: $lang=array(); 64: include_once($file); 65: $this->items = array_merge($this->items, $lang); 66: } 67: else $NATS->Event("Language file ".$file." not found",5,"Language","Load"); 68: } 69: else $NATS->Event("Illegal Language ".$language,5,"Language","Load"); 70: } 71: 72: function Item($item) 73: { 74: global $NATS; 75: //return "{".$item."}"; 76: if (isset($this->items[$item])) return $this->items[$item]; 77: else 78: { 79: $NATS->PageError("missing lang.element {ULE}",$item); 80: return "ULE{".$item."}"; 81: } 82: } 83: 84: } 85: 86: ?>