Krlos Posted January 6, 2022 Share Posted January 6, 2022 Hi, I'm trying to use hanna code with translations but it gives me an error: Oh no… Fatal Error: Uncaught Error: Call to undefined function __() in site/assets/cache/HannaCode/guia_turistico_hanna.php I'm using: <?php echo __("Ver detalles"); ?> for translations output. Thanks in advance. Link to comment Share on other sites More sharing options...
Ivan Gretsky Posted January 6, 2022 Share Posted January 6, 2022 Did you define a ProcessWire namespace? Link to comment Share on other sites More sharing options...
Krlos Posted January 6, 2022 Author Share Posted January 6, 2022 3 minutes ago, Ivan Gretsky said: Did you define a ProcessWire namespace? Hi Ivan, yes, I have this on my Hanna code PHP <?php namespace ProcessWire; ?> <?php $alojamiento = $pages->find("template=alojamiento, limit=10"); foreach ($alojamiento as $a): ?> ... More HTML and PHP code <a><?php echo __("Ver detalle"); ?></a> the last part with the a tag is throwing the error. Link to comment Share on other sites More sharing options...
MarkE Posted January 6, 2022 Share Posted January 6, 2022 This might possibly be connected with an issue that I raised here https://github.com/ryancramerdesign/ProcessHannaCode/issues/26 and here but I haven’t received any response 2 Link to comment Share on other sites More sharing options...
Krlos Posted January 7, 2022 Author Share Posted January 7, 2022 7 hours ago, MarkE said: This might possibly be connected with an issue that I raised here https://github.com/ryancramerdesign/ProcessHannaCode/issues/26 and here but I haven’t received any response I think I will have to wait to fix this, I'm not php savy. Someone else might know a solution. Link to comment Share on other sites More sharing options...
MarkE Posted January 7, 2022 Share Posted January 7, 2022 The hack in the quoted post is quite simple @Krlos - you may wish to try it and see if it fixes your problem. If not, you can revert. Or you could just try \ProcessWire\_(“….”) 1 Link to comment Share on other sites More sharing options...
Krlos Posted January 7, 2022 Author Share Posted January 7, 2022 13 hours ago, MarkE said: The hack in the quoted post is quite simple @Krlos - you may wish to try it and see if it fixes your problem. If not, you can revert. Or you could just try \ProcessWire\_(“….”) Hi @MarkE, Thankyou for your help, I will try your suggestion. Where should I put that code you posted?, before every hanna code block? This: $php = '<' . '?php'; $openPHP = $php; $openPHPNS = "$php namespace ProcessWire;"; $firstLine = 'if(!defined("PROCESSWIRE")) die("no direct access");'; if(strpos($code, 'namespace') && preg_match('/(namespace\s+ProcessWire(?:;|\s*;))/', $code, $matches)) { $openPHP = $openPHPNS; $code = str_replace($matches[1], '', $code); } if(strpos($code, $openPHP) !== 0 && strpos($code, $php) !== 0) { // prepend open PHP tag to code if not already present $code = "$openPHPNS\n$firstLine\n$code"; } else { // otherwise insert our $firstLine security check $code = str_replace($php, "$openPHPNS\n$firstLine\n", $code); } I don't understand this code: \ProcessWire\_(“….”) Should I replace that for this? <?php namespace ProcessWire; ?> Thankyou Link to comment Share on other sites More sharing options...
MarkE Posted January 8, 2022 Share Posted January 8, 2022 I suggest you try the simple thing first: Replace <a><?php echo __("Ver detalle"); ?></a> by <a><?php echo \ProcessWire\__("Ver detalle"); ?></a> Let me know if that works - then I know we have the same namesapce issue as I have already reported 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