diff --git a/src/View/Helper/MelisSiteTranslationHelper.php b/src/View/Helper/MelisSiteTranslationHelper.php index f1be399..9eb5753 100644 --- a/src/View/Helper/MelisSiteTranslationHelper.php +++ b/src/View/Helper/MelisSiteTranslationHelper.php @@ -28,9 +28,10 @@ public function setServiceManager(ServiceManager $serviceManager) * @param string $key * @param int $langId * @param int $siteId + * @param boolean $isInAttribute - check if the translations is put inside an attribute like placeholder or title * @return string */ - public function __invoke($key, $langId, $siteId) + public function __invoke($key, $langId, $siteId, $isInAttribute = false) { $siteTransSrv = $this->serviceManager->get('MelisSiteTranslationService'); @@ -46,16 +47,24 @@ public function __invoke($key, $langId, $siteId) } $str = $cacheData[$langId][$key] ?? $key; - - if(!empty($this->getView()->renderMode)){ - if($this->getView()->renderMode != 'front'){ - $str = ''.$str.''; - } - }else{//try to check uri if we are in BO - $uri = $_SERVER['REQUEST_URI']; - $uri = explode('/', $uri); - if(in_array('renderMode', $uri)){ - $str = ''.$str.''; + /** + * We modify only the translation if we are not inside + * an attribute since html attribute don't accept + * html tag like span + */ + if(!$isInAttribute) { + if (!empty($this->getView()->renderMode)) { + if ($this->getView()->renderMode != 'front') { + //return translation with a span so they can see the key when they hover the text + $str = '' . $str . ''; + } + } else {//try to check uri if we are in BO + $uri = $_SERVER['REQUEST_URI']; + $uri = explode('/', $uri); + if (in_array('renderMode', $uri)) { + //return translation with a span so they can see the key when they hover the text + $str = '' . $str . ''; + } } }