If you’ve purchased a premium WordPress theme before you may have run across PHP code that contained a double underscore and wondered what it was doing. For example:
<!--?php next_posts_link( __( 'Older posts', 'the_themes_name' ) ); ?-->
You may have also seen the _e() function in action:
<!--?php _e(“Blog Archives”, “the_themes_name”); ?-->
The __() and _e() functions are localization functions, meaning they’re there so the theme can support multiple languages. They do this by passing the phrase in the first parameter, “Blog Archives” in the example above, to a function that looks up the translated phrase in the language that needs to be displayed.
The translated phrases are store in .mo and .po files found in the languages folder of your theme. Looking in the fr_FR.po file, which stores French translations, you may find the following:
#: archive.php msgid "Blog Archives" msgstr "Archives du site"
When one of the localization functions is called from the archive.php page, and passes in the “Blog Archives” phrase to be translated into French, the returned phrase will be “Archives du site”.
There’s obviously more to it than what I’ve explained above. If you’re interested in adding localization to your theme you can read more about it in the following articles: