October 5, 2011

Davita Davita
Lab Rat
49 posts

[Solved] specify different context to tr?


Hi guys

I have the following situation. I have 2 dialogs which share several texts. The problem I’m facing is that lupdate generates tr’s constant in different <context> element, so I’m obligated to do translation of single texts multiple times.

here’s how it looks the generated ts file.

  1. <context>
  2.     <name>GenericAlert</name>
  3.     <message>
  4.         <location filename="genericalert.cpp" line="81"/>
  5.         <source>CertVerified</source>
  6.     </message>
  7. </context>
  9. <context>
  10.     <name>ProcessStartAlert</name>
  11.     <message>
  12.         <location filename="processstartalert.cpp" line="66"/>
  13.         <location filename="processstartalert.cpp" line="86"/>
  14.         <source>CertVerified</source>
  15.     </message>
  16. </context>

Now I want to have single CertVerified for both dialogs. Is this possible at all?

Than you very much :)

2 replies

October 5, 2011

Volker Volker
Ant Farmer
5331 posts

The static QCoreApplication::translate() [doc.qt.nokia.com] methods could be of use in this case. You can explicitly set a context there.

October 5, 2011

Davita Davita
Lab Rat
49 posts

Thanks Volker, it worked :)

  ‹‹ QGLWidget in a plugin      QML ListElement with translation ››

You must log in to post a reply. Not a member yet? Register here!