Plugin Author
Ajay
(@ajay)
Hi,
Can you modify your top-10.php file as follows and tell me if you still get this warning message?
Modify line 33 which has the load_textdomain call to this:
load_plugin_textdomain( TPTN_LOCAL_NAME, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
And modify line 36 to:
add_action('plugins_loaded', 'ald_tptn_init');
Yup, that worked… the warning message is not showed anymore.
Oh, BTW, now it shows all the languages availables on top 10 too
Plugin Author
Ajay
(@ajay)
That’s great news. I will implement this in the next version. Do you have a screenshot of this?
And, do you plan to update any language files?
Hi Ajay,
I can’t get my languages files to work. Updates of the .po/.mo files seem to have no effect whatsoever (I am using version 1.9.10.1 on a local development environment).
Best regards,
Benoît
———
Plugin Author
Ajay
(@ajay)
Do you notice this for any specific term or all terms?
Thanks for your prompt feedback.
Localization of static text is fine (plugin’s admin settings). It’s the dynamic strings which do not seem to work. For instance, the main title “Popular Posts” (between h3 tags) always displays in EN although properly translated in the .po/.mo files.
Plugin Author
Ajay
(@ajay)
The problem with the dynamic text is that it is translated only when setting the default options. After that it can no longer be translated.
But, you can always set this in the Settings pages, right? Or in the widget, if you’re using that?
You mean that translation is only working when the default options remain untouched? Even if the text chosen is in practice equal to the initial default value of the field?
I am actually working on a multilingual website with Qtranslate, but unfortunately, it seems that Qtranslate tags do not work if used within the Top-10 settings fields. I therefore need to proceed otherwise.
I’ll try and reset Top-10 settings to their default values and only change the non textual fields.
For the time being, the solution to my problem is to tweak the top-10.php file (comment-out line 391 and add replacement code at line 392):
//$output .= '<div id="tptn_related" class="tptn_posts ' . $widget_class . $shortcode_class . '">' . apply_filters( 'tptn_heading_title', $title );
$output .= '<div id="tptn_related" class="tptn_posts ' . $widget_class . $shortcode_class . '">' . __('<h3>Popular posts</h3>', TPTN_LOCAL_NAME);
Plugin Author
Ajay
(@ajay)
What I meant was that the static strings are recognised and can be translated easily into the .po/,mo file.
I am not familiar with QTranslate, but would it be possible to create your own function that would filter 'tptn_heading_title'
Will try that. This is clearly the right way to address the issue.
Clean solution:
1. Add following function to function.php + filter:
function qtranslate_filter( $text ) {
return __( $text ); }
add_filter( 'tptn_heading_title', 'qtranslate_filter', 10, 1);
2. Use Qtranslate multilingual tags in the title field of Top-10 output settings.
This way, Top-10 core code does not need to be altered.
Plugin Author
Ajay
(@ajay)
Thanks! This is indeed a better solution. Should help all users of QTranslate