Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > a6711891ce757817bba854bf3f25205a > files > 2428

qtjambi-doc-4.3.3-3mdv2008.1.i586.rpm

<class name="QTranslator" doc="/**
&lt;p&gt;The &lt;a href=&quot;QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QTranslator&lt;/tt&gt;&lt;/a&gt; class provides internationalization support for text output.&lt;/p&gt;
&lt;p&gt;An object of this class contains a set of translations from a source language to a target language. &lt;a href=&quot;QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QTranslator&lt;/tt&gt;&lt;/a&gt; provides functions to look up translations in a translation file. Translation files are created using &lt;a href=&quot;%2E%2E/linguist-manual.html#qt-linguist&quot;&gt;Qt Linguist&lt;/tt&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The most common use of &lt;a href=&quot;QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QTranslator&lt;/tt&gt;&lt;/a&gt; is to: load a translation file, install it using QApplication::installTranslator(), and use it via QObject::tr(). Here's the &lt;tt&gt;main()&lt;/tt&gt; function from the Hello &lt;/tt&gt;tr() example:&lt;/p&gt;
&lt;pre&gt;    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);

        QTranslator translator;
        translator.load(&amp;quot;hellotr_la&amp;quot;);
        app.installTranslator(&amp;amp;translator);

        QPushButton hello(QPushButton::tr(&amp;quot;Hello world!&amp;quot;));
        hello.resize(100, 30);

        hello.show();
        return app.exec();
    }&lt;/pre&gt;
&lt;p&gt;Note that the translator must be created &lt;i&gt;before&lt;/i&gt; the application's widgets.&lt;/p&gt;
&lt;p&gt;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.&lt;/p&gt;
&lt;p&gt;It is possible to lookup a translation using translate() (as tr() and QApplication::translate() do). The translate() function takes up to three parameters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;i&gt;context&lt;/i&gt; - usually the class name for the tr() caller.&lt;/li&gt;
&lt;li&gt;The &lt;i&gt;source text&lt;/i&gt; - usually the argument to tr().&lt;/li&gt;
&lt;li&gt;The &lt;i&gt;comment&lt;/i&gt; - an optional comment that helps disambiguate different uses of the same text in the same context.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, the &amp;quot;Cancel&amp;quot; in a dialog might have &amp;quot;Anuluj&amp;quot; when the program runs in Polish (in this case the source text would be &amp;quot;Cancel&amp;quot;). The context would (normally) be the dialog's class name; there would normally be no comment, and the translated text would be &amp;quot;Anuluj&amp;quot;.&lt;/p&gt;
&lt;p&gt;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 &amp;quot;Activado&amp;quot; and &amp;quot;Activada&amp;quot; as translations for &amp;quot;Enabled&amp;quot;. In this case the source text would be &amp;quot;Enabled&amp;quot; in both cases, and the context would be the dialog's class name, but the two items would have disambiguating comments such as &amp;quot;two-sided printing&amp;quot; for one and &amp;quot;binding&amp;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.&lt;/p&gt;

@see &lt;tt&gt;QApplication::installTranslator&lt;/tt&gt;
@see &lt;tt&gt;QApplication::removeTranslator&lt;/tt&gt;
@see &lt;tt&gt;QObject::tr&lt;/tt&gt;
@see &lt;tt&gt;QApplication::translate&lt;/tt&gt;
@see &lt;a href=&quot;%2E%2E/qtjambi-i18n.html&quot;&gt;I18N Example&lt;/tt&gt;&lt;/a&gt;
@see Hello tr() Example&lt;/tt&gt;
@see Arrow Pad Example&lt;/tt&gt;
@see Troll Print Example&lt;/tt&gt; */">
    <method name="public QTranslator(com.trolltech.qt.core.QObject parent)" doc="/**
&lt;p&gt;Constructs an empty message file object with parent &lt;tt&gt;parent&lt;/tt&gt; that is not connected to any file.&lt;/p&gt;
 */"/>
    <method name="public QTranslator()" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QTranslator.html#QTranslator(com.trolltech.qt.core.QObject)&quot;&gt;&lt;tt&gt;QTranslator&lt;/tt&gt;&lt;/a&gt;(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="/**
&lt;p&gt;Loads &lt;tt&gt;filename&lt;/tt&gt; + &lt;tt&gt;suffix&lt;/tt&gt; (&amp;quot;.qm&amp;quot; if the &lt;tt&gt;suffix&lt;/tt&gt; is not specified), which may be an absolute file name or relative to &lt;tt&gt;directory&lt;/tt&gt;. Returns true if the translation is successfully loaded; otherwise returns false.&lt;/p&gt;
&lt;p&gt;The previous contents of this translator object are discarded.&lt;/p&gt;
&lt;p&gt;If the file name does not exist, other file names are tried in the following order:&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;File name without &lt;tt&gt;suffix&lt;/tt&gt; appended.&lt;/li&gt;
&lt;li&gt;File name with text after a character in &lt;tt&gt;search_delimiters&lt;/tt&gt; stripped (&amp;quot;_.&amp;quot; is the default for &lt;tt&gt;search_delimiters&lt;/tt&gt; if it is an empty string) and &lt;tt&gt;suffix&lt;/tt&gt;.&lt;/li&gt;
&lt;li&gt;File name stripped without &lt;tt&gt;suffix&lt;/tt&gt; appended.&lt;/li&gt;
&lt;li&gt;File name stripped further, etc.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;For example, an application running in the fr_CA locale (French-speaking Canada) might call load(&amp;quot;foo.fr_ca&amp;quot;, &amp;quot;/opt/foolib&amp;quot;). &lt;a href=&quot;QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)&quot;&gt;&lt;tt&gt;load&lt;/tt&gt;&lt;/a&gt; would then try to open the first existing readable file from this list:&lt;/p&gt;
&lt;ol type=&quot;1&quot;&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo.fr_ca.qm&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo.fr_ca&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo.fr.qm&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo.fr&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo.qm&lt;/tt&gt;&lt;/li&gt;
&lt;li&gt;&lt;tt&gt;/opt/foolib/foo&lt;/tt&gt;&lt;/li&gt;
&lt;/ol&gt;
 */"/>
    <method name="public final boolean load(java.lang.String filename, java.lang.String directory, java.lang.String search_delimiters)" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)&quot;&gt;load&lt;/tt&gt;&lt;/a&gt;(&lt;tt&gt;filename&lt;/tt&gt;, &lt;tt&gt;directory&lt;/tt&gt;, &lt;tt&gt;search_delimiters&lt;/tt&gt;, QString()). */"/>
    <method name="public final boolean load(java.lang.String filename, java.lang.String directory)" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)&quot;&gt;load&lt;/tt&gt;&lt;/a&gt;(&lt;tt&gt;filename&lt;/tt&gt;, &lt;tt&gt;directory&lt;/tt&gt;, QString(), QString()). */"/>
    <method name="public final boolean load(java.lang.String filename)" doc="/**
&lt;p&gt;Equivalent to &lt;a href=&quot;QTranslator.html#load(java.lang.String, java.lang.String, java.lang.String, java.lang.String)&quot;&gt;load&lt;/tt&gt;&lt;/a&gt;(&lt;tt&gt;filename&lt;/tt&gt;, QString(), QString(), QString()). */"/>
    <method name="public boolean isEmpty()" doc="/**
&lt;p&gt;Returns true if this translator is empty, otherwise returns false. This function works with stripped and unstripped translation files.&lt;/p&gt;
 */"/>
</class>