summaryrefslogtreecommitdiffstats
path: root/doc/html/qtranslator.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/html/qtranslator.html')
-rw-r--r--doc/html/qtranslator.html326
1 files changed, 326 insertions, 0 deletions
diff --git a/doc/html/qtranslator.html b/doc/html/qtranslator.html
new file mode 100644
index 0000000..e0881e9
--- /dev/null
+++ b/doc/html/qtranslator.html
@@ -0,0 +1,326 @@
+<!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>QTranslator 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&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 text
+output.
+<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 class=fn><a href="#QTranslator"><b>QTranslator</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
+<li class=fn><a href="#~QTranslator"><b>~QTranslator</b></a> ()</li>
+<li 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></li>
+<li 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 = 0 ) const</li>
+<li 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 )</li>
+<li class=fn>bool <a href="#load-2"><b>load</b></a> ( const&nbsp;uchar&nbsp;*&nbsp;data, int&nbsp;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&nbsp;QString&nbsp;&amp;&nbsp;filename, SaveMode&nbsp;mode = Everything )</li>
+<li class=fn>void <a href="#insert"><b>insert</b></a> ( const&nbsp;QTranslatorMessage&nbsp;&amp;&nbsp;message )</li>
+<li 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></li>
+<li class=fn>void <a href="#remove"><b>remove</b></a> ( const&nbsp;QTranslatorMessage&nbsp;&amp;&nbsp;message )</li>
+<li class=fn>void remove ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText ) &nbsp;<em>(obsolete)</em></li>
+<li 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</li>
+<li class=fn>void <a href="#squeeze"><b>squeeze</b></a> ( SaveMode&nbsp;mode = Everything )</li>
+<li class=fn>void <a href="#unsqueeze"><b>unsqueeze</b></a> ()</li>
+<li class=fn>QValueList&lt;QTranslatorMessage&gt; <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 QTranslator 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">QTranslatorMessage</a>
+objects, each of which specifies a translation from a source
+language to a target language. QTranslator provides functions to
+look up translations, add new ones, remove them, load and save
+them, etc.
+<p> The most common use of QTranslator is to: load a translator file
+created 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>
+
+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">QApplication::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,
+QTranslator 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 Qt to distinguish between
+translations.
+<p> Note that when QTranslator 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">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 translation
+files. There are two modes:
+<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 for
+end-user applications
+</ul><p> Note that when QTranslator 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="QTranslator"></a>QTranslator::QTranslator ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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="~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&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;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">QString</a> <a name="find"></a>QTranslator::find ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;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&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;char&nbsp;*&nbsp;comment = 0 ) 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>). If none is found,
+also tries (<em>context</em>, <em>sourceText</em>, "").
+
+<h3 class=fn>void <a name="insert"></a>QTranslator::insert ( const&nbsp;<a href="qtranslatormessage.html">QTranslatorMessage</a>&nbsp;&amp;&nbsp;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>QTranslator::insert ( const&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;sourceText, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;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>QTranslator::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>QTranslator::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;directory = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;search_delimiters = QString::null, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;suffix = QString::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#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 is
+QString::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>QTranslator::load ( const&nbsp;uchar&nbsp;*&nbsp;data, int&nbsp;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">QValueList</a>&lt;QTranslatorMessage&gt; <a name="messages"></a>QTranslator::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">QValueList</a>&lt;QTranslatorMessage&gt; list = myTranslator.messages();
+ QValueList&lt;QTranslatorMessage&gt;::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>QTranslator::remove ( const&nbsp;<a href="qtranslatormessage.html">QTranslatorMessage</a>&nbsp;&amp;&nbsp;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&nbsp;char&nbsp;*&nbsp;context, const&nbsp;char&nbsp;*&nbsp;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&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filename, <a href="qtranslator.html#SaveMode-enum">SaveMode</a>&nbsp;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>QTranslator::squeeze ( <a href="qtranslator.html#SaveMode-enum">SaveMode</a>&nbsp;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>QTranslator::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">Qt toolkit</a>.
+Copyright &copy; 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 &copy; 2007
+<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
+<td align=right><div align=right>Qt 3.3.8</div>
+</table></div></address></body>
+</html>