justb3a Posted May 18, 2015 Share Posted May 18, 2015 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? Link to comment Share on other sites More sharing options...
justb3a Posted May 21, 2015 Author Share Posted May 21, 2015 After a lot of testing I found the solution for my problem by myself. Comparing objects in a template leads to this behavior (it works using ProcessWire version 2.5.3): - <li class="nav-meta__item{% if language == user.language %} nav-meta__item--active{% endif %}"> + <li class="nav-meta__item{% if language.id == user.language.id %} nav-meta__item--active{% endif %}"> Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now