<class name="QTranslator" doc="/** <p>The <a href="QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)"><tt>QTranslator</tt></a> class provides internationalization support for text output.</p> <p>An object of this class contains a set of translations from a source language to a target language. <a href="QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)"><tt>QTranslator</tt></a> provides functions to look up translations in a translation file. Translation files are created using <a href="%2E%2E/linguist-manual.html#qt-linguist">Qt Linguist</tt></a>.</p> <p>The most common use of <a href="QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)"><tt>QTranslator</tt></a> is to: load a translation file, install it using QApplication::installTranslator(), and use it via QObject::tr(). Here's the <tt>main()</tt> function from the Hello </tt>tr() example:</p> <pre> int main(int argc, char *argv[]) { QApplication app(argc, argv); QTranslator translator; translator.load(&quot;hellotr_la&quot;); app.installTranslator(&amp;translator); QPushButton hello(QPushButton::tr(&quot;Hello world!&quot;)); hello.resize(100, 30); hello.show(); return app.exec(); }</pre> <p>Note that the translator must be created <i>before</i> the application's widgets.</p> <p>Most applications will never need to do anything else with this class. The other functions provided by this class are useful for applications that work on translator files.</p> <p>It is possible to lookup a translation using translate() (as tr() and QApplication::translate() do). The translate() function takes up to three parameters:</p> <ul> <li>The <i>context</i> - usually the class name for the tr() caller.</li> <li>The <i>source text</i> - usually the argument to tr().</li> <li>The <i>comment</i> - an optional comment that helps disambiguate different uses of the same text in the same context.</li> </ul> <p>For example, the &quot;Cancel&quot; in a dialog might have &quot;Anuluj&quot; when the program runs in Polish (in this case the source text would be &quot;Cancel&quot;). The context would (normally) be the dialog's class name; there would normally be no comment, and the translated text would be &quot;Anuluj&quot;.</p> <p>But it's not always so simple. The Spanish version of a printer dialog with settings for two-sided printing and binding would probably require both &quot;Activado&quot; and &quot;Activada&quot; as translations for &quot;Enabled&quot;. In this case the source text would be &quot;Enabled&quot; in both cases, and the context would be the dialog's class name, but the two items would have disambiguating comments such as &quot;two-sided printing&quot; for one and &quot;binding&quot; for the other. The comment enables the translator to choose the appropriate gender for the Spanish version, and enables Qt to distinguish between translations.</p> @see <tt>QApplication::installTranslator</tt> @see <tt>QApplication::removeTranslator</tt> @see <tt>QObject::tr</tt> @see <tt>QApplication::translate</tt> @see <a href="%2E%2E/qtjambi-i18n.html">I18N Example</tt></a> @see Hello tr() Example</tt> @see Arrow Pad Example</tt> @see Troll Print Example</tt> */"> <method name="public QTranslator(com.trolltech.qt.core.QObject parent)" doc="/** <p>Constructs an empty message file object with parent <tt>parent</tt> that is not connected to any file.</p> */"/> <method name="public QTranslator()" doc="/** <p>Equivalent to <a href="QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)"><tt>QTranslator</tt></a>(0). */"/> <method name="public final boolean load(java.lang.String filename, java.lang.String directory, java.lang.String search_delimiters, java.lang.String suffix)" doc="/** <p>Loads <tt>filename</tt> + <tt>suffix</tt> (&quot;.qm&quot; if the <tt>suffix</tt> is not specified), which may be an absolute file name or relative to <tt>directory</tt>. Returns true if the translation is successfully loaded; otherwise returns false.</p> <p>The previous contents of this translator object are discarded.</p> <p>If the file name does not exist, other file names are tried in the following order:</p> <ol type="1"> <li>File name without <tt>suffix</tt> appended.</li> <li>File name with text after a character in <tt>search_delimiters</tt> stripped (&quot;_.&quot; is the default for <tt>search_delimiters</tt> if it is an empty string) and <tt>suffix</tt>.</li> <li>File name stripped without <tt>suffix</tt> appended.</li> <li>File name stripped further, etc.</li> </ol> <p>For example, an application running in the fr_CA locale (French-speaking Canada) might call load(&quot;foo.fr_ca&quot;, &quot;/opt/foolib&quot;). <a href="QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)"><tt>load</tt></a> would then try to open the first existing readable file from this list:</p> <ol type="1"> <li><tt>/opt/foolib/foo.fr_ca.qm</tt></li> <li><tt>/opt/foolib/foo.fr_ca</tt></li> <li><tt>/opt/foolib/foo.fr.qm</tt></li> <li><tt>/opt/foolib/foo.fr</tt></li> <li><tt>/opt/foolib/foo.qm</tt></li> <li><tt>/opt/foolib/foo</tt></li> </ol> */"/> <method name="public final boolean load(java.lang.String filename, java.lang.String directory, java.lang.String search_delimiters)" doc="/** <p>Equivalent to <a href="QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)">load</tt></a>(<tt>filename</tt>, <tt>directory</tt>, <tt>search_delimiters</tt>, QString()). */"/> <method name="public final boolean load(java.lang.String filename, java.lang.String directory)" doc="/** <p>Equivalent to <a href="QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)">load</tt></a>(<tt>filename</tt>, <tt>directory</tt>, QString(), QString()). */"/> <method name="public final boolean load(java.lang.String filename)" doc="/** <p>Equivalent to <a href="QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)">load</tt></a>(<tt>filename</tt>, QString(), QString(), QString()). */"/> <method name="public boolean isEmpty()" doc="/** <p>Returns true if this translator is empty, otherwise returns false. This function works with stripped and unstripped translation files.</p> */"/> </class>