This post is part of the sub-series on Internationalizing a ClassicPress plugin which is part of the Internationalizing a ClassicPress plugin series.
When internationalizing a plugin, you should avoid including a URL in the translatable string.
While for ease it may be tempting to do this:
esc_html_e('Please visit <a href="https://development.azurecurve.co.uk/">azurecurve Development</a> for more details.','your-text-domain');
You should instead paramaterize it by doing this:
printf(esc_html__('Please visit %s for more details.', 'your-text-domain'), '<a href="'.esc_url('https://development.azurecurve.co.uk/').'">azurecurve Development</a>');
If you have a URL where you want the anchor text to be translated, you can do this:
printf(esc_html__('Please %sLogin or Register%s to leave a comment.', 'your-text-domain'), '<a href="'.esc_url('https://development.azurecurve.co.uk/login.php').'">', '</a>');
Using a printf
or sprintf
function will allow you to paramaterize the URL and prevent a translator from substituting your domain for a different one.
Translating a ClassicPress plugin
What should we write about next?
If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.