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


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1176 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 13 years ago
parent 1033c950fa
commit a5f3cb9b96

@ -51,6 +51,11 @@ require_once("$incpath/functions.inc.php");
$_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().

@ -38,6 +38,35 @@ $CONF['postfix_admin_url'] = '';
// 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+

@ -215,7 +215,7 @@ class PostfixAdmin {
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 @@ class PostfixAdmin {
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;

Loading…
Cancel
Save