⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qtranslator.html

📁 QT 下载资料仅供参考
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qtranslator.cpp:213 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QTranslator Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QTranslator Class Reference</h1><p>The QTranslator class provides internationalization support for textoutput.<a href="#details">More...</a><p><tt>#include &lt;<a href="qtranslator-h.html">qtranslator.h</a>&gt;</tt><p>Inherits <a href="qobject.html">QObject</a>.<p><a href="qtranslator-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QTranslator"><b>QTranslator</b></a> ( QObject&nbsp;*&nbsp;parent, const&nbsp;char&nbsp;*&nbsp;name = 0 )</div></li><li><div class=fn><a href="#~QTranslator"><b>~QTranslator</b></a> ()</div></li><li><div class=fn>QString find ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;comment = 0 ) const &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>virtual QTranslatorMessage <a href="#findMessage"><b>findMessage</b></a> ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;comment ) const</div></li><li><div class=fn>bool <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename, const&nbsp;QString&nbsp;&amp;&nbsp;directory = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;search_delimiters = QString::null, const&nbsp;QString&nbsp;&amp;&nbsp;suffix = QString::null )</div></li><li><div class=fn>void <a href="#clear"><b>clear</b></a> ()</div></li><li><div class=fn>enum <a href="#SaveMode-enum"><b>SaveMode</b></a> { Everything, Stripped }</div></li><li><div class=fn>bool <a href="#save"><b>save</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filename, SaveMode&nbsp;mode = Everything )</div></li><li><div class=fn>void <a href="#insert"><b>insert</b></a> ( const&nbsp;QTranslatorMessage&nbsp;&amp;&nbsp;message )</div></li><li><div class=fn>void insert ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;QString&nbsp;&amp;&nbsp;translation ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>void <a href="#remove"><b>remove</b></a> ( const&nbsp;QTranslatorMessage&nbsp;&amp;&nbsp;message )</div></li><li><div class=fn>void remove ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText ) &nbsp;<em>(obsolete)</em></div></li><li><div class=fn>bool <a href="#contains"><b>contains</b></a> ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;comment = 0 ) const</div></li><li><div class=fn>void <a href="#squeeze"><b>squeeze</b></a> ( SaveMode&nbsp;mode = Everything )</div></li><li><div class=fn>void <a href="#unsqueeze"><b>unsqueeze</b></a> ()</div></li><li><div class=fn>QValueList&lt;QTranslatorMessage&gt; <a href="#messages"><b>messages</b></a> () const</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2><p> The QTranslator class provides <a href="i18n.html#internationalization">internationalization</a> support for textoutput.<p> <p> An object of this class contains a set of <a href="qtranslatormessage.html">QTranslatorMessage</a>objects, each of which specifies a translation from a sourcelanguage to a target language. QTranslator provides functions tolook up translations, add new ones, remove them, load and savethem, etc.<p> The most common use of QTranslator is to: load a translator filecreated with <a href="linguist-manual.html">Qt Linguist</a>,install it using <a href="qapplication.html#installTranslator">QApplication::installTranslator</a>(), and use it via<a href="qobject.html#tr">QObject::tr</a>(). For example:<p> <pre>    int main( int argc, char ** argv )    {        <a href="qapplication.html">QApplication</a> app( argc, argv );        QTranslator translator( 0 );        translator.<a href="#load">load</a>( "french.qm", "." );        app.<a href="qapplication.html#installTranslator">installTranslator</a>( &amp;translator );        MyWidget m;        app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &amp;m );        m.show();        return app.<a href="qapplication.html#exec">exec</a>();    }    </pre> <p> Most applications will never need to do anything else with thisclass. The other functions provided by this class are useful forapplications that work on translator files.<p> We call a translation a "messsage". For this reason, translationfiles are sometimes referred to as "message files".<p> It is possible to lookup a translation using <a href="#findMessage">findMessage</a>() (as<a href="qobject.html#tr">tr</a>() and <a href="qapplication.html#translate">QApplication::translate</a>() do) and <a href="#contains">contains</a>(), to insert anew translation messsage using <a href="#insert">insert</a>(), and to remove one using<a href="#remove">remove</a>().<p> Translation tools often need more information than the bare sourcetext and translation, for example, context information to helpthe translator. But end-user programs that are using translationsusually only need lookup. To cater for these different needs,QTranslator can use stripped translator files that use the minimumof memory and which support little more functionality thanfindMessage().<p> Thus, <a href="#load">load</a>() may not load enough information to make anything morethan findMessage() work. <a href="#save">save</a>() has an argument indicatingwhether to save just this minimum of information or to saveeverything.<p> "Everything" means that for each translation item the followinginformation is kept:<p> <ul><li> The <em>translated text</em> - the return value from <a href="qobject.html#tr">tr</a>().<li> The input key:<ul><li> The <em>source text</em> - usually the argument to tr().<li> The <em>context</em> - usually the class name for the tr() caller.<li> The <em>comment</em> - a comment that helps disambiguate different usesof the same text in the same context.</ul></ul><p> The minimum for each item is just the information necessary for<a href="#findMessage">findMessage</a>() to return the right text. This may include thesource, context and comment, but usually it is just a hash valueand the translated text.<p> For example, the "Cancel" in a dialog might have "Anuluj" when theprogram runs in Polish (in this case the source text would be"Cancel"). The context would (normally) be the dialog's classname; there would normally be no comment, and the translated textwould be "Anuluj".<p> But it's not always so simple. The Spanish version of a printerdialog with settings for two-sided printing and binding wouldprobably require both "Activado" and "Activada" as translationsfor "Enabled". In this case the source text would be "Enabled" inboth cases, and the context would be the dialog's class name, butthe two items would have disambiguating comments such as"two-sided printing" for one and "binding" for the other. Thecomment enables the translator to choose the appropriate genderfor the Spanish version, and enables Qt to distinguish betweentranslations.<p> Note that when QTranslator loads a stripped file, most functionsdo not work. The functions that do work with stripped files areexplicitly documented as such.<p> <p>See also <a href="qtranslatormessage.html">QTranslatorMessage</a>, <a href="qapplication.html#installTranslator">QApplication::installTranslator</a>(), <a href="qapplication.html#removeTranslator">QApplication::removeTranslator</a>(), <a href="qobject.html#tr">QObject::tr</a>(), <a href="qapplication.html#translate">QApplication::translate</a>(), <a href="environment.html">Environment Classes</a> and <a href="i18n.html">Internationalization with Qt</a>.<hr><h2>Member Type Documentation</h2><h3 class=fn><a name="SaveMode-enum"></a>QTranslator::SaveMode</h3><p> This enum type defines how QTranslator writes translationfiles. There are two modes:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -