What is difference between _e()
and __()
functions for the translation? In what cases e()
and __ ()
should be used?
-
For purposed of expanding, check this tutorial.– Pieter GoosenCommented Jun 5, 2014 at 8:40
-
1Additionally see: Codex: Translating Wordpress and Codex: I18n for WordPress Developers.– Nicolai GrossherrCommented Jun 5, 2014 at 9:28
Add a comment
|
1 Answer
If you want to echo
the translated string, then you will be using _e
and when you just want to have the translated string, then you will be using __
.
Example:
_e('this is a message', 'twentyfourteen');
is same as
echo __('this is a message', 'twentyfourteen');
-
Does
_e()
return the translated string, or just echo in place? For example, would$x = _e('1','2'); echo $x
echo the translated string twice? Would the first line run? Commented Mar 25, 2020 at 21:42 -
__('this is a message', 'twentyfourteen');
gives the translated string. Then it's upto you how you want to use that result. Commented Apr 11, 2020 at 18:49