1

I'm currently editing some Wordpress auto-respond emails for an events website we're building and I'm having problems with formatting in PHP. I'm a bit of a PHP noob, so excuse me if this is a stupid question. I've been searching for about an hour an can't find a fix.

Here's the PHP string:

<h2><?php printf( __( 'Hello %s!', 'tp-event-auth' ), $user_name ); ?></h2>

This is displaying as "Hello,User" with no spaces - obviously there needs to be a space just after the comma - how can I achieve this?

If you need anymore info I'd be happy to supply.

scrowler
  • 24,273
  • 9
  • 60
  • 92
admhande
  • 11
  • 1
  • Well - it *should* output something like `Hello user!` not `Hello,User`. Are you sure this is the code causing the problem? I.e. if you change `Hello` to `Goodbye` does it end up in your email template? – scrowler Sep 14 '16 at 00:51
  • Just a guess, but the __() function is probably localization lookup of some sort. There's probably a different localization file somewhere. If so, you'll need to edit the English one and the other languages as well. – BJ Black Sep 14 '16 at 00:53
  • Confirmed. See https://codex.wordpress.org/I18n_for_WordPress_Developers – BJ Black Sep 14 '16 at 00:55
  • Annoyingly it seems that this is not actually the correct file / code (although our developers have pointed me here to edit the emails). – admhande Sep 14 '16 at 00:56
  • Thanks, BJ Black, I'll look further into it. Appreciate the help – admhande Sep 14 '16 at 00:57
  • Unfortunately it's not as simple as just editing the code here. Wordpress uses gettext, which means that after you translate it, you have to generate the translation files by the command line and upload these to the server. See also [this answer](http://stackoverflow.com/a/31176371/811240) in case it's any help (disclaimer: I wrote it). – Mike Sep 14 '16 at 01:02

0 Answers0