[RCD] Internationalization in JavaScript

Thomas Bruederli thomas at roundcube.net
Thu Sep 29 22:12:29 CEST 2016


On Wed, Sep 28, 2016 at 6:24 PM, Brendan <brendan at tucows.com> wrote:
>> I am using |rcmail.gettext('somelabel', 'plugin-name') to label
>> something within my java script file (as described in Wiki).
>> But my label is always 'somelabel' and not the translated text.
>> My plugin name has underscores in the name, but that should not matter?
>>
>> What am I doing wrong?
>
> you also need to pass through those strings to the javascript from the
> php backend. in the php bits you'd have these :
>
> // load in the language strings from plugindir/localization/
> $this->add_texts('localization/', false);
> // send the strings to the client
> $rcmail->output->add_label(['somelabel']);

Actually, $this->add_texts('localization/', true); does exactly that
in one go. The second argument set to true exports all texts to the
client.

~Thomas


More information about the dev mailing list