diff options
Diffstat (limited to 'doc/html/linguist-manual-4.html')
-rw-r--r-- | doc/html/linguist-manual-4.html | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/doc/html/linguist-manual-4.html b/doc/html/linguist-manual-4.html index 4f7e2e97a..7c4009ae9 100644 --- a/doc/html/linguist-manual-4.html +++ b/doc/html/linguist-manual-4.html @@ -83,8 +83,8 @@ body { background: #ffffff; color: black; } <pre> button = new TQPushButton( tr("&Quit"), this); </pre> -<!-- index TQ_OBJECT --><p>All <a href="ntqobject.html">TQObject</a> subclasses that use the <tt>TQ_OBJECT</tt> macro implement the <tt>tr()</tt> function.</p> -<p>Although the <tt>tr()</tt> call is normally made directly since it is usually called as a member function of a <a href="ntqobject.html">TQObject</a> subclass, in other cases an explicit class name can be supplied, for example:</p> +<!-- index TQ_OBJECT --><p>All <a href="tqobject.html">TQObject</a> subclasses that use the <tt>TQ_OBJECT</tt> macro implement the <tt>tr()</tt> function.</p> +<p>Although the <tt>tr()</tt> call is normally made directly since it is usually called as a member function of a <a href="tqobject.html">TQObject</a> subclass, in other cases an explicit class name can be supplied, for example:</p> <pre> TQPushButton::tr("&Quit") </pre> @@ -102,8 +102,8 @@ body { background: #ffffff; color: black; } rbh = new TQRadioButton( tr("Enabled", "Hue frame"), this ); </pre> <!-- index Ctrl Key --><p>Ctrl key accelerators are also translatable:</p> -<pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="ntqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), - <a href="ntqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); +<pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="tqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), + <a href="tqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); </pre> <p>It is strongly recommended that the two argument form of <tt>tr()</tt> is used for Ctrl key accelerators. The second argument is the only clue the translator has as to the function performed by the accelerator.</p> <h4><a name="1-5"></a>Helping The Translator With Navigation Information</h4> @@ -202,7 +202,7 @@ int main( int argc, char **argv ) translator.<a href="ntqtranslator.html#load">load</a>( "tt1_la", "." ); app.<a href="ntqapplication.html#installTranslator">installTranslator</a>( &translator ); - <a href="ntqpushbutton.html">TQPushButton</a> hello( TQPushButton::<a href="ntqobject.html#tr">tr</a>("Hello world!"), 0 ); + <a href="ntqpushbutton.html">TQPushButton</a> hello( TQPushButton::<a href="tqobject.html#tr">tr</a>("Hello world!"), 0 ); app.<a href="ntqapplication.html#setMainWidget">setMainWidget</a>( &hello ); hello.<a href="ntqwidget.html#show">show</a>(); @@ -224,10 +224,10 @@ int main( int argc, char **argv ) <!-- index TQApplication!installTranslator() --><!-- index installTranslator()!TQApplication --><pre> app.<a href="ntqapplication.html#installTranslator">installTranslator</a>( &translator ); </pre> <p>Adds the translations from <tt>tt1_la.qm</tt> to the pool of translations used by the program.</p> -<!-- index Hello World --><pre> <a href="ntqpushbutton.html">TQPushButton</a> hello( TQPushButton::<a href="ntqobject.html#tr">tr</a>("Hello world!"), 0 ); +<!-- index Hello World --><pre> <a href="ntqpushbutton.html">TQPushButton</a> hello( TQPushButton::<a href="tqobject.html#tr">tr</a>("Hello world!"), 0 ); </pre> <p>Creates a push button that displays "Hello world!". If <tt>tt1_la.qm</tt> was found and contains a translation for "Hello world!", the translation appears; if not, the source text appears.</p> -<!-- index tr() --><!-- index TQObject!tr() --><p>All classes that inherit <a href="ntqobject.html">TQObject</a> have a <tt>tr()</tt> function. Inside a member function of a <a href="ntqobject.html">TQObject</a> class, we simply write <tt>tr("Hello world!")</tt> instead of <tt>TQPushButton::tr("Hello world!")</tt> or <tt>TQObject::tr("Hello world!")</tt>.</p> +<!-- index tr() --><!-- index TQObject!tr() --><p>All classes that inherit <a href="tqobject.html">TQObject</a> have a <tt>tr()</tt> function. Inside a member function of a <a href="tqobject.html">TQObject</a> class, we simply write <tt>tr("Hello world!")</tt> instead of <tt>TQPushButton::tr("Hello world!")</tt> or <tt>TQObject::tr("Hello world!")</tt>.</p> <h5><a name="2-1-2"></a>Running the Application in English</h5> <!-- index English Language --><p>Since we haven't made the translation file <tt>tt1_la.qm</tt>, the source text is shown when we run the application:</p> <p align="center"><img align="middle" src="tt1_en.png" width="112" height="49"> @@ -321,7 +321,7 @@ TRANSLATIONS = tt2_fr.ts \ </pre> <p>Knowing which class each source text appears in enables <em>TQt Linguist</em> to group texts that are logically related together, e.g. all the text in a dialog will have the context of the dialog's class name and will be shown together. This provides useful information for the translator since the context in which text appears may influence how it should be translated. For some translations keyboard accelerators may need to be changed and having all the source texts in a particular context (class) grouped together makes it easier for the translator to perform any accelerator changes without introducing conflicts.</p> <p>In <tt>arrowpad.cpp</tt> we implement the <tt>ArrowPad</tt> class.</p> -<pre> (void) new <a href="ntqpushbutton.html">TQPushButton</a>( <a href="ntqobject.html#tr">tr</a>("&Up"), this ); +<pre> (void) new <a href="ntqpushbutton.html">TQPushButton</a>( <a href="tqobject.html#tr">tr</a>("&Up"), this ); </pre> <p>We call <tt>ArrowPad::tr()</tt> for each button's label since the labels are user-visible text.</p> <p align="center"><img align="middle" src="tt2_en.png" width="170" height="157"> @@ -336,8 +336,8 @@ TRANSLATIONS = tt2_fr.ts \ <pre> ArrowPad *ap = new ArrowPad( this, "arrow pad" ); </pre> <p>We also call <tt>MainWindow::tr()</tt> twice, once for the menu item and once for the accelerator.</p> -<!-- index Ctrl Key --><!-- index Alt Key --><pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="ntqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), - <a href="ntqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); +<!-- index Ctrl Key --><!-- index Alt Key --><pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="tqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), + <a href="tqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); </pre> <p>Note the use of <tt>tr()</tt> to support different keys in other languages. "Ctrl+Q" is a good choice for Quit in English, but a Dutch translator might want to use "Ctrl+A" (for Afsluiten) and a German translator "Strg+E" (for Beenden). When using <tt>tr()</tt> for Ctrl key accelerators, the two argument form should be used with the second argument describing the function that the accelerator performs.</p> <!-- index main() --><p>Our <tt>main()</tt> function is defined in <tt>main.cpp</tt> as usual.</p> @@ -431,36 +431,36 @@ TRANSLATIONS = tt3_pt.ts <!-- index TQ_OBJECT --><!-- index PrintPanel!in Translation Tutorial --> <p>PrintPanel is a <a href="ntqwidget.html">TQWidget</a>. It needs the <tt>TQ_OBJECT</tt> macro for <tt>tr()</tt> to work properly.</p> <p>The implementation file is <tt>printpanel.cpp</tt>.</p> <pre> /* - <a href="ntqlabel.html">TQLabel</a> *lab = new <a href="ntqlabel.html">TQLabel</a>( <a href="ntqobject.html#tr">tr</a>("<b>TROLL PRINT</b>"), this ); + <a href="ntqlabel.html">TQLabel</a> *lab = new <a href="ntqlabel.html">TQLabel</a>( <a href="tqobject.html#tr">tr</a>("<b>TROLL PRINT</b>"), this ); lab-><a href="ntqlabel.html#setAlignment">setAlignment</a>( <a href="ntqt.html#AlignmentFlags-enum">AlignCenter</a> ); */ </pre> <!-- index Troll Print --> <p>Some of the code is commented out in Troll Print 1.0; you will uncomment it later, for Troll Print 1.1.</p> <pre> <a href="ntqhbuttongroup.html">TQHButtonGroup</a> *twoSided = new <a href="ntqhbuttongroup.html">TQHButtonGroup</a>( this ); - twoSided-><a href="ntqgroupbox.html#setTitle">setTitle</a>( <a href="ntqobject.html#tr">tr</a>("2-sided") ); - but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="ntqobject.html#tr">tr</a>("Enabled"), twoSided ); - but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="ntqobject.html#tr">tr</a>("Disabled"), twoSided ); + twoSided-><a href="ntqgroupbox.html#setTitle">setTitle</a>( <a href="tqobject.html#tr">tr</a>("2-sided") ); + but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="tqobject.html#tr">tr</a>("Enabled"), twoSided ); + but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="tqobject.html#tr">tr</a>("Disabled"), twoSided ); but-><a href="ntqbutton.html#toggle">toggle</a>(); <a href="ntqhbuttongroup.html">TQHButtonGroup</a> *colors = new <a href="ntqhbuttongroup.html">TQHButtonGroup</a>( this ); - colors-><a href="ntqgroupbox.html#setTitle">setTitle</a>( <a href="ntqobject.html#tr">tr</a>("Colors") ); - but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="ntqobject.html#tr">tr</a>("Enabled"), colors ); - but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="ntqobject.html#tr">tr</a>("Disabled"), colors ); + colors-><a href="ntqgroupbox.html#setTitle">setTitle</a>( <a href="tqobject.html#tr">tr</a>("Colors") ); + but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="tqobject.html#tr">tr</a>("Enabled"), colors ); + but = new <a href="ntqradiobutton.html">TQRadioButton</a>( <a href="tqobject.html#tr">tr</a>("Disabled"), colors ); but-><a href="ntqbutton.html#toggle">toggle</a>(); </pre> <p>Notice the two occurrences of <tt>tr("Enabled")</tt> and of <tt>tr("Disabled")</tt> in PrintPanel. Since both "Enabled"s and "Disabled"s appear in the same context <em>TQt Linguist</em> will only display one occurrence of each and will use the same translations for the duplicates that it doesn't display. Whilst this is a useful timesaver, in some languages, such as Portuguese, the second occurrence requires a separate translation. We will see how <em>TQt Linguist</em> can be made to display all the occurrences for separate translation shortly.</p> <!-- index MainWindow!in Translation Tutorial --><p>The header file for <tt>MainWindow</tt>, <tt>mainwindow.h</tt>, contains no surprises. In the implementation, <tt>mainwindow.cpp</tt>, we have some user-visible source texts that must be marked for translation.</p> -<pre> <a href="ntqwidget.html#setCaption">setCaption</a>( <a href="ntqobject.html#tr">tr</a>("Troll Print 1.0") ); +<pre> <a href="ntqwidget.html#setCaption">setCaption</a>( <a href="tqobject.html#tr">tr</a>("Troll Print 1.0") ); </pre> <p>We must translate the window's caption.</p> -<pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="ntqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), - <a href="ntqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); +<pre> file-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="tqobject.html#tr">tr</a>("E&xit"), tqApp, TQ_SLOT(<a href="ntqapplication.html#quit">quit</a>()), + <a href="tqobject.html#tr">tr</a>("Ctrl+Q", "Quit") ); <a href="ntqpopupmenu.html">TQPopupMenu</a> *help = new <a href="ntqpopupmenu.html">TQPopupMenu</a>( this ); - help-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="ntqobject.html#tr">tr</a>("&About"), this, TQ_SLOT(about()), Key_F1 ); - help-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="ntqobject.html#tr">tr</a>("About &TQt"), this, TQ_SLOT(aboutTQt()) ); + help-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="tqobject.html#tr">tr</a>("&About"), this, TQ_SLOT(about()), Key_F1 ); + help-><a href="ntqmenudata.html#insertItem">insertItem</a>( <a href="tqobject.html#tr">tr</a>("About &TQt"), this, TQ_SLOT(aboutTQt()) ); - <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertItem( <a href="ntqobject.html#tr">tr</a>("&File"), file ); + <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertItem( <a href="tqobject.html#tr">tr</a>("&File"), file ); <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertSeparator(); - <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertItem( <a href="ntqobject.html#tr">tr</a>("&Help"), help ); + <a href="ntqmainwindow.html#menuBar">menuBar</a>()->insertItem( <a href="tqobject.html#tr">tr</a>("&Help"), help ); </pre> <p>We also need to translate the menu items. Note that the two argument form of <tt>tr()</tt> is used for the keyboard accelerator, "Ctrl+Q", since the second argument is the only clue the translator has to indicate what function that accelerator will perform.</p> <pre> <a href="ntqtranslator.html">TQTranslator</a> translator( 0 ); |