Skip to content

TSvgIconImageCollection and Gettext ​

Gettext for Delphi has two procedures TranslateComponent and RetranslateComponent, which are called when a form is created and when the UI language changes. These procedures translate all string properties of all components on a form. Since each SVG Icon has a Name property, Gettext tries to translate the icon names for all icons in the collection, which is normally not what we want.

There are two possible solutions for this problem:

  1. Don't assign a name to your svg icon items. If they don't have a name, they won't be translated by accident.
  2. Add TP_GlobalIgnoreClass(...); instructions to your .dpr file before any forms are created or to the initialization section of any unit that is called before Gettext does it's magic. There are two alternatives:
  • This excludes all TSVGIconImageCollections and TVirtualImageLists from translation.
    pascal
    TP_GlobalIgnoreClass(TSVGIconImageCollection);
    TP_GlobalIgnoreClass(TVirtualImageList);
  • This excludes the ImageName property of all objects, since ImageName should not be translated in any component.
    pascal
    TP_GlobalIgnoreClassProperty(TObject,'ImageName');`

Choose whichever approach suits you best.

Limitations of the rendering engines ​

The Test Suite checks every engine against the same rules; the differences below come from the third-party libraries and are documented there as ignored tests.

SVGMagic ​

  • currentColor is not supported: it is always black, also when the SVG sets color="...". With a FixedColor the problem does not show, because the colors are replaced.
  • The stroke of a <rect> is drawn inside the rectangle instead of centered on its edge (<path> and <polygon> are right).
  • Markers (marker, marker-start, marker-mid, marker-end) and overflow are not supported.
  • A filter region mixing percent and pixel values is approximated.

Direct2D ​

  • <style> blocks, class attributes and <text> elements are not supported (define CheckForUnsupportedSvg to get an exception for them during debugging).
  • Blur and other filters are not supported.

Skia4Delphi ​

  • <style> blocks are not supported by Skia: they are converted into presentation attributes (InlineSvgStyle) before rendering. Only simple class selectors (.name) are converted; Source and SVGText always return the original text.

Released under Apache License, Version 2.0.