<?php

namespace Smarty\Filter\Output;

/**
 * Smarty trimwhitespace outputfilter plugin
 * Trim unnecessary whitespace from HTML markup.
 *
 * @author Rodney Rehm
 *
 * @param string $source input string
 *
 * @return string filtered output
 */
class Lang implements \Smarty\Filter\FilterInterface {

	public function filter($code, \Smarty\Template $template) {
		$source = $code;
		return preg_replace_callback ('/##(.+?)##/', 'langstr', $source);
	}

	function langstr($treffer)
	{
		global $lang;
		return $lang->_($treffer[1]);
	}
}
