What is a WordPress Theme Text Domain ?

In this example ‘my-theme-textdomain’ is the defined as textdomain for the Theme. Text Domain is used to make the Theme translatable. (Codex reference: load_theme_textdomain()).

Define the Theme’s textdomain
load_theme_textdomain( 'my-theme-textdomain', TEMPLATEPATH.'/languages' );

Define translatable strings in the template.
This is done using one of a few translation functions: __() (for returned strings), _e() (for echoed strings), and _x()/_ex() (for gettext context strings).

A static text string, such as <p>Hello world!</p>, is wrapped in an appropriate translation function, such as <p><?php _e( 'Hello World!', 'my-theme-textdomain' ); ?></p>, to make it available for translation.

Generate the .mo/.po files
.mo stands for Machine Object — compiled export of the .po file which is used by WordPress
.po stands for Portable Object — editable text file with the translations strings

Nishant Vaity

I am a skilled self-taught PHP developer with years of experience writing scalable code for high-traffic websites. I am proficient in Linux, Apache, MySQL, PHP, HTML, JavaScript, CSS, Git, SVN, Vagrant, and SSH, among others. I am contributor for WordPress open source plugins and Translator (Marathi) for WordPress 4.5.x. I am passionate about the technologies I use and am always eager to share that passion and learn more.

Leave a Reply

Your email address will not be published. Required fields are marked *