Inxentas Posted February 23, 2017 Share Posted February 23, 2017 I do not seem to be able to properly display translated text when the call to translate, using either __() or $this->_(), is put into an include. In my template file I have this statement: <?php include("inc/bku-block-footer.php"); ?> No matter what I do, the untranslated text is displayed in the frontend. I have tried several things already: Fiddled with $config->templateCompile = false in config.php as described here. Gave me additional options in the backend. None of these options seems to have any effect on the frontend. Fiddled with textdomains like described here. To no avail. Fiddled with template compilation in general, tried all options. No effects. Tried adding the ProcessWire namespace to my template file. Again, no effect on translations. It doesn't seem to matter, any call to the translation functions returns the untranslated, original value unless I place the call inside the template file. I must be missing something very obvious, anyone got an idea? Link to comment Share on other sites More sharing options...
Inxentas Posted February 23, 2017 Author Share Posted February 23, 2017 (edited) This is my template file bku-news-page.php: <?php namespace ProcessWire; ?> <!DOCTYPE html> <html> <?php include("inc/head.php"); ?> <body> <?php include("inc/bku-block-topbar.php"); ?> <?php include("inc/bku-block-menu.php"); ?> <?php include("inc/bku-block-newsitems.php"); ?> <?php include("inc/bku-block-footer.php"); ?> </body> </html> This is the relevant snippet of code from the include: <?php echo $this->_("Voor vragen of advies kunt u altijd contact met ons opnemen"); ?> Off course that sentence has been translated by selecting the specific include under Languages. It does not work, but when I do exactly the same using the template file itself, it works smoothly. Edited February 23, 2017 by Inxentas Link to comment Share on other sites More sharing options...
AndZyk Posted February 24, 2017 Share Posted February 24, 2017 Hello @Inxentas, you should include your files like this: <?php include("./inc/bku-block-footer.php"); ?> This should help. Found in this similar thread: Regards, Andreas 1 Link to comment Share on other sites More sharing options...
Inxentas Posted March 1, 2017 Author Share Posted March 1, 2017 Ah, thank you! That seems to be the last piece of the puzzle. The solution works for me as well. 1 Link to comment Share on other sites More sharing options...
uliverse Posted March 11, 2019 Share Posted March 11, 2019 (edited) This topic is a bit old already... but I have the same problem. Translated a string that appears in an include file (.inc), but the translated string is not showing up for the secondary language. I tried the above, but without success... OK... I found the problem. It had nothing to do with the include file. Instead of. $this->_("xyz") as shown in the docs I only used .__("xyz"). That worked. Edited March 11, 2019 by uliverse Link to comment Share on other sites More sharing options...
szabesz Posted March 11, 2019 Share Posted March 11, 2019 5 hours ago, uliverse said: $this->_("xyz") as shown in the docs I only used .__("xyz"). That worked. The former is for module context while the latter is for frontend template file context. Can you point to the part of the docs you are referring to? Link to comment Share on other sites More sharing options...
uliverse Posted March 13, 2019 Share Posted March 13, 2019 I found it here: https://processwire.com/docs/multi-language-support/code-i18n/#marking-strings-for-translation 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