1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the documentation of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** You may use this file under the terms of the BSD license as follows:
10 **
11 ** "Redistribution and use in source and binary forms, with or without
12 ** modification, are permitted provided that the following conditions are
13 ** met:
14 **   * Redistributions of source code must retain the above copyright
15 **     notice, this list of conditions and the following disclaimer.
16 **   * Redistributions in binary form must reproduce the above copyright
17 **     notice, this list of conditions and the following disclaimer in
18 **     the documentation and/or other materials provided with the
19 **     distribution.
20 **   * Neither the name of The Qt Company Ltd nor the names of its
21 **     contributors may be used to endorse or promote products derived
22 **     from this software without specific prior written permission.
23 **
24 **
25 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
36 **
37 ** $QT_END_LICENSE$
38 **
39 ****************************************************************************/
40 
41 //! [3]
42 label->setText(tr("F\374r \310lise"));
43 //! [3]
44 
45 
wrapInFunction()46 void wrapInFunction()
47 {
48 //! [6]
49 button = new QPushButton("&Quit", this);
50 //! [6]
51 
52 
53 //! [7]
54 button = new QPushButton(tr("&Quit"), this);
55 //! [7]
56 
57 
58 //! [8]
59 QPushButton::tr("&Quit")
60 //! [8]
61 
62 
63 //! [9]
64 QObject::tr("&Quit")
65 //! [9]
66 
67 
68 //! [10]
69 rbc = new QRadioButton(tr("Enabled", "Color frame"), this);
70 //! [10]
71 
72 
73 //! [11]
74 rbh = new QRadioButton(tr("Enabled", "Hue frame"), this);
75 //! [11]
76 }
77 
78 
79 //! [12]
80 /*
81     TRANSLATOR FindDialog
82 
83     Choose Edit|Find from the menu bar or press Ctrl+F to pop up the
84     Find dialog.
85 
86     ...
87 */
88 //! [12]
89 
90 //! [13]
91 /*
92     TRANSLATOR MyNamespace::MyClass
93 
94     Necessary for lupdate.
95 
96     ...
97 */
98 //! [13]
99 
100 //! [14]
some_global_function(LoginWidget * logwid)101 void some_global_function(LoginWidget *logwid)
102 {
103     QLabel *label = new QLabel(
104             LoginWidget::tr("Password:"), logwid);
105 }
106 
same_global_function(LoginWidget * logwid)107 void same_global_function(LoginWidget *logwid)
108 {
109     QLabel *label = new QLabel(
110             qApp->translate("LoginWidget", "Password:"),
111             logwid);
112 }
113 //! [14]
114 
115 
116 //! [15]
greeting(int greet_type)117 QString FriendlyConversation::greeting(int greet_type)
118 {
119     static const char* greeting_strings[] = {
120         QT_TR_NOOP("Hello"),
121         QT_TR_NOOP("Goodbye")
122     };
123     return tr(greeting_strings[greet_type]);
124 }
125 //! [15]
126 
127 
128 //! [16]
129 static const char* greeting_strings[] = {
130     QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"),
131     QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye")
132 };
133 
greeting(int greet_type)134 QString FriendlyConversation::greeting(int greet_type)
135 {
136     return tr(greeting_strings[greet_type]);
137 }
138 
global_greeting(int greet_type)139 QString global_greeting(int greet_type)
140 {
141     return qApp->translate("FriendlyConversation",
142                             greeting_strings[greet_type]);
143 }
144 //! [16]
145 
wrapInFunction()146 void wrapInFunction()
147 {
148 
149 //! [17]
150 QString tr(const char *text, const char *comment, int n);
151 //! [17]
152 
153 //! [18]
154 tr("%n item(s) replaced", "", count);
155 //! [18]
156 
157 }
158