📄 qtranslator.html
字号:
<ul><li><tt>QTranslator::Everything</tt> - files are saved with all available information<li><tt>QTranslator::Stripped</tt> - files are saved with just enough information forend-user applications</ul><p> Note that when QTranslator loads a stripped file, most functions donot work. The functions that do work with stripped files areexplicitly documented as such.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QTranslator"></a>QTranslator::QTranslator ( <a href="qobject.html">QObject</a> * parent, const char * name = 0 )</h3>Constructs an empty message file object that is not connected toany file. The object is called <em>name</em> with parent <em>parent</em>.<h3 class=fn><a name="~QTranslator"></a>QTranslator::~QTranslator ()</h3>Destroys the object and frees any allocated resources.<h3 class=fn>void <a name="clear"></a>QTranslator::clear ()</h3>Empties this translator of all contents.<p> This function works with stripped translator files.<h3 class=fn>bool <a name="contains"></a>QTranslator::contains ( const char * context, const char * sourceText, const char * comment = 0 ) const</h3>Returns TRUE if this message file contains a message with the key(<em>context</em>, <em>sourceText</em>, <em>comment</em>); otherwise returns FALSE.<p> This function works with stripped translator files.<p> (This is is a one-liner that calls <a href="#find">find</a>().)<h3 class=fn><a href="qstring.html">QString</a> <a name="find"></a>QTranslator::find ( const char * context, const char * sourceText, const char * comment = 0 ) const</h3><b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.<p> Please use <a href="#findMessage">findMessage</a>() instead.<p> Returns the translation for the key (<em>context</em>, <em>sourceText</em>,<em>comment</em>) or <a href="qstring.html#QString-null">QString::null</a> if there is none in this translator.<h3 class=fn><a href="qtranslatormessage.html">QTranslatorMessage</a> <a name="findMessage"></a>QTranslator::findMessage ( const char * context, const char * sourceText, const char * comment ) const<tt> [virtual]</tt></h3>Returns the <a href="qtranslatormessage.html">QTranslatorMessage</a> for the key (<em>context</em>, <em>sourceText</em>, <em>comment</em>).<h3 class=fn>void <a name="insert"></a>QTranslator::insert ( const <a href="qtranslatormessage.html">QTranslatorMessage</a> & message )</h3>Inserts <em>message</em> into this message file.<p> This function does <em>not</em> work with stripped translator files. Itmay appear to, but that is not dependable.<p> <p>See also <a href="#remove">remove</a>().<h3 class=fn>void <a name="insert-2"></a>QTranslator::insert ( const char * context, const char * sourceText, const <a href="qstring.html">QString</a> & translation )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.<p> <h3 class=fn>bool <a name="load"></a>QTranslator::load ( const <a href="qstring.html">QString</a> & filename, const <a href="qstring.html">QString</a> & directory = QString::null, const <a href="qstring.html">QString</a> & search_delimiters = QString::null, const <a href="qstring.html">QString</a> & suffix = QString::null )</h3>Loads <em>filename</em>, which may be an absolute file name or relativeto <em>directory</em>. The previous contents of this translator objectis discarded.<p> If the full file name does not exist, other file names are triedin the following order:<p> <ol type=1><li> File name with <em>suffix</em> appended (".qm" if the <em>suffix</em> is<a href="qstring.html#QString-null">QString::null</a>).<li> File name with text after a character in <em>search_delimiters</em>stripped ("_." is the default for <em>search_delimiters</em> if it isQString::null).<li> File name stripped and <em>suffix</em> appended.<li> File name stripped further, etc.</ol><p> For example, an application running in the fr_CA locale(French-speaking Canada) might call <a href="#load">load</a>("foo.fr_ca","/opt/foolib"). load() would then try to open the first existingreadable file from this list:<p> <ol type=1><li> /opt/foolib/foo.fr_ca<li> /opt/foolib/foo.fr_ca.qm<li> /opt/foolib/foo.fr<li> /opt/foolib/foo.fr.qm<li> /opt/foolib/foo<li> /opt/foolib/foo.qm</ol><p> <p>See also <a href="#save">save</a>().<p>Example: <a href="i18n-example.html#x1936">i18n/main.cpp</a>.<h3 class=fn><a href="qvaluelist.html">QValueList</a><QTranslatorMessage> <a name="messages"></a>QTranslator::messages () const</h3>Returns a list of the messages in the translator. This function israther slow. Because it is seldom called, it's optimized forsimplicity and small size, rather than speed.<p> If you want to iterate over the list, you should iterate over acopy, e.g.<pre> <a href="qvaluelist.html">QValueList</a><QTranslatorMessage> list = myTranslator.messages(); QValueList<QTranslatorMessage>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); while( it != list.<a href="qvaluelist.html#end">end</a>() ) { myProcessing( *it ); ++it; } </pre> <h3 class=fn>void <a name="remove"></a>QTranslator::remove ( const <a href="qtranslatormessage.html">QTranslatorMessage</a> & message )</h3>Removes <em>message</em> from this translator.<p> This function works with stripped translator files.<p> <p>See also <a href="#insert">insert</a>().<h3 class=fn>void <a name="remove-2"></a>QTranslator::remove ( const char * context, const char * sourceText )</h3>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.<p> <b>This function is obsolete.</b> It is provided to keep old source working. We strongly advise against using it in new code.<p> Removes the translation associated to the key (<em>context</em>, <em>sourceText</em>,"") from this translator.<h3 class=fn>bool <a name="save"></a>QTranslator::save ( const <a href="qstring.html">QString</a> & filename, <a href="qtranslator.html#SaveMode-enum">SaveMode</a> mode = Everything )</h3>Saves this message file to <em>filename</em>, overwriting the previouscontents of <em>filename</em>. If <em>mode</em> is <a href="#SaveMode-enum">Everything</a> (thedefault), all the information is preserved. If <em>mode</em> is <a href="#SaveMode-enum">Stripped</a>, any information that is not necessary for <a href="#findMessage">findMessage</a>()is stripped away.<p> <p>See also <a href="#load">load</a>().<h3 class=fn>void <a name="squeeze"></a>QTranslator::squeeze ( <a href="qtranslator.html#SaveMode-enum">SaveMode</a> mode = Everything )</h3>Converts this message file to the compact format used to storemessage files on disk.<p> You should never need to call this directly; <a href="#save">save</a>() and otherfunctions call it as necessary. <em>mode</em> is for internal use.<p> <p>See also <a href="#save">save</a>() and <a href="#unsqueeze">unsqueeze</a>().<h3 class=fn>void <a name="unsqueeze"></a>QTranslator::unsqueeze ()</h3>Converts this message file into an easily modifiable datastructure, less compact than the format used in the files.<p> You should never need to call this function; it is called by<a href="#insert">insert</a>() and friends as necessary.<p> <p>See also <a href="#squeeze">squeeze</a>().<!-- eof --><hr><p>This file is part of the <a href="index.html">Qt toolkit</a>.Copyright © 1995-2002<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center><table width=100% cellspacing=0 border=0><tr><td>Copyright © 2002 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a><td align=right><div align=right>Qt version 3.0.5</div></table></div></address></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -