2025-06-20 19:10:23 +02:00
|
|
|
<?php
|
2025-06-22 22:26:19 +02:00
|
|
|
$module["lang"]["name"]="Language Class";
|
|
|
|
$module["lang"]["ver"]="0.1.2";
|
2025-06-20 19:10:23 +02:00
|
|
|
/**
|
2025-06-22 22:26:19 +02:00
|
|
|
* Project: BeCast WebEngine - simple site engine
|
|
|
|
* File: /inc/lang.class.php
|
2025-06-20 19:10:23 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
2025-06-22 22:26:19 +02:00
|
|
|
* @link http://www.becast.at
|
|
|
|
* @copyright 2009-2025 becast.at
|
2025-06-20 19:10:23 +02:00
|
|
|
* @author Bernhard Jaud <bernhard at becast dot at>
|
2025-06-22 22:26:19 +02:00
|
|
|
* @package BcWe core
|
2025-06-20 19:10:23 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
|
|
|
* @version $Id$
|
2025-06-22 22:26:19 +02:00
|
|
|
*/
|
|
|
|
|
2025-06-20 19:10:23 +02:00
|
|
|
|
|
|
|
class lang{
|
|
|
|
var $langname=array('de'=>'Deutsch','en'=>'English');
|
|
|
|
var $language;
|
|
|
|
var $languagedir;
|
2025-06-22 17:45:42 +02:00
|
|
|
var array $langdata;
|
2025-06-20 19:10:23 +02:00
|
|
|
|
|
|
|
function __construct($languagedir='/languages/'){
|
|
|
|
$this->languagedir = dirname(dirname(__FILE__)).'/languages/';
|
|
|
|
}
|
|
|
|
|
2025-06-22 17:45:42 +02:00
|
|
|
function setlang($language): void
|
|
|
|
{
|
|
|
|
global $config;
|
2025-06-20 19:10:23 +02:00
|
|
|
unset($this->language);
|
2025-06-22 17:45:42 +02:00
|
|
|
unset($this->langdata);
|
2025-06-20 19:10:23 +02:00
|
|
|
if(!$language || $language==''){
|
|
|
|
$language=$config['lang'];
|
|
|
|
if(!$language){
|
|
|
|
$this->language='en';
|
|
|
|
}else{
|
|
|
|
$this->language=$language;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$this->language=$language;
|
|
|
|
}
|
2025-06-22 17:45:42 +02:00
|
|
|
require_once $this->languagedir.$this->language.'.lang.php';
|
|
|
|
if (isset($lf)) {
|
|
|
|
$this->langdata = $lf;
|
|
|
|
}
|
2025-06-20 19:10:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getlanguages(){
|
|
|
|
$langdir = $this->languagedir;
|
|
|
|
$langs = opendir($langdir);
|
|
|
|
$i=0;
|
|
|
|
while ($lang = readdir($langs)) {
|
|
|
|
if (preg_match('/^.*?\.lang.php$/', $lang)) {
|
|
|
|
$langfile[$i]['short']=substr($lang,0,2);
|
|
|
|
$langfile[$i]['name']=$this->langname[$langfile[$i]['short']];
|
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@closedir($langs);
|
|
|
|
return($langfile);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _($string){
|
2025-06-22 17:45:42 +02:00
|
|
|
if(isset($this->langdata[$string])){
|
|
|
|
return($this->langdata[$string]);
|
2025-06-20 19:10:23 +02:00
|
|
|
}else{
|
|
|
|
return($string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|