0

I need to create a QString that contains html. I want to internationalize it... adding QObject::tr()

How can I combine it ? At this point, my string is like this... I don't think I can apply tr to he entire string, or I'd end up with odd words for colors, text, size...

const QString errorContent = QObject::tr("<!DOCTYPE html>\n"
                           "<svg height=\"100\" width=\"80\">\n"
                           "<text font-size=\"20\" x=\"10\" y=\"30\" fill=\"black\">Unable</text>\n"
                           "<text font-size=\"20\" x=\"10\" y=\"60\" fill=\"black\">to load</text>\n"
                           "<text font-size=\"20\" x=\"20\" y=\"90\" fill=\"black\">SVG</text>\n"
                           "Sorry, your browser does not support inline SVG.\n"
                           "\n</svg>");
Thalia
  • 13,637
  • 22
  • 96
  • 190

1 Answers1

0

You should be able to simply build the string from multiple QStrings where the tr() is only applied to the relevant part:

const QString errorContent = QString("<!DOCTYPE html>\n"
                       "<svg height=\"100\" width=\"80\">\n"
                       "<text font-size=\"20\" x=\"10\" y=\"30\" fill=\"black\">Unable</text>\n"
                       "<text font-size=\"20\" x=\"10\" y=\"60\" fill=\"black\">to load</text>\n"
                       "<text font-size=\"20\" x=\"20\" y=\"90\" fill=\"black\">SVG</text>\n")
                       + QObject::tr("Sorry, your browser does not support inline SVG")
                       + QString(".\n\n</svg>");
Bowdzone
  • 3,827
  • 11
  • 39
  • 52