I have my own theme that I've created and I need to support 3 languages. I started by adding the gettext functions to my template _e("string","namespace") etc, generated the po file with Poedit, and then created the .mo file for Spanish (es_ES)

My current setup which is not working > Update


define ('WPLANG', 'es_ES');  



function theme_init(){
    load_theme_textdomain( 'protoman', TPL_LANGUAGES);

add_action('init', 'theme_init');

languages mo file



      <li><a href="#"><?php _e('Home', 'protoman'); ?> </a></li>
      <li><a href="#"><?php _e('Account', 'protoman'); ?></a></li>
      <li><a href="#"><?php _e('Shop', 'protoman'); ?> </a></li>
      <li><a href="#"><?php _e('Corporate', 'protoman'); ?> </a></li>


  • Nevermind I figured it out. Im using the WPML plugin and I actually have to set the language in the plugin!
    – qodeninja
    May 17 '11 at 19:40

You need to load_theme_textdomain() in your theme.

Place this in theme functions file:

function theme_init(){
    load_theme_textdomain('theme_name', get_template_directory() . '/languages');
add_action ('init', 'theme_init');

Then you put you language files in you theme /languages folder

you language files should be es_ES.mo and es_ES.po without the text domain at the front as the codex states File names such as: my_theme-sv_SE.mo will NOT work.

  • Yeah I did all that =/ still not working...
    – qodeninja
    May 17 '11 at 17:22
  • Ive edited my answer please re-read. This should clarify things.
    – Scott
    May 17 '11 at 18:54
  • Thanks for that. I tried that approach too, and updated my question with my current setup. Is there something missing perhaps in the .mo file? Like some setting I need to set in poedit?
    – qodeninja
    May 17 '11 at 19:14
  • The .po file must be created with proper path options. Look at step 3 here
    – Lenin
    Jan 19 '13 at 15:57
  • Also, you wont have to init this load_theme_textdomain in the init action. Just call this function on your functions.php thats all.
    – Lenin
    Jan 19 '13 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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