[wp-meta] [Making WordPress.org] #3601: Wrong detection of localizable method in case of class

Making WordPress.org noreply at wordpress.org
Fri Jun 22 16:23:22 UTC 2018

#3601: Wrong detection of localizable method in case of class
 Reporter:  Mte90                     |       Owner:  (none)
     Type:  defect                    |      Status:  closed
 Priority:  normal                    |   Milestone:
Component:  Translate Site & Plugins  |  Resolution:  maybelater
 Keywords:  2nd-opinion               |

Comment (by MattDotNet):

 Hello everybody,

 This topic was opened after our company reported the issue to @Mte90 for
 the translations used by our plugins.
 We've followed what @ocean90 advised, and I built a possible patch for the
 `StringExtractor` class that resolves this issue. I would like you to
 review our proposal, hoping this will be helpful.

 I'm attaching a ZIP package containing the modified file extract.php (all
 the modifications can be found by searching for `@mod`) and a file with
 the correct results of the test made for our plugin VikBooking (see first

 My modification allows to ignore the translating functions that belong to
 classes which are out of context. For example:
 // the function _ is ignored as it's part of the Html class
 Html::_('checkbox', 1, false);

 Additionally, in case certain functions belonging to specific classes
 should not be ignored, maybe because they are part of the gettext
 framework, it is possible to pass them within the class constructor as a
 second optional argument. For example:
 $extractor = new StringExtractor($rules, ['Gettext', 'Translator']);


 // this code will be ignored
 // these lines of code will be added as new translation entries
 Gettext::_('This string can be translated');
 Translator::_('This string can be translated too');

 That's all. Hopefully someone will review our proposal.

 Please let us know your thoughts.

Ticket URL: <https://meta.trac.wordpress.org/ticket/3601#comment:5>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org

More information about the wp-meta mailing list