From: Konrad Rosenbaum Date: Sun, 27 Sep 2015 17:04:44 +0000 (+0200) Subject: make web default language configurable X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=0dee8c3a9813944518595a534c9326cb85d9ab6f;p=web%2Fkonrad%2Fsmoke.git make web default language configurable --- diff --git a/www/config.php.template b/www/config.php.template index 7646ad9..438a792 100644 --- a/www/config.php.template +++ b/www/config.php.template @@ -84,6 +84,11 @@ $ClientSessionTimeout=2*3600; //Template directory $template="./template/"; +//set this if you want to set a default language +//it must exist as a directory inside the template directory +//if unset the pseudo-language "C" will be used +$default_language="en"; + //Renderer options $twigoptions = array( //cache points to: diff --git a/www/inc/classes/language_manager.php b/www/inc/classes/language_manager.php index 24fdf0f..65ed82d 100644 --- a/www/inc/classes/language_manager.php +++ b/www/inc/classes/language_manager.php @@ -1,8 +1,9 @@ +// | Copyright (C) 2007-8 by Peter keller +// | (c) 2010-15 Konrad Rosenbaum // +---------------------------------------------------------------------- // | // | Copyright: See COPYING file that comes with this distribution @@ -41,7 +42,6 @@ function string_format($string, $array) class LanguageManager { private static $instance=null;//will be instantiated by singleton() - private $lang="C";//fallback for unknown language, constructor overrides it private $config; private $templateFolder; private $formatcfg; @@ -101,7 +101,12 @@ class LanguageManager /** returns the instance of the Language Manager */ public static function singleton() { + global $default_language; if(self::$instance===null) { + //this may be set in config.php, otherwise use "C" + if(!isset($default_language)) + $default_language="C"; + //instantiate LM self::$instance = new LanguageManager(); } @@ -124,9 +129,10 @@ class LanguageManager /**returns the configured language template folder plus its fallback*/ public function templateFolders() { + global $default_language; $ret=array(); $ret[]=realpath($this->templateFolder()); - $ret[]=realpath($this->templateFolder."C/"); + $ret[]=realpath($this->templateFolder.$default_language."/"); return $ret; } diff --git a/www/inc/wext/format.php b/www/inc/wext/format.php index 9162031..b5f9a60 100644 --- a/www/inc/wext/format.php +++ b/www/inc/wext/format.php @@ -19,9 +19,10 @@ class WOServerFormat extends WOServerFormatAbstract // echo "Loading ".$lang."
"; $this->loadConfig($template."/".$lang."/format.cfg"); }else{ + global $default_language; //fall back to default language // echo "Loading C as fallback
"; - $this->loadConfig($template."/C/format.cfg"); + $this->loadConfig($template."/".$default_language."/format.cfg"); } //check timezone $tz=$this->gettimezone();