I use Twig as template engine and to enable string translation I wrote a litte helper function. In 2.5.x everything works well. Now I upgraded to 2.6.0 and got the following (strange) problem: Default language - everything works as expected. Second language - error (white page, stopped rendering output after first string translation) Error: Nesting level too deep - recursive dependency? Twig Helper function:
$function = new Twig_SimpleFunction("__", function ($text, $filename = '') {
if (!empty($filename) && $this->twig->getLoader()->exists($filename . '.twig')) {
$textdomain = $this->twig->getLoader()->getCacheKey($filename . '.twig');
return __($text, $textdomain);
}
});
The problem occurs in wire/core/LanguageFunctions.php. In line 26 the second parameter $textdomain is supposed to be a string.
* @param string $textdomain Textdomain for the text, may be class name, filename, or something made up by you. If ommitted, a debug backtrace will attempt to determine it automatically.
function __($text, $textdomain = null, $context = '') {
But wire/modules/LanguageSupport/LanguageSupport.module line 186 and 188 use the $this->_('string') function:
186: $this->wire('config')->dateFormat = $this->_('Y-m-d H:i:s');
188: $locale = $this->_('C');
This calls wire/core/Wire.php line 1094.
public function _($text) {
return __($text, $this);
}
$this is passed as second parameter / $textdomain (which should be a string). But $this is in this case an object(LanguageSupport).
Dirty workaround at this moment: remove translate ($this->_('string')) call in wire/modules/LanguageSupport/LanguageSupport.module and just pass string. Any ideas how to solve this without touching the core?