This post is part of the sub-series on Internationalizing a ClassicPress plugin which is part of the Internationalizing a ClassicPress plugin series.
Over the previous posts I’ve discussed adding text domains and which functions are available to use, it’s time to look at a practical application.
To return a translated string we’d use the esc_html__
function with the string which can be localized as the first parameter and the text domain as the second:
$str = esc_html__('This is the string to translate', 'plugin-text-domain');
If we wanted to echo the translated string rather than return it, we’d use the esc_html_e
function:
esc_html_e('This is the string to translate', 'plugin-text-domain');
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.