I created a my own theme, now I wish to make it translatable.

I made two files:


msgid "know_more"
msgstr "Vuoi saperne di più?"


msgid "know_more"
msgstr "Vuoi saperne di più?"

Then in the index theme file i wrote:

<h2><?php _e('know_more',''); ?></h2>

But when I run the site appears just: know_more


1 Answer 1


To do it properly, you need to generate a valid .mo file and load the text domain in your theme functions.php:

function wpse222346_localize_theme() {

    load_theme_textdomain( 'your_theme_domain', get_template_directory() . '/languages' );


add_action( 'after_setup_theme', 'wpse222346_localize_theme' );

You can check the WordPress Codex for more info on the load_theme_textdomain function: https://codex.wordpress.org/Function_Reference/load_theme_textdomain

Then you would call the translatable strings using your theme's text domain:

<h2><?php _e( 'know_more', 'your_theme_domain' ); ?></h2>

Also, it's strongly advised to use a tool for automating the creation of the POT files. It makes maintainability much easier. There are many options, such as Poedit, several online generators, makepot.php and even a very nice plugin to do it from the WordPress Dashboard called LocoTranslate. Most of them will also help you creating the .PO and .MO files.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.