SF.net SVN: postfixadmin:[1176] trunk
Brought to you by:
christian_boltz,
gingerdog
From: <chr...@us...> - 2011-08-23 21:23:22
|
Revision: 1176 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=1176&view=rev Author: christian_boltz Date: 2011-08-23 21:23:16 +0000 (Tue, 23 Aug 2011) Log Message: ----------- config.inc.php: - new config option $CONF['language_hook'] Hook function to override or add translations to $PALANG. Example hook function included (commented out). common.php: - honor $CONF['language_hook'] scripts/postfixadmin-cli.php: - honor $CONF['language_hook'] - add TODO - language shouldn't be hardcoded to english This implements my feature request at http://sourceforge.net/tracker/?func=detail&aid=3292408&group_id=191583&atid=937967 Modified Paths: -------------- trunk/common.php trunk/config.inc.php trunk/scripts/postfixadmin-cli.php Modified: trunk/common.php =================================================================== --- trunk/common.php 2011-08-22 00:04:52 UTC (rev 1175) +++ trunk/common.php 2011-08-23 21:23:16 UTC (rev 1176) @@ -51,6 +51,11 @@ $_SESSION['lang'] = $language = check_language (); # TODO: storing the language only at login instead of calling check_language() on every page would save some processor cycles ;-) require_once("$incpath/languages/" . $_SESSION['lang'] . ".lang"); +if($CONF['language_hook'] != '' && function_exists($CONF['language_hook'])) { + $hook_func = $CONF['language_hook']; + $PALANG = $hook_func ($PALANG, $_SESSION['lang']); +} + /** * @param string $class * __autoload implementation, for use with spl_autoload_register(). Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2011-08-22 00:04:52 UTC (rev 1175) +++ trunk/config.inc.php 2011-08-23 21:23:16 UTC (rev 1176) @@ -38,6 +38,35 @@ // Language files are located in './languages', change as required.. $CONF['default_language'] = 'en'; +// Hook to override or add translations in $PALANG +// Set to the function name you want to use as hook function (see language_hook example function below) +$CONF['language_hook'] = ''; + +/* + language_hook example function + + Called if $CONF['language_hook'] == '<name_of_the_function>' + Allows to add or override $PALANG interface texts. + + Returns: modified $PALANG array +*/ +/* +function language_hook($PALANG, $language) { + switch ($language) { + case "de": + $PALANG['whatever'] = 'foo'; + break; + case "en": + $PALANG['whatever'] = 'bar'; + break; + default: + $PALANG['whatever'] = 'foobar'; + } + + return $PALANG; +} +*/ + // Database Config // mysql = MySQL 3.23 and 4.0, 4.1 or 5 // mysqli = MySQL 4.1+ Modified: trunk/scripts/postfixadmin-cli.php =================================================================== --- trunk/scripts/postfixadmin-cli.php 2011-08-22 00:04:52 UTC (rev 1175) +++ trunk/scripts/postfixadmin-cli.php 2011-08-23 21:23:16 UTC (rev 1176) @@ -215,7 +215,7 @@ PATH.'/config.inc.php', PATH.'/languages/language.php', PATH.'/functions.inc.php', - PATH.'/languages/en.lang', + PATH.'/languages/en.lang', # TODO: honor $CONF[default_language] and/or language from $_ENV CORE_INCLUDE_PATH.'/common.php', CORE_INCLUDE_PATH.'/inflector.php', ); @@ -230,6 +230,12 @@ Config::write($CONF); Lang::getInstance(); + + if($CONF['language_hook'] != '' && function_exists($CONF['language_hook'])) { + $hook_func = $CONF['language_hook']; + $PALANG = $hook_func ($PALANG, 'en'); # $includes is also hardcoded to 'en' - see TODO above + } + Lang::write($PALANG); return true; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |