diff options
Diffstat (limited to 'examples/linguist/doc/src/hellotr.qdoc')
-rw-r--r-- | examples/linguist/doc/src/hellotr.qdoc | 65 |
1 files changed, 30 insertions, 35 deletions
diff --git a/examples/linguist/doc/src/hellotr.qdoc b/examples/linguist/doc/src/hellotr.qdoc index 924950731..67de1002e 100644 --- a/examples/linguist/doc/src/hellotr.qdoc +++ b/examples/linguist/doc/src/hellotr.qdoc @@ -1,33 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only /*! \example hellotr \ingroup examples-linguist + \examplecategory {User Interface Components} + \title Hello tr() Example \brief Translating a small Hello World program to Latin. @@ -56,6 +34,10 @@ Tries to load a file called \c hellotr_la.qm (the \c .qm file extension is implicit) that contains Latin translations for the source texts used in the program. No error will occur if the file is not found. + This example works best on desktop platforms. + On platforms like Android and iOS, + the .qm file needs to be part of the app bundle. Usually, + this involves bundling the .qm file in a Qt resource. \snippet hellotr/main.cpp 7 @@ -82,17 +64,23 @@ \section1 Creating a Latin Message File - The first step is to create a project file, \c hellotr.pro, that lists - all the source files for the project. The project file can be a qmake - project file, or even an ordinary makefile. Any file that contains + The first step is to create a project file that lists + all the source files for the project. + + When using qmake, the relevant lines in \c hellotr.pro are: \snippet hellotr/hellotr.pro 0 \snippet hellotr/hellotr.pro 1 - will work. \c TRANSLATIONS specifies the message files we want to + \c TRANSLATIONS specifies the message files we want to maintain. In this example, we just maintain one set of translations, namely Latin. + When using CMake, the relevant lines in \c CMakeLists.txt are: + \snippet hellotr/CMakeLists.txt 0 + \codeline + \snippet hellotr/CMakeLists.txt 1 + Note that the file extension is \c .ts, not \c .qm. The \c .ts translation source format is designed for use during the application's development. Programmers or release managers run @@ -119,16 +107,23 @@ \c lupdate is used to create and update the message files (\c hellotr_la.ts in this case) to keep them in sync with the source code. It is safe to run \c lupdate at any time, as \c lupdate does not remove any - information. For example, you can put it in the makefile, so the TS - files are updated whenever the source changes. + information. + + Try running \c lupdate right now. - Try running \c lupdate right now, like this: + When using qmake, \c lupdate must be run manually: \snippet doc/snippets/doc_src_examples_hellotr.qdoc 0 (The \c -verbose option instructs \c lupdate to display messages that - explain what it is doing.) You should now have a file \c hellotr_la.ts in - the current directory, containing this: + explain what it is doing.) + + When using CMake, build the \c update_translations target to run \c lupdate: + + \snippet doc/snippets/doc_src_examples_hellotr.qdoc 5 + + You should now have a file \c hellotr_la.ts in + the source directory, containing this: \snippet doc/snippets/doc_src_examples_hellotr.qdoc 1 |