1

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:

/
include/
    ListCategoryPostsWidget.php
    lcp_widget_form.php
languages/
    es_ES.mo
    en_US.mo
plugin.php

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) {
    include('lcp_widget_form.php');
}

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.

3
  • Can we see the output code, to help diagnose the problem? Commented 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". Commented 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. Commented Oct 28, 2011 at 18:31

1 Answer 1

2

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.

4
  • Ooops, sorry I was wrong on the comments, I am using it the way I'm supposed to: _e("Category", 'list-category-posts') Commented Oct 28, 2011 at 18:38
  • That's why we need to see the actual code... :) Commented Oct 28, 2011 at 18:53
  • I added some more details on the question. Commented Oct 28, 2011 at 19:04
  • 1
    This is an old question but was just checking my account over here. i18n was finally added: wordpress.org/extend/plugins/list-category-posts/changelog, thanks Chip! :) Commented Feb 8, 2013 at 5:48

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.