From b00d5c383696dcbde5dd7d0e8cbd8601c6c3c226 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 18 Jan 2018 11:33:11 +0100 Subject: [PATCH] Automatically localize data-label-* attributes of a template object --- program/include/rcmail_output_html.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/program/include/rcmail_output_html.php b/program/include/rcmail_output_html.php index c5f5404c0..36a2a1d9d 100644 --- a/program/include/rcmail_output_html.php +++ b/program/include/rcmail_output_html.php @@ -1162,6 +1162,8 @@ EOF; // we are calling a class/method if (($handler = $this->object_handlers[$object]) && is_array($handler)) { if (is_callable($handler)) { + $this->prepare_object_attribs($attrib); + // We assume that objects with src attribute are internal (in most // cases this is a watermark frame). We need this to make sure assets_path // is added to the internal assets paths @@ -1171,6 +1173,7 @@ EOF; } // execute object handler function else if (function_exists($handler)) { + $this->prepare_object_attribs($attrib); $content = call_user_func($handler, $attrib); } else if ($object == 'doctype') { @@ -1296,6 +1299,21 @@ EOF; return ''; } + /** + * Prepares template object attributes + * + * @param array &$attribs Attributes + */ + protected function prepare_object_attribs(&$attribs) + { + // Localize data-label-* attributes + array_walk($attribs, function(&$value, $key, $rcube) { + if (strpos($key, 'data-label-') === 0) { + $value = $rcube->gettext($value); + } + }, $this->app); + } + /** * Include a specific file and return it's contents *