#1534 (patch by severin.schols) Added support for sprintf(_t()) usage in template for translation

see http://code.google.com/p/google-highly-open-participation-silverstripe/issues/detail?id=29

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@46155 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2007-12-03 01:21:52 +00:00
parent 9c6a30d363
commit de30b37795

View File

@ -286,6 +286,10 @@ class SSViewer extends Object {
ereg('.*[\/](.*)',$template,$path);
$content = ereg_replace('<' . '% +_t\((\'([^\']*)\'|"([^"]*)")(([^)]|\)[^ ]|\) +[^% ])*)\) +%' . '>', '<?= _t(\''. $path[1] . '.\\2\\3\'\\4) ?>', $content);
// i18n - sprintf => "sprintf(_t(...),$argument)"
// CAUTION: No spaces allowed between arguments!
$content = ereg_replace('<' . '% +sprintf\(_t\((\'([^\']*)\'|"([^"]*)")(([^)]|\)[^ ]|\) +[^% ])*)\),\<\?= +([^\?]*) +\?\>) +%' . '>', '<?= sprintf(_t(\''. $path[1] . '.\\2\\3\'\\4),\\6) ?>', $content);
// </base> isnt valid html? !?
$content = ereg_replace('<' . '% +base_tag +%' . '>', '<base href="<?= Director::absoluteBaseURL(); ?>" />', $content);