Hi, I want to change a couple of strings in the program/localization/en_GB/labels.inc file, e.g. $labels['trash'], but need to do it with a plugin to avoid having to customise on every roundcube update. I am familiar with how to write a plugin, but don't seem to be able to work out how to change the default $labels['trash'] string in a plugin. Any ideas would be very welcome!
That's an interesting question. I think you can do something like this:
class contextmenu extends rcube_plugin
{
public function init()
{
$this->merge_texts('localization/');
}
public function merge_texts($dir, $add2client = false)
{
$rcube = rcube::get_instance();
$texts = $rcube->read_localization(realpath(slashify($this->home) . $dir));
if (!empty($texts)) {
$merge = [];
foreach ($texts as $key => $value) {
$merge[$key] = $value;
}
$rcube->load_language($_SESSION['language'] ?? null, null, $merge);
// add labels to client
if ($add2client && method_exists($rcube->output, 'add_label')) {
if (is_array($add2client)) {
$js_labels = array_map([$this, 'label_map_callback'], $add2client);
} else {
$js_labels = array_keys($merge);
}
$rcube->output->add_label($js_labels);
}
}
}
}
assuming your texts are in a folder called localization and files use the regular Roundcube naming scheme. Essentially do the same thing as the native add_texts method but merge (and strip the domain) instead.
@JohnDoh You're an absolute superstar, thank you!! That worked perfectly - exactly what I needed.