{"id":8155718,"date":"2016-09-07T16:39:49","date_gmt":"2016-09-07T16:39:49","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/translation-patch\/"},"modified":"2016-09-07T16:39:49","modified_gmt":"2016-09-07T16:39:49","slug":"translation-patch","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/translation-patch\/","title":{"rendered":"translation patch"},"content":{"rendered":"<p>Hi,<\/p>\n<p>I modified the code to allow translation (and edited french translation)<\/p>\n<p>You can apply following patch to allow translations in your code.<\/p>\n<p>Thanx in advance for new release with this patch \ud83d\ude09<\/p>\n<p>diff &#8211;git a\/safe-report-comments.php b\/safe-report-comments.php<br \/>\nindex 82fc30d..e6070b3 100644<br \/>\n&#8212; a\/safe-report-comments.php<br \/>\n+++ b\/safe-report-comments.php<br \/>\n@@ -10,10 +10,16 @@ Author: Thorsten Ott, Daniel Bachhuber, Automattic<br \/>\n Author URI: http:\/\/automattic.com<br \/>\n *\/<\/p>\n<p>+add_action( &#8216;init&#8217;, &#8216;safe_report_comments_load_textdomain&#8217; );<br \/>\n+function safe_report_comments_load_textdomain() {<br \/>\n+\tload_plugin_textdomain( &#8216;safe-report-comments&#8217;, false, dirname( plugin_basename( __FILE__ ) ) . &#8216;\/lang&#8217; );<br \/>\n+}<br \/>\n+<br \/>\n if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<\/p>\n<p> \tclass Safe_Report_Comments {<\/p>\n<p>+    private $_domain_name = &#8216;safe-report-comments&#8217;;<br \/>\n \t\tprivate $_plugin_prefix = &#8216;srcmnt&#8217;;<br \/>\n \t\tprivate $_admin_notices = array();<br \/>\n \t\tprivate $_nonce_key = &#8216;flag_comment_nonce&#8217;;<br \/>\n@@ -70,13 +76,13 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\tpublic function backend_init() {<br \/>\n \t\t\tdo_action( &#8216;safe_report_comments_backend_init&#8217; );<\/p>\n<p>&#8211;\t\t\tadd_settings_field( $this-&gt;_plugin_prefix . &#8216;_enabled&#8217;, __( &#8216;Allow comment flagging&#8217; ), array( $this, &#8216;comment_flag_enable&#8217; ), &#8216;discussion&#8217;, &#8216;default&#8217; );<br \/>\n+\t\t\tadd_settings_field( $this-&gt;_plugin_prefix . &#8216;_enabled&#8217;, __( &#8216;Allow comment flagging&#8217;, $this-&gt;_domain_name ), array( $this, &#8216;comment_flag_enable&#8217; ), &#8216;discussion&#8217;, &#8216;default&#8217; );<br \/>\n \t\t\tregister_setting( &#8216;discussion&#8217;, $this-&gt;_plugin_prefix . &#8216;_enabled&#8217; );<\/p>\n<p> \t\t\tif ( ! $this-&gt;is_enabled() )<br \/>\n \t\t\t\treturn;<\/p>\n<p>&#8211;\t\t\tadd_settings_field( $this-&gt;_plugin_prefix . &#8216;_threshold&#8217;, __( &#8216;Flagging threshold&#8217; ), array( $this, &#8216;comment_flag_threshold&#8217; ), &#8216;discussion&#8217;, &#8216;default&#8217; );<br \/>\n+\t\t\tadd_settings_field( $this-&gt;_plugin_prefix . &#8216;_threshold&#8217;, __( &#8216;Flagging threshold&#8217;, $this-&gt;_domain_name ), array( $this, &#8216;comment_flag_threshold&#8217; ), &#8216;discussion&#8217;, &#8216;default&#8217; );<br \/>\n \t\t\tregister_setting( &#8216;discussion&#8217;, $this-&gt;_plugin_prefix . &#8216;_threshold&#8217;, array( $this, &#8216;check_threshold&#8217; ) );<br \/>\n \t\t\tadd_filter(&#8216;manage_edit-comments_columns&#8217;, array( $this, &#8216;add_comment_reported_column&#8217; ) );<br \/>\n \t\t\tadd_action(&#8216;manage_comments_custom_column&#8217;, array( $this, &#8216;manage_comment_reported_column&#8217; ), 10, 2);<br \/>\n@@ -185,7 +191,7 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t\t?&gt;<br \/>\n \t\t\t&lt;label for=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_enabled&#8221;&gt;<br \/>\n \t\t\t\t&lt;input name=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_enabled&#8221; id=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_enabled&#8221; type=&#8221;checkbox&#8221; value=&#8221;1&#8243; &lt;?php if ( $enabled === true ) echo &#8216; checked=&#8221;checked&#8221;&#8216;; ?&gt; \/&gt;<br \/>\n&#8211;\t\t\t\t&lt;?php _e( &#8220;Allow your visitors to flag a comment as inappropriate.&#8221; ); ?&gt;<br \/>\n+\t\t\t\t&lt;?php _e( &#8220;Allow your visitors to flag a comment as inappropriate.&#8221;, $this-&gt;_domain_name ); ?&gt;<br \/>\n \t\t\t&lt;\/label&gt;<br \/>\n \t\t\t&lt;?php<br \/>\n \t\t}<br \/>\n@@ -198,7 +204,7 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t\t?&gt;<br \/>\n \t\t\t&lt;label for=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_threshold&#8221;&gt;<br \/>\n \t\t\t\t&lt;input size=&#8221;2&#8243; name=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_threshold&#8221; id=&#8221;&lt;?php echo $this-&gt;_plugin_prefix; ?&gt;_threshold&#8221; type=&#8221;text&#8221; value=&#8221;&lt;?php echo $threshold; ?&gt;&#8221; \/&gt;<br \/>\n&#8211;\t\t\t\t&lt;?php _e( &#8220;Amount of user reports needed to send a comment to moderation?&#8221; ); ?&gt;<br \/>\n+\t\t\t\t&lt;?php _e( &#8220;Amount of user reports needed to send a comment to moderation?&#8221;, $this-&gt;_domain_name ); ?&gt;<br \/>\n \t\t\t&lt;\/label&gt;<br \/>\n \t\t\t&lt;?php<br \/>\n \t\t}<br \/>\n@@ -353,9 +359,9 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t *\/<br \/>\n \t\tprivate function cond_die( $message ) {<br \/>\n \t\t\tif ( isset( $_REQUEST[&#8216;no_js&#8217;] ) &amp;&amp; true == (boolean) $_REQUEST[&#8216;no_js&#8217;] )<br \/>\n&#8211;\t\t\t\twp_die( __( $message ), &#8220;Safe Report Comments Notice&#8221;, array(&#8216;response&#8217; =&gt; 200 ) );<br \/>\n+\t\t\t\twp_die( $message, __( &#8220;Safe Report Comments Notice&#8221;, $this-&gt;_domain_name ), array(&#8216;response&#8217; =&gt; 200 ) );<br \/>\n \t\t\telse<br \/>\n&#8211;\t\t\t\tdie( __( $message ) );<br \/>\n+\t\t\t\tdie( $message );<br \/>\n \t\t}<\/p>\n<p> \t\t\/*<br \/>\n@@ -363,34 +369,38 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t *\/<br \/>\n \t\tpublic function flag_comment() {<br \/>\n \t\t\tif ( (int) $_REQUEST[ &#8216;comment_id&#8217; ] != $_REQUEST[ &#8216;comment_id&#8217; ] || empty( $_REQUEST[ &#8216;comment_id&#8217; ] ) )<br \/>\n&#8211;\t\t\t\t$this-&gt;cond_die( __( $this-&gt;invalid_values_message ) );<br \/>\n+\t\t\t\t\/\/$this-&gt;cond_die( __( $this-&gt;invalid_values_message ) );<br \/>\n+\t\t\t\t$this-&gt;cond_die( __( &#8216;Cheating huh? &lt;!&#8211; invalid values &#8211;&gt;&#8217;, $this-&gt;_domain_name ) );<\/p>\n<p> \t\t\t$comment_id = (int) $_REQUEST[ &#8216;comment_id&#8217; ];<br \/>\n \t\t\tif ( $this-&gt;already_flagged( $comment_id ) )<br \/>\n&#8211;\t\t\t\t$this-&gt;cond_die( __( $this-&gt;already_flagged_message ) );<br \/>\n+\t\t\t\t\/\/$this-&gt;cond_die( __( $this-&gt;already_flagged_message ) );<br \/>\n+\t\t\t\t$this-&gt;cond_die( __( &#8216;It seems you already reported this comment. &lt;!&#8211; already flagged &#8211;&gt;&#8217;, $this-&gt;_domain_name ) );<\/p>\n<p> \t\t\t$nonce = $_REQUEST[ &#8216;sc_nonce&#8217; ];<br \/>\n \t\t\t\/\/ checking if nonces help<br \/>\n \t\t\tif ( ! wp_verify_nonce( $nonce, $this-&gt;_plugin_prefix . &#8216;_&#8217; . $this-&gt;_nonce_key ) )<br \/>\n&#8211;\t\t\t\t$this-&gt;cond_die( __( $this-&gt;invalid_nonce_message ) );<br \/>\n+\t\t\t\t\/\/$this-&gt;cond_die( __( $this-&gt;invalid_nonce_message ) );<br \/>\n+\t\t\t\t$this-&gt;cond_die( __( &#8216;It seems you already reported this comment. &lt;!&#8211; nonce invalid &#8211;&gt;&#8217;, $this-&gt;_domain_name ) );<br \/>\n \t\t\telse {<br \/>\n \t\t\t\t$this-&gt;mark_flagged( $comment_id );<br \/>\n&#8211;\t\t\t\t$this-&gt;cond_die( __( $this-&gt;thank_you_message ) );<br \/>\n+\t\t\t\t\/\/$this-&gt;cond_die( __( $this-&gt;thank_you_message ) );<br \/>\n+\t\t\t\t$this-&gt;cond_die( __( &#8216;Thank you for your feedback. We will look into it.&#8217;, $this-&gt;_domain_name ) );<br \/>\n \t\t\t}<\/p>\n<p> \t\t}<\/p>\n<p>&#8211;\t\tpublic function print_flagging_link( $comment_id=&#8221;, $result_id=&#8221;, $text=&#8217;Report comment&#8217; ) {<br \/>\n&#8211;\t\t\techo $this-&gt;get_flagging_link( $comment_id=&#8221;, $result_id=&#8221;, $text=&#8217;Report comment&#8217; );<br \/>\n+\t\tpublic function print_flagging_link( $comment_id, $result_id ) {<br \/>\n+\t\t\techo $this-&gt;get_flagging_link( $comment_id, $result_id );<br \/>\n \t\t}<\/p>\n<p> \t\t\/*<br \/>\n \t\t * Output Link to report a comment<br \/>\n \t\t *\/<br \/>\n&#8211;\t\tpublic function get_flagging_link( $comment_id=&#8221;, $result_id=&#8221;, $text=&#8217;Report comment&#8217; ) {<br \/>\n+\t\tpublic function get_flagging_link( $comment_id=&#8221;, $result_id=&#8221; ) {<br \/>\n \t\t\tglobal $in_comment_loop;<br \/>\n \t\t\tif ( empty( $comment_id ) &amp;&amp; !$in_comment_loop ) {<br \/>\n&#8211;\t\t\t\treturn __( &#8216;Wrong usage of print_flagging_link().&#8217; );<br \/>\n+\t\t\t\treturn __( &#8216;Wrong usage of print_flagging_link().&#8217;, $this-&gt;_domain_name );<br \/>\n \t\t\t}<br \/>\n \t\t\tif ( empty( $comment_id ) ) {<br \/>\n \t\t\t\t$comment_id = get_comment_ID();<br \/>\n@@ -398,14 +408,15 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t\telse {<br \/>\n \t\t\t\t$comment_id = (int) $comment_id;<br \/>\n \t\t\t\tif ( !get_comment( $comment_id ) ) {<br \/>\n&#8211;\t\t\t\t\treturn __( &#8216;This comment does not exist.&#8217; );<br \/>\n+\t\t\t\t\treturn __( &#8216;This comment does not exist.&#8217;, $this-&gt;_domain_name );<br \/>\n \t\t\t\t}<br \/>\n \t\t\t}<br \/>\n \t\t\tif ( empty( $result_id ) )<br \/>\n \t\t\t\t$result_id = &#8216;safe-comments-result-&#8216; . $comment_id;<\/p>\n<p> \t\t\t$result_id = apply_filters( &#8216;safe_report_comments_result_id&#8217;, $result_id );<br \/>\n&#8211;\t\t\t$text = apply_filters( &#8216;safe_report_comments_flagging_link_text&#8217;, $text );<br \/>\n+      \/\/ use default translations to modify flagging_link_text, not a filter !<br \/>\n+\t\t\t\/\/$text = apply_filters( &#8216;safe_report_comments_flagging_link_text&#8217;, $text );<\/p>\n<p> \t\t\t$nonce = wp_create_nonce( $this-&gt;_plugin_prefix . &#8216;_&#8217; . $this-&gt;_nonce_key );<br \/>\n \t\t\t$params = array(<br \/>\n@@ -417,10 +428,11 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t\t);<\/p>\n<p> \t\t\tif ( $this-&gt;already_flagged( $comment_id ) )<br \/>\n&#8211;\t\t\t\treturn __( $this-&gt;already_flagged_note );<br \/>\n+\t\t\t\treturn __( &#8216;&lt;!&#8211; already flagged &#8211;&gt;&#8217;, $this-&gt;_domain_name );<br \/>\n+\t\t\t\t\/\/return __( $this-&gt;already_flagged_note );<\/p>\n<p> \t\t\treturn apply_filters( &#8216;safe_report_comments_flagging_link&#8217;, &#8216;<br \/>\n&#8211;\t\t\t&lt;span id=&#8221;&#8216; . $result_id . &#8216;&#8221;&gt;<a href=\"void(0);\">&#8216; . __( $text ) . &#8216;<\/a>&lt;\/span&gt;&#8217; );<br \/>\n+\t\t\t&lt;span id=&#8221;&#8216; . $result_id . &#8216;&#8221;&gt;<a href=\"void(0);\">_domain_name ) . &#8216;&#8221; onclick=&#8221;safe_report_comments_flag_comment( \\&#8221; . $comment_id . &#8216;\\&#8217;, \\&#8221; . $nonce . &#8216;\\&#8217;, \\&#8221; . $result_id . &#8216;\\&#8217;);&#8221;&gt;&#8217; . __( &#8216;Report comment&#8217;, $this-&gt;_domain_name ) . &#8216;<\/a>&lt;\/span&gt;&#8217; );<\/p>\n<p> \t\t}<br \/>\n@@ -442,7 +454,7 @@ if ( !class_exists( &#8220;Safe_Report_Comments&#8221; ) ) {<br \/>\n \t\t * Callback function to add the report counter to comments screen. Remove action manage_edit-comments_columns if not desired<br \/>\n \t\t *\/<br \/>\n \t\tpublic function add_comment_reported_column( $comment_columns ) {<br \/>\n&#8211;\t\t\t$comment_columns[&#8216;comment_reported&#8217;] = _x(&#8216;Reported&#8217;, &#8216;column name&#8217;);<br \/>\n+\t\t\t$comment_columns[&#8216;comment_reported&#8217;] = _x(&#8216;Reported&#8217;, &#8216;column name&#8217;, $this-&gt;_domain_name);<br \/>\n \t\t\treturn $comment_columns;<br \/>\n \t\t}<\/p>\n","protected":false},"template":"","class_list":["post-8155718","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8155718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8155718\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=8155718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}