[RCD] Help with Plugin Translation

Brendan brendan at tucows.com
Wed Sep 28 19:43:50 CEST 2016


>>>>      My function is:
>>>> function action_pending(){
>>>>      global $color;
>>>>      $rcmail = rcmail::get_instance();
>>>>      //$rcmail->output->show_message('pending');
>>>>
>>>>      $plugin_tmdatools_tmdadir =
>>>> $rcmail->config->get('plugin_tmdatools_tmdadir');
>>>>      $plugin_tmdatools_tmdasettings =
>>>> $rcmail->config->get('plugin_tmdatools_tmdasettings');
>>>>      $show_num = $rcmail->config->get('plugin_tmdatools_showPageNum');
>>>>
>>>> }
>>> You can find your answer in the plugin API docs:
>>> https://github.com/roundcube/roundcubemail/wiki/Plugin-API#internationalization
>>>
>> i think he's running into an issue where $this doesn't have the context
>> he needs inside his sub.
>>
>> aureleo - what is calling action_pending()? an ajax request? some other
>> sub elsewhere?
>> _______________________________________________
>     Yes, it's an ajax resquest.
> 

and how did you register that ajax request with the php core of
roundcube? you need to use register_action to let it know (and then call
your function with $this initialized):

class myplugin rcube_plugin {
  public $task = 'mail';
  function init() {
    $this->add_texts('localization/', false);
    $this->register_action('plugin.myplugin_action',array($this,'myaction');
  }

  function myaction($args) {
    $rcmail = rcmail::get_instance();
    $string = $this->gettext('myplugin.string');
  }
}


then when you call http://whatever/?_task=mail&_action=plugin.myplugin
you should end up calling your myaction() function with $this
initialized to what you need.


More information about the dev mailing list