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,

Hello world!

is wrapped in an appropriate translation function as follow

_e( 'Hello World!', 'my-theme-textdomain' );

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

Knowledgeable and skilled Technology Lead with an ability of software development and supervision. Possess a Bachelor of Science (BS) in Information Technology along with 10+ years of experience with hands-on coding and team management. By profession, I am a Software Engineer, Technology Mentor & Entrepreneur. Passionate about the technologies I use and always eager to share & learn more from that passion.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: