diff options
Diffstat (limited to 'doc/html/qtranslator.html')
-rw-r--r-- | doc/html/qtranslator.html | 326 |
1 files changed, 0 insertions, 326 deletions
diff --git a/doc/html/qtranslator.html b/doc/html/qtranslator.html deleted file mode 100644 index 4ed8ee499..000000000 --- a/doc/html/qtranslator.html +++ /dev/null @@ -1,326 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> -<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qtranslator.cpp:216 --> -<html> -<head> -<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> -<title>TQTranslator Class</title> -<style type="text/css"><!-- -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 Classes</font></a> - | <a href="mainclasses.html"> -<font color="#004faf">Main Classes</font></a> - | <a href="annotated.html"> -<font color="#004faf">Annotated</font></a> - | <a href="groups.html"> -<font color="#004faf">Grouped 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>TQTranslator Class Reference</h1> - -<p>The TQTranslator class provides internationalization support for text -output. -<a href="#details">More...</a> -<p><tt>#include <<a href="qtranslator-h.html">qtranslator.h</a>></tt> -<p>Inherits <a href="qobject.html">TQObject</a>. -<p><a href="qtranslator-members.html">List of all member functions.</a> -<h2>Public Members</h2> -<ul> -<li class=fn><a href="#TQTranslator"><b>TQTranslator</b></a> ( TQObject * parent = 0, const char * name = 0 )</li> -<li class=fn><a href="#~TQTranslator"><b>~TQTranslator</b></a> ()</li> -<li class=fn>TQString find ( const char * context, const char * sourceText, const char * comment = 0 ) const <em>(obsolete)</em></li> -<li class=fn>virtual TQTranslatorMessage <a href="#findMessage"><b>findMessage</b></a> ( const char * context, const char * sourceText, const char * comment = 0 ) const</li> -<li class=fn>bool <a href="#load"><b>load</b></a> ( const TQString & filename, const TQString & directory = TQString::null, const TQString & search_delimiters = TQString::null, const TQString & suffix = TQString::null )</li> -<li class=fn>bool <a href="#load-2"><b>load</b></a> ( const uchar * data, int len )</li> -<li class=fn>void <a href="#clear"><b>clear</b></a> ()</li> -<li class=fn>enum <a href="#SaveMode-enum"><b>SaveMode</b></a> { Everything, Stripped }</li> -<li class=fn>bool <a href="#save"><b>save</b></a> ( const TQString & filename, SaveMode mode = Everything )</li> -<li class=fn>void <a href="#insert"><b>insert</b></a> ( const TQTranslatorMessage & message )</li> -<li class=fn>void insert ( const char * context, const char * sourceText, const TQString & translation ) <em>(obsolete)</em></li> -<li class=fn>void <a href="#remove"><b>remove</b></a> ( const TQTranslatorMessage & message )</li> -<li class=fn>void remove ( const char * context, const char * sourceText ) <em>(obsolete)</em></li> -<li class=fn>bool <a href="#contains"><b>contains</b></a> ( const char * context, const char * sourceText, const char * comment = 0 ) const</li> -<li class=fn>void <a href="#squeeze"><b>squeeze</b></a> ( SaveMode mode = Everything )</li> -<li class=fn>void <a href="#unsqueeze"><b>unsqueeze</b></a> ()</li> -<li class=fn>TQValueList<TQTranslatorMessage> <a href="#messages"><b>messages</b></a> () const</li> -<li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li> -</ul> -<hr><a name="details"></a><h2>Detailed Description</h2> - - -<p> The TQTranslator class provides <a href="i18n.html#internationalization">internationalization</a> support for text -output. -<p> - - -<p> An object of this class contains a set of <a href="qtranslatormessage.html">TQTranslatorMessage</a> -objects, each of which specifies a translation from a source -language to a target language. TQTranslator provides functions to -look up translations, add new ones, remove them, load and save -them, etc. -<p> The most common use of TQTranslator is to: load a translator file -created with <a href="linguist-manual.html">TQt Linguist</a>, -install it using <a href="qapplication.html#installTranslator">TQApplication::installTranslator</a>(), and use it via -<a href="qobject.html#tr">TQObject::tr</a>(). For example: -<p> <pre> - int main( int argc, char ** argv ) - { - <a href="qapplication.html">TQApplication</a> app( argc, argv ); - - TQTranslator translator( 0 ); - translator.<a href="#load">load</a>( "french.qm", "." ); - app.<a href="qapplication.html#installTranslator">installTranslator</a>( &translator ); - - MyWidget m; - app.<a href="qapplication.html#setMainWidget">setMainWidget</a>( &m ); - m.show(); - - return app.<a href="qapplication.html#exec">exec</a>(); - } - </pre> - -Note that the translator must be created <em>before</em> the -application's main window. -<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> We call a translation a "messsage". For this reason, translation -files 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">TQApplication::translate</a>() do) and <a href="#contains">contains</a>(), to insert a -new 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 source -text and translation, for example, context information to help -the translator. But end-user programs that are using translations -usually only need lookup. To cater for these different needs, -TQTranslator can use stripped translator files that use the minimum -of memory and which support little more functionality than -findMessage(). -<p> Thus, <a href="#load">load</a>() may not load enough information to make anything more -than findMessage() work. <a href="#save">save</a>() has an argument indicating -whether to save just this minimum of information or to save -everything. -<p> "Everything" means that for each translation item the following -information 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 uses -of 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 the -source, context and comment, but usually it is just a hash value -and the translated text. -<p> For example, the "Cancel" in a dialog might have "Anuluj" when the -program runs in Polish (in this case the source text would be -"Cancel"). The context would (normally) be the dialog's class -name; there would normally be no comment, and the translated text -would be "Anuluj". -<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 "Activado" and "Activada" as translations -for "Enabled". In this case the source text would be "Enabled" in -both cases, and the context would be the dialog's class name, but -the two items would have disambiguating comments such as -"two-sided printing" for one and "binding" for the other. The -comment enables the translator to choose the appropriate gender -for the Spanish version, and enables TQt to distinguish between -translations. -<p> Note that when TQTranslator loads a stripped file, most functions -do not work. The functions that do work with stripped files are -explicitly documented as such. -<p> <p>See also <a href="qtranslatormessage.html">TQTranslatorMessage</a>, <a href="qapplication.html#installTranslator">TQApplication::installTranslator</a>(), <a href="qapplication.html#removeTranslator">TQApplication::removeTranslator</a>(), <a href="qobject.html#tr">TQObject::tr</a>(), <a href="qapplication.html#translate">TQApplication::translate</a>(), <a href="environment.html">Environment Classes</a>, and <a href="i18n.html">Internationalization with TQt</a>. - -<hr><h2>Member Type Documentation</h2> -<h3 class=fn><a name="SaveMode-enum"></a>TQTranslator::SaveMode</h3> - -<p> This enum type defines how TQTranslator writes translation -files. There are two modes: -<ul> -<li><tt>TQTranslator::Everything</tt> - files are saved with all available information -<li><tt>TQTranslator::Stripped</tt> - files are saved with just enough information for -end-user applications -</ul><p> Note that when TQTranslator loads a stripped file, most functions do -not work. The functions that do work with stripped files are -explicitly documented as such. - -<hr><h2>Member Function Documentation</h2> -<h3 class=fn><a name="TQTranslator"></a>TQTranslator::TQTranslator ( <a href="qobject.html">TQObject</a> * parent = 0, const char * name = 0 ) -</h3> -Constructs an empty message file object that is not connected to -any file. The object is called <em>name</em> with parent <em>parent</em>. - -<h3 class=fn><a name="~TQTranslator"></a>TQTranslator::~TQTranslator () -</h3> -Destroys the object and frees any allocated resources. - -<h3 class=fn>void <a name="clear"></a>TQTranslator::clear () -</h3> -Empties this translator of all contents. -<p> This function works with stripped translator files. - -<h3 class=fn>bool <a name="contains"></a>TQTranslator::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="#findMessage">findMessage</a>().) - -<h3 class=fn><a href="qstring.html">TQString</a> <a name="find"></a>TQTranslator::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#TQString-null">TQString::null</a> if there is none in this translator. - -<h3 class=fn><a href="qtranslatormessage.html">TQTranslatorMessage</a> <a name="findMessage"></a>TQTranslator::findMessage ( const char * context, const char * sourceText, const char * comment = 0 ) const<tt> [virtual]</tt> -</h3> Returns the <a href="qtranslatormessage.html">TQTranslatorMessage</a> for the key -(<em>context</em>, <em>sourceText</em>, <em>comment</em>). If none is found, -also tries (<em>context</em>, <em>sourceText</em>, ""). - -<h3 class=fn>void <a name="insert"></a>TQTranslator::insert ( const <a href="qtranslatormessage.html">TQTranslatorMessage</a> & message ) -</h3> -Inserts <em>message</em> into this message file. -<p> This function does <em>not</em> work with stripped translator files. It -may 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>TQTranslator::insert ( const char * context, const char * sourceText, const <a href="qstring.html">TQString</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="isEmpty"></a>TQTranslator::isEmpty () const -</h3> -Returns TRUE if this translator is empty, otherwise returns FALSE. -This function works with stripped and unstripped translation files. - -<h3 class=fn>bool <a name="load"></a>TQTranslator::load ( const <a href="qstring.html">TQString</a> & filename, const <a href="qstring.html">TQString</a> & directory = TQString::null, const <a href="qstring.html">TQString</a> & search_delimiters = TQString::null, const <a href="qstring.html">TQString</a> & suffix = TQString::null ) -</h3> -Loads <em>filename</em>, which may be an absolute file name or relative -to <em>directory</em>. The previous contents of this translator object -is discarded. Returns TRUE if the file is loaded successfully; -otherwise returns FALSE. -<p> If the full file name does not exist, other file names are tried -in 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#TQString-null">TQString::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 is -TQString::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 existing -readable 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#x1950">i18n/main.cpp</a>. -<h3 class=fn>bool <a name="load-2"></a>TQTranslator::load ( const uchar * data, int len ) -</h3> -This is an overloaded member function, provided for convenience. It behaves essentially like the above function. -<p> -<p> Loads the .qm file data <em>data</em> of length <em>len</em> into the -translator. Returns TRUE if the data is loaded successfully; -otherwise returns FALSE. -<p> The data is not copied. The caller must be able to guarantee that <em>data</em> -will not be deleted or modified. - -<h3 class=fn><a href="qvaluelist.html">TQValueList</a><TQTranslatorMessage> <a name="messages"></a>TQTranslator::messages () const -</h3> -Returns a list of the messages in the translator. This function is -rather slow. Because it is seldom called, it's optimized for -simplicity and small size, rather than speed. -<p> If you want to iterate over the list, you should iterate over a -copy, e.g. -<pre> - <a href="qvaluelist.html">TQValueList</a><TQTranslatorMessage> list = myTranslator.messages(); - TQValueList<TQTranslatorMessage>::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>(); - while ( it != list.<a href="qvaluelist.html#end">end</a>() ) { - process_message( *it ); - ++it; - } - </pre> - - -<h3 class=fn>void <a name="remove"></a>TQTranslator::remove ( const <a href="qtranslatormessage.html">TQTranslatorMessage</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>TQTranslator::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>TQTranslator::save ( const <a href="qstring.html">TQString</a> & filename, <a href="qtranslator.html#SaveMode-enum">SaveMode</a> mode = Everything ) -</h3> -Saves this message file to <em>filename</em>, overwriting the previous -contents of <em>filename</em>. If <em>mode</em> is <a href="#SaveMode-enum">Everything</a> (the -default), 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>TQTranslator::squeeze ( <a href="qtranslator.html#SaveMode-enum">SaveMode</a> mode = Everything ) -</h3> -Converts this message file to the compact format used to store -message files on disk. -<p> You should never need to call this directly; <a href="#save">save</a>() and other -functions 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>TQTranslator::unsqueeze () -</h3> -Converts this message file into an easily modifiable data -structure, 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">TQt toolkit</a>. -Copyright © 1995-2007 -<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 © 2007 -<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> -<td align=right><div align=right>TQt 3.3.8</div> -</table></div></address></body> -</html> |