2011-03-17, 02:33:20
The function(s) would be:
(the second function is a "private" function needed because the plugin's language file also sets $i18n).
BTW: it would be nice to have a function to determine if the plugin is included for the frontend or the admin backend, like:
Not sure, if this is the best way.
Code:
function i18n_merge($plugin, $language=null) {
global $i18n, $LANG;
return i18n_merge_impl($plugin, $language ? $language : $LANG, $i18n);
}
function i18n_merge_impl($plugin, $lang, &$globali18n) {
$i18n = array();
if (!file_exists(GSPLUGINPATH.$plugin.'/lang/'.$lang.'.php')) return false;
@include(GSPLUGINPATH.$plugin.'/lang/'.$lang.'.php');
if (count($i18n) > 0) foreach ($i18n as $code => $text) {
if (!array_key_exists($plugin.'/'.$code, $globali18n)) $globali18n[$plugin.'/'.$code] = $text;
}
return true;
}
(the second function is a "private" function needed because the plugin's language file also sets $i18n).
BTW: it would be nice to have a function to determine if the plugin is included for the frontend or the admin backend, like:
Code:
function is_admin() {
return basename($_SERVER['PHP_SELF']) != 'index.php';
}
Not sure, if this is the best way.