I am adding i18n to the widget on List Category Posts. I've correctly created the pot file, and po and mo files for Spanish and English. All of the Strings are being displayed with _e() on the form file.

The directory structure is as follows:


There are other files, but these are the ones involved in translation. From my Widget class (ListCategoryPostsWidget.php) I'm using this to register the translation:

$translation_dir = '../languages';
load_plugin_textdomain( 'list-category-posts', null, $translation_dir );

And this is the code I'm using to include the form file in ListCategoryPostsWidget.php file:

/** @see WP_Widget::form */
function form($instance) {

Default language is English, so that works fine. But when I set WP_LANG to "es_ES" on my wp-config, I still see the text on the widget in English. Any ideas? EDIT: So, I'm adding some more code:

<p><label for="<?php echo $this->get_field_id('title'); ?>">
<?php _e("Title", 'list-category-posts')?></label>

This is how I'm using the _e function in lcp_widget_form.php.

  • Can we see the output code, to help diagnose the problem? Oct 28, 2011 at 18:20
  • Sure, which code? The html generated by the widget? That one just shows the Strings in the _e function for eg: _e("Category") displays "Category". Oct 28, 2011 at 18:29
  • Yes: the PHP code that generates the HTML output - specifically, the strings that get output. HINT: If you're using _e( "Category" ), you're doing it wrong, and that's why it's not working. Oct 28, 2011 at 18:31

1 Answer 1


Based on your comment:

The html generated by the widget? That one just shows the Strings in the _e function for eg: _e("Category") displays "Category"

I suspect that you've not configured your translation strings properly. You need to include the textdomain in every translation string function call, or else the strings will never get translated.

e.g. for your textdomain 'list-category-posts':

_e( 'Category' )

...should instead be:

_e( 'Category', 'list-category-posts' )

Ensure that all of your translation string functions are declared accordingly.


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.