doc/src/snippets/code/doc_src_linguist-manual.qdoc
branchRCL_3
changeset 7 3f74d0d4af4c
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the documentation of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 //! [0]
       
    43 HEADERS         = main-dlg.h \
       
    44                   options-dlg.h
       
    45 SOURCES         = main-dlg.cpp \
       
    46                   options-dlg.cpp \
       
    47                   main.cpp
       
    48 FORMS           = search-dlg.ui
       
    49 TRANSLATIONS    = superapp_dk.ts \
       
    50                   superapp_fi.ts \
       
    51                   superapp_no.ts \
       
    52                   superapp_se.ts
       
    53 //! [0]
       
    54 
       
    55 
       
    56 //! [1]
       
    57 CODECFORTR      = ISO-8859-5
       
    58 //! [1]
       
    59 
       
    60 
       
    61 //! [2]
       
    62 CODECFORSRC     = UTF-8
       
    63 //! [2]
       
    64 
       
    65 
       
    66 //! [3]
       
    67 label->setText(tr("F\374r \310lise"));
       
    68 //! [3]
       
    69 
       
    70 
       
    71 //! [4]
       
    72 Usage:
       
    73     lupdate [options] [project-file]
       
    74     lupdate [options] [source-file|path]... -ts ts-files
       
    75 Options:
       
    76     -help  Display this information and exit.
       
    77     -noobsolete
       
    78            Drop all obsolete strings.
       
    79     -extensions <ext>[,<ext>]...
       
    80            Process files with the given extensions only.
       
    81            The extension list must be separated with commas, not with whitespace.
       
    82            Default: 'ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx'.
       
    83     -pluralonly
       
    84            Only include plural form messages.
       
    85     -silent
       
    86            Do not explain what is being done.
       
    87     -version
       
    88            Display the version of lupdate and exit.
       
    89 //! [4]
       
    90 
       
    91 
       
    92 //! [5]
       
    93 Usage:
       
    94     lrelease [options] project-file
       
    95     lrelease [options] ts-files [-qm qm-file]
       
    96 Options:
       
    97     -help  Display this information and exit
       
    98     -compress
       
    99            Compress the QM files
       
   100     -nounfinished
       
   101            Do not include unfinished translations
       
   102     -removeidentical
       
   103            If the translated text is the same as
       
   104            the source text, do not include the message
       
   105     -silent
       
   106            Do not explain what is being done
       
   107     -version
       
   108            Display the version of lrelease and exit
       
   109 //! [5]
       
   110 
       
   111 
       
   112 void wrapInFunction()
       
   113 {
       
   114 //! [6]
       
   115 button = new QPushButton("&Quit", this);
       
   116 //! [6]
       
   117 
       
   118 
       
   119 //! [7]
       
   120 button = new QPushButton(tr("&Quit"), this);
       
   121 //! [7]
       
   122 
       
   123 
       
   124 //! [8]
       
   125 QPushButton::tr("&Quit")
       
   126 //! [8]
       
   127 
       
   128 
       
   129 //! [9]
       
   130 QObject::tr("&Quit")
       
   131 //! [9]
       
   132 
       
   133 
       
   134 //! [10]
       
   135 rbc = new QRadioButton(tr("Enabled", "Color frame"), this);
       
   136 //! [10]
       
   137 
       
   138 
       
   139 //! [11]
       
   140 rbh = new QRadioButton(tr("Enabled", "Hue frame"), this);
       
   141 //! [11]
       
   142 }
       
   143 
       
   144 
       
   145 //! [12]
       
   146 /*
       
   147     TRANSLATOR FindDialog
       
   148 
       
   149     Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
       
   150     Find dialog.
       
   151 
       
   152     ...
       
   153 */
       
   154 //! [12]
       
   155 
       
   156 //! [13]
       
   157 /*
       
   158     TRANSLATOR MyNamespace::MyClass
       
   159 
       
   160     Necessary for lupdate.
       
   161 
       
   162     ...
       
   163 */
       
   164 //! [13]
       
   165 
       
   166 //! [14]
       
   167 void some_global_function(LoginWidget *logwid)
       
   168 {
       
   169     QLabel *label = new QLabel(
       
   170             LoginWidget::tr("Password:"), logwid);
       
   171 }
       
   172 
       
   173 void same_global_function(LoginWidget *logwid)
       
   174 {
       
   175     QLabel *label = new QLabel(
       
   176             qApp->translate("LoginWidget", "Password:"),
       
   177             logwid);
       
   178 }
       
   179 //! [14]
       
   180 
       
   181 
       
   182 //! [15]
       
   183 QString FriendlyConversation::greeting(int greet_type)
       
   184 {
       
   185     static const char* greeting_strings[] = {
       
   186         QT_TR_NOOP("Hello"),
       
   187         QT_TR_NOOP("Goodbye")
       
   188     };
       
   189     return tr(greeting_strings[greet_type]);
       
   190 }
       
   191 //! [15]
       
   192 
       
   193 
       
   194 //! [16]
       
   195 static const char* greeting_strings[] = {
       
   196     QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
       
   197     QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
       
   198 };
       
   199 
       
   200 QString FriendlyConversation::greeting(int greet_type)
       
   201 {
       
   202     return tr(greeting_strings[greet_type]);
       
   203 }
       
   204 
       
   205 QString global_greeting(int greet_type)
       
   206 {
       
   207     return qApp->translate("FriendlyConversation",
       
   208                             greeting_strings[greet_type]);
       
   209 }
       
   210 //! [16]
       
   211 
       
   212 void wrapInFunction()
       
   213 {
       
   214 
       
   215 //! [17]
       
   216 QString tr(const char *text, const char *comment, int n);
       
   217 //! [17]
       
   218 
       
   219 //! [18]
       
   220 tr("%n item(s) replaced", "", count);
       
   221 //! [18]
       
   222 
       
   223 }
       
   224