lesterchan / wp-polls

Adds an AJAX poll system to your WordPress blog. You can also easily add a poll into your WordPress's blog post/page.
https://wordpress.org/plugins/wp-polls/
93 stars 78 forks source link

Bug: WP-Polls 2.72 with WordPress 4.4.1 do not load a language localization #64

Closed Celeron closed 8 years ago

Celeron commented 8 years ago

Please consider, I am not familiar with WordPress programming, so could be uncertain with terminology... But, I have found a bug with localization in "WP-Polls 2.72", and experimentally I have found a workaround.

Story: When I set up a Site on WordPress 4.4.1... I have installed a plugin WP-Polls 2.72... Then, I have downloaded translation (wp-polls-ru_RU.po and wp-polls-ru_RU.mo) from https://plugins.trac.wordpress.org/browser/wp-polls/i18n and put it to the plugin's folder (as pointed in instruction). Then, I have Activated the plugin... But, my language have not appeared in interface - It still in English!

I have checked many things, but nothing helps. BTW, I have noticed, that WordPress pick up the localization (since I see translated description on plugin's manage page). But, when the "WP-Polls" activated, it could not see own translation! So, I suspect a bug in code.

I have found a suspicious call to "load_plugin_textdomain" method in "wp-polls.php" on 39 line. https://github.com/lesterchan/wp-polls/blob/master/wp-polls.php#L39 There have used a reduced call form, with one parameter. Yes, normally, you could omit the second and third parameter in "load_plugin_textdomain" method https://codex.wordpress.org/Function_Reference/load_plugin_textdomain It must work... But, something goes wrong! I do not known "why". (Maybe bug in WordPress core? or wrong environment variables? BTW, have "plugin_dir_path()" set correctly?)

Experimentally, I have found this code repair an issue (it fix translation):

--- D:/Original/wp-polls/wp-polls.php   Вт дек 15 04:18:24 2015
+++ D:/Fixed/wp-polls/wp-polls.php  Ср янв 13 06:18:00 2016
@@ -36,7 +36,7 @@
 ### Create Text Domain For Translations
 add_action( 'plugins_loaded', 'polls_textdomain' );
 function polls_textdomain() {
-    load_plugin_textdomain( 'wp-polls' );
+    load_plugin_textdomain( 'wp-polls', '', dirname( plugin_basename( __FILE__ ) ) );
 }

Maybe safer to use a distinct call form? Consider to commit this to code.

lesterchan commented 8 years ago

Please see https://github.com/lesterchan/wp-polls/issues/63