Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You might be able to use the <code>QT_TRANSLATE_NOOP</code> family of macros to do what you want. Those simply mark some text as "need to be translated" so that <code>lupdate</code> picks it up, but you can refer to those translated values by variable constants in your code. So ...</p> <pre><code>const char *kHelloWorld = QT_TRANSLATE_NOOP("SomeScope", "Hello world"); </code></pre> <p><em>Later...</em></p> <pre><code>return qApp-&gt;translate("SomeScope", kHelloWorld); </code></pre> <p>This is still in your source code somewhere, but it is at least one step removed. You could theoretically have the <code>QT_TRANSLATE_NOOP</code> stuff in an entirely different Qt project, but then you'd need <em>some</em> way in your real project to know what you are supposed to translate. (You still need the char* constants <em>somewhere</em>.) </p> <p>What are you trying to accomplish exactly by not having the English text in the source? That might help people provide more appropriate answers.</p> <p><strong>EDIT</strong></p> <p><em>Based on your comment below about intended usage</em></p> <p>OK, then this is precisely what the normal Qt translation process does. Running <code>lupdate</code> creates those XML files (they have a .ts extension). They can be opened by translators in the very-easy-to-use Qt Linguist. They are translated, then sent back to you (the programmer), where you run <code>lrelease</code> on them to create the binary translation files you will ship with the app. The translations are resolved <em>at runtime</em>, so there is no need to recompile.</p> <p>If you wanted to enable a user to do this, you would:</p> <ul> <li>Ship your application with an empty (untranslated) <code>.ts</code> file and the <code>lrelease</code> program.</li> <li>Provide instructions on how to use Qt Linguist to translate. (They could use a text editor and modify the Xml directly, but it's a lot easier with Linguist.)</li> <li>Explain how to run <code>lrelease</code> and where to drop the binary translation files so that your application pulls them in.</li> </ul> <p>On this last step, you could theoretically provide a nice wizard-like app that hides the implementation details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload