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.
Based on your comment:
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'
:…should instead be:
Ensure that all of your translation string functions are declared accordingly.