Quick Tip: Using the Mysteriously Named _e, _n and __ Functions
You might have met these functions during your WordPress career. These can be used for translating purposes. Here are some quick examples about using them.
Why Use Them?
The fact is WordPress can be used and translated into any languages of the world. If you want a webpage layout which can handle multiple languages you can do that with the default translating system built into WordPress. You don’t even have to write complex PHP code or a plugin for that. Just use these methods and make the appropriate language files.
Where to Use Them?
The places to use these functions are the PHP files of themes and plugins. For starters I recommend using them only in themes, but later on you can explore using them in plugins as well.
For translating texts WordPress uses the gettext translation framework. This data is stored in POT (Portable Object Template), PO (Portable Object) and MO (Machine Object) files. You can create these files with the Open Source poEdit and GNU gettext. The default language files for the WordPress interface are in the wp-content folder. More information can be read in the Translation article in the WordPress Codex.
_e is used for simple text while
_n can be used for the plural form of a word, you can even define different forms for different numbers of an object or thing.
If you are a PHP developer and may want to write a plugin or other useful thing related to your WordPress project you can use the
__ function, which returns the translated version of the given string. This returned string can be integrated in whatever WordPress code you want.
// return the translation of apple in a German sentence echo "Das ist ein " . __("apple") . "!";
So the main difference between
_e is that the latter one echoes the result to the webpage.
__ serves as the alias of the
translate() function. These functions can be found in wp-includes/l10n.php.
Reference pages for the functions here:
Original from: http://wp.tutsplus.com/articles/tips-articles/quick-tip-using-the-mysteriously-named-_e-_n-and-__-functions/