Soma Posted September 26, 2012 Share Posted September 26, 2012 Somehow on a page I use PW translations: echo __("Text string") it stopped working showing the alternative language. Before it was all ok. I updated the core to latest 2.2.9. No luck. Before I updated to 2.2.6 and there it seems it stopped working. I didn't recognize until now. The page is a formular: http://www.velokurie...ine-bestellung/ and you can cahnge to english using the link above the form. So only the formular is/should be translated (not the rest of the page). I didn't change anything so I'm a little lost as to why and how. Language is set like this: if($input->get->lang){ $lang = $sanitizer->pageName($input->get->lang); $langfield = "_en"; } else { $lang = 'default'; $langfield = ''; } $user->language = $languages->get($lang); Then in the formular the texts are outputed like this: <?php echo __("Vorname / Name")?> And it worked really well, until now. Any ideas? Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Ok if I drop in an older /wire core (2.2.2 as in footer) it works again with the translation, but the whole admin is broken then. Thanks. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted September 26, 2012 Share Posted September 26, 2012 2.2.5 seems to work fine with languages, as a site ( site not yet online ) is working fine with your language url module. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Thanks MG, I just uploaded PW 2.2.5 core, but it still same problem. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Just uploaded 2.2.4 and still the problem persists. Link to comment Share on other sites More sharing options...
apeisa Posted September 26, 2012 Share Posted September 26, 2012 Not sure if this is related, but strange behavior between latest and older version, see screenshots (this is page delete view in Finnish): 2.2.6: 2.2.9: Latest version shows page id instead of translated string. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Thanks apeisa for mentioning. That's something I also recognized in the latests versions... Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Ok, I tested on my local test install 2.2.9 and it works normally with translations in templates. But can't get it to work on that host. Only difference I know is php version. Locally PHP 5.2.9 and on the server where it doesn't work PHP 5.2.4. So, strange thing it works when I put in PW 2.2.2. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 I have no idea why it suddenly stoped working but found out if I add the language domain the text translation works. Like __("text",__FILE__); __("text"); simply stopped working for some reason I don't know. It would be great to not have to add __FILE__ to each text phrase. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 This seems related to what I already reported a while back with php 5.2.4 Link to comment Share on other sites More sharing options...
ryan Posted September 26, 2012 Share Posted September 26, 2012 Soma I don't have a 5.2.4 to test on, but if you try modifying that debug_backtrace does it also fix the issue? The issue with 2.2.9 showing the value rather than the label for a checkbox is unrelated -- I think I know what's causing it, it's related to some new features I recently added to the checkbox inputfield. Should be an easy fix. Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 I can't get it to work with modifying the debug_backtrace. Why does it not find the text domain and works in PW 2.2.2? Is that related to some other part? No matter what I do, it must be that __() function not finding the template file? Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Ok tried again and it works when I do: if(is_null($textdomain)) { $traces = @debug_backtrace(); ... Link to comment Share on other sites More sharing options...
ryan Posted September 26, 2012 Share Posted September 26, 2012 No idea why it would make any difference between 2.2.2 and now. There haven't been any changes to the stuff in question. For instance, the last change made to LanguageFunctions.php (where the __ function lives) was related to our previous thread, 4 months ago: https://github.com/ryancramerdesign/ProcessWire/blob/master/wire/core/LanguageFunctions.php The only thing I can figure at this point is PHP 5.2.4, which is known to have bugs. If you want to try and troubleshoot it a little more, try taking a look at what exactly the __() function is sending to the translator. So add this line: if($text == "whatever your text is") echo "<p>Textdomain: $textdomain</p>"; right before this: return htmlspecialchars($language->translator()->getTranslation($textdomain, $text, $context), ENT_QUOTES, 'UTF-8'); Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 Thanks Ryan. I get this Textdomain: site Edit: When I do it removing argument of the debug_backtrace() function I get: Textdomain: /var/www/web8/web/site/templates/views/order-form2.inc Link to comment Share on other sites More sharing options...
Soma Posted September 26, 2012 Author Share Posted September 26, 2012 The only way I can get it to work would be: if(is_null($textdomain)) { if(defined('DEBUG_BACKTRACE_IGNORE_ARGS')) $traces = @debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); else $traces = @debug_backtrace(); 1 Link to comment Share on other sites More sharing options...
ryan Posted September 28, 2012 Share Posted September 28, 2012 Thanks Soma, I'm making the same change here. 1 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