I’m trying to translate WordPress website using gettext(). Documentation says this:
Use format strings instead of string concatenation —
sprintf(__('Replace %1$s with %2$s'), $a, $b);is always better than__('Replace').$a.__(' with ').$b;
I want to follow this advice but here comes the problem:
<?php _e('You must be', 'textdomain'); ?>
<a href="<?php bloginfo('url'); ?>/wp-login.php?redirect_to=<?php the_permalink(); ?>">
<?php _e('logged in', 'textdomain'); ?>
</a>
<?php _e('to post a comment.', 'textdomain'); ?>
This would either require some nested sprintf() or I would have to leave it like that – split into 3 strings (or at least 2). I’m not PHP expert, so if someone knows a way to get around this I would appreciate it.
1 Answer