Ticket #1645 (closed enhancement: fixed)

Opened 3 years ago

Last modified 3 years ago

alt attribute of icons img tags is not translated.

Reported by: joseluis.rosa@iavante.es Assigned to: tracguest
Priority: P2 Milestone: CPS 3.4.3
Component: CPSPortlets Version: TRUNK
Severity: normal Keywords:
Cc:

Description

In PortletsTool?.py the methods renderIcon and renderActionIcon, return an img tag. The value of the alt attribute is not translated with Localizer which in case of actions icons can be very useful (in my use case I render actions without title).

I propose to replace this line:

img_tag = IMG_TAG % (base_url + icon_path,
                     getattr(img, 'width', 0),
                     getattr(img, 'height', 0),
                     alt)

with these:

language = self.translation_service.getSelectedLanguage()
alt_text = self.Localizer.default.gettext(alt, language) 
img_tag = IMG_TAG % (base_url + icon_path,
                     getattr(img, 'width', 0),
                     getattr(img, 'height', 0),
                     alt_text)

Please, let me know if there's a better solution for this.

Thank you.

Change History

05/19/06 17:22:35 changed by sfermigier

  • milestone changed from CPS 3.4.1 to CPS 3.4.3.

06/28/06 16:40:48 changed by joseluis.rosa@iavante.es

Even, the title attribute of the img tag could be set too.

IMG_TAG = '<img src="%s" width="%s" height="%s" alt="%s" title="%s"/>'
language = self.translation_service.getSelectedLanguage()
alt_text = self.Localizer.default.gettext(alt, language) 
img_tag = IMG_TAG % (base_url + icon_path,
                     getattr(img, 'width', 0),
                     getattr(img, 'height', 0),
                     alt_text, alt_text)

06/29/06 17:32:49 changed by joseluis.rosa@iavante.es

  • owner changed from jmorliaguet to tracguest.
  • status changed from new to assigned.

There's a little bug here:

alt_text = self.Localizer.default.gettext(alt, language) 

should be

alt_text = self.Localizer.default.gettext(str(alt), language) 

as alt sometimes is not a string, which is required so that it can be translated by message catalog.

11/17/06 11:58:35 changed by madarche

  • status changed from assigned to closed.
  • version changed from 3.4.0 to TRUNK.
  • resolution set to fixed.

Fixed by changeset [50095].

There is still a little cache problem : the alt and title don't get changed when the user change the portal language. This is strange since the Actions Portlet cache parameters include "current_lang".

If you have an idea and can contribute code you are welcome.