[RCD] Help with Plugin Translation

Thomas Bruederli thomas at roundcube.net
Mon Sep 26 21:47:50 CEST 2016


On Thu, Sep 22, 2016 at 3:51 AM, Aurélio de Souza Ribeiro Neto
<netolistas at mpc.com.br> wrote:
> Hello Brendan,
>
>     Thanks for your answer!
>
>     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');
>
>
> ...
> ...
> ...
> }
>
>     I want to write a variable content from "lang.inc" on this function.
>
>     I don't know how! :(

You can find your answer in the plugin API docs:
https://github.com/roundcube/roundcubemail/wiki/Plugin-API#internationalization

Best,
Thomas

> Em 21/09/2016 17:33, Brendan escreveu:
>>
>> how is the sub function getting called? you may need to pass $this
>> through to it.. here's how that works with register_action:
>>
>> function init() {
>>    $this->load_config();
>>    $this->add_texts('localization/', true);
>>    $this->register_action('plugin.thing', array($this, 'thing'));
>> }
>>
>> function thing($args) {
>>    $rcmail = rcube::get_instance();
>>    $this->gettext('somelabel_from_my_lang.inc_file')
>> }
>>
>> On 16-09-21 01:27 PM, Aurélio de Souza Ribeiro Neto wrote:
>>>
>>> Hello Everyone,
>>>
>>>      I have a plugin, and I want to translate it based on
>>> localization/language.inc file.
>>>
>>>      In my plugin core PHP file I have this:
>>>
>>>      function init()
>>>      {
>>>          $this->load_config();
>>>          $this->add_texts('localization/', true);
>>>      }
>>>
>>>
>>>      If in a sub function I use
>>>
>>>      $this->gettext('somelabel_from_my_lang.inc_file')
>>>
>>>      I got this error   PHP Fatal error:  Using $this when not in object
>>> context
>>>
>>>      What I'm doing wrong?
>>>
>>>      Thanks
>>>
>>> Aurelio
>>>
>>>
>>> _______________________________________________
>>> Roundcube Development discussion mailing list
>>> dev at lists.roundcube.net
>>> http://lists.roundcube.net/mailman/listinfo/dev
>>
>> _______________________________________________
>> Roundcube Development discussion mailing list
>> dev at lists.roundcube.net
>> http://lists.roundcube.net/mailman/listinfo/dev
>>
>
>
> _______________________________________________
> Roundcube Development discussion mailing list
> dev at lists.roundcube.net
> http://lists.roundcube.net/mailman/listinfo/dev


More information about the dev mailing list