[Interest] Dynamic translation

Rainer Wiesenfarth Rainer_Wiesenfarth at Trimble.com
Mon Jul 27 10:00:53 CEST 2015


From: Graham Labdon
> My system maintains a system log which we require to be in English.
> Some of the strings used to log messages are also used to present
information
> to the user in the selected language

We had the same problem and solved it by implementing a special message
class that contains two QStrings, one translated, one original.  The
application then may decide which version of the message it needs. This
works, although creating a message looks awful:

  ICMessage( "Context", QT_TRANSLATE_NOOP( "Context", "EnglishMessage" ) );

The constructor uses code similar to

  m_original = text;
  m_localized = QCoreApplication::translate( context, text );

Unfortunately you cannot define a macro for the constructor QT_TRANSLATE
stuff, as lupdate would not find the strings :-(

Best Regards / Mit freundlichen Grüßen
Rainer Wiesenfarth

-- 
Software Engineer | Trimble Geospatial
Rotebühlstraße 81 | 70178 Stuttgart | Germany
Office +49 711 22881 0 | Fax +49 711 22881 11
http://www.trimble.com/geospatial/ | http://www.inpho.de/

Trimble Germany GmbH, Am Prime Parc 11, 65479 Raunheim
Eingetragen beim Amtsgericht Darmstadt unter HRB 83893,
Geschäftsführer: Dr. Frank Heimberg, Hans-Jürgen Gebauer 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6250 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150727/c9dc195d/attachment.bin>


More information about the Interest mailing list