Help welcome
biber2005
Code: Select all
{{!de}}German{{--}}{!en}}English{{--}}
Code: Select all
function smarty_multiling($msg) {
function strip_langs($msg) {
global $serendipity;
if (!preg_match('@{{@', $msg)) return $msg;
$language = $serendipity['lang'];
/* Handle escaping of {} chars. If someone is up for it,
they're welcome to try and find a better way. As it is,
this appears to work. */
$msg = str_replace('\{', chr(1), $msg);
$msg = str_replace('\}', chr(2), $msg);
// The explode actually makes sure that each latter array part will end on either the full string end or {{--}
$parts = explode('{{--}}', $msg);
$out = '';
// Iterate each subblock and inspect if its language matches.
foreach($parts AS $idx => $match) {
if (empty($match)) continue; // Last block part, skip it.
if (stristr($match, '{{!' . $serendipity['lang'] . '}}')) {
// Current language found. Keep the string, minus the {{!xx}} part.
$out .= preg_replace('@\{\{!' . $serendipity['lang'] . '\}\}@', '', $match);
} else {
// Current language not found. Remove everything after {{!xx}}.
$out .= preg_replace('@\{\{![^\}]+\}\}.+$@', '', $match);
}
}
$msg = $out;
/* Put back escaped {} chars */
$msg = str_replace(chr(1), '{', $msg);
$msg = str_replace(chr(2), '}', $msg);
return $msg;
}
}
$serendipity['smarty']->register_modifier('smarty_multiling', 'smarty_multiling')
Sure, everything superior to duplicate installations, especially if you want translated entries, the same users, a single RSS feed etc...Don Chambers wrote:Garvin - do you think any of those suggestions are superior to an independent installation for another language, and if so, why?