Doc: Update multilanguage database docs
Update reference docs and tutorial for the multilanguage database. Task-number: QDS-5966 Change-Id: I1aa3fa2fa8009bb0240ec787edbdc1589e87d5f1 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 8.5 KiB |
@@ -39,8 +39,8 @@
|
|||||||
translations from a JSON file.
|
translations from a JSON file.
|
||||||
|
|
||||||
You need to download the starting project for this tutorial from
|
You need to download the starting project for this tutorial from
|
||||||
\l{https://git.qt.io/public-demos/qtdesign-studio/-/tree/master/examples/
|
\l{https://git.qt.io/public-demos/qtdesign-studio/-/tree/master/tutorial%20projects/multi-language%20tutorial/Loginui2}{here}
|
||||||
loginui2}{here} before you start.
|
before you start.
|
||||||
|
|
||||||
Download the project and open the \e loginui2.qmlproject file in \QDS
|
Download the project and open the \e loginui2.qmlproject file in \QDS
|
||||||
to get started.
|
to get started.
|
||||||
@@ -48,8 +48,7 @@
|
|||||||
This project consists of a login page with a couple of text elements.
|
This project consists of a login page with a couple of text elements.
|
||||||
|
|
||||||
Additionally, you will use a JSON translation file in this tutorial.
|
Additionally, you will use a JSON translation file in this tutorial.
|
||||||
Download it from \l{https://git.qt.io/public-demos/qtdesign-studio/-/tree/
|
Download it from \l{https://git.qt.io/public-demos/qtdesign-studio/-/tree/master/tutorial%20projects/multi-language}{here}.
|
||||||
master/tutorial%20projects/multi-language}{here}.
|
|
||||||
|
|
||||||
\section1 JSON Translation File
|
\section1 JSON Translation File
|
||||||
|
|
||||||
@@ -133,10 +132,11 @@
|
|||||||
First, you need to prepare your project for translation:
|
First, you need to prepare your project for translation:
|
||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
|
\li In \uicontrol{Projects}, double-click \e{Screen01.ui.qml} to open it.
|
||||||
\li All text strings that you want to translate need to be of \c
|
\li All text strings that you want to translate need to be of \c
|
||||||
qsTrId type. In this project the text strings are of \c qsTr type so you
|
qsTrId type. In this project the text strings are of \c qsTr type so you
|
||||||
need to change them. Open \uicontrol{Text Editor}, find all five
|
need to change them. Open \uicontrol{Text Editor}, find all five
|
||||||
occurrences of \c QsTr and replace them with \c{QsTrId}. For example,
|
occurrences of \c qsTr and replace them with \c{qsTrId}. For example,
|
||||||
replace:
|
replace:
|
||||||
\code
|
\code
|
||||||
text: qsTr("Qt Account")
|
text: qsTr("Qt Account")
|
||||||
@@ -165,21 +165,14 @@
|
|||||||
\li Go to \uicontrol View > \uicontrol Views and select \uicontrol
|
\li Go to \uicontrol View > \uicontrol Views and select \uicontrol
|
||||||
Translations to open the \uicontrol Translations view. You can
|
Translations to open the \uicontrol Translations view. You can
|
||||||
drag it to a workspace to dock it.
|
drag it to a workspace to dock it.
|
||||||
|
|
||||||
When you open the \uicontrol Translations view for the first time, \QDS
|
|
||||||
prompts you to enable the multi-language database, select
|
|
||||||
\uicontrol{Yes}.
|
|
||||||
\image enable-multilanguage.png
|
|
||||||
\li In \uicontrol Translations, select
|
\li In \uicontrol Translations, select
|
||||||
\inlineimage icons/select-languages.png
|
\inlineimage icons/select-languages.png
|
||||||
.
|
.
|
||||||
|
|
||||||
When you enable the multi-language database, an SQLite database named
|
|
||||||
\e translations.db is created in the project folder root.
|
|
||||||
\li Select the languages that you want to support in your project,
|
\li Select the languages that you want to support in your project,
|
||||||
in this case \uicontrol{English - American English} and
|
in this case \uicontrol{English - American English} and
|
||||||
\uicontrol{Swedish}.
|
\uicontrol{Swedish - Svenska}.
|
||||||
\li Set \uicontrol English as primary language and select \uicontrol{OK}.
|
\li Set \uicontrol{English - American English} as primary language and
|
||||||
|
select \uicontrol{Ok}.
|
||||||
\li Select \inlineimage icons/import-json-translations.png
|
\li Select \inlineimage icons/import-json-translations.png
|
||||||
and open the \e ml_translations.json file. Now you can see all your
|
and open the \e ml_translations.json file. Now you can see all your
|
||||||
imported translations in the \uicontrol Translations view.
|
imported translations in the \uicontrol Translations view.
|
||||||
|
Before Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 3.8 KiB |
@@ -63,12 +63,14 @@
|
|||||||
\li \l{Generating Qt Translation Source Files}
|
\li \l{Generating Qt Translation Source Files}
|
||||||
\row
|
\row
|
||||||
\li \inlineimage icons/project-translation-test.png
|
\li \inlineimage icons/project-translation-test.png
|
||||||
\li Run project translation test.
|
\li Run translation test for several documents and create a test report.
|
||||||
\li \l{Running the Project Translation Test}
|
\li \l{Running Translation Test for Several Documents}
|
||||||
\row
|
\row
|
||||||
\li \inlineimage icons/qml-translation-test.png
|
\li \inlineimage icons/qml-translation-test.png
|
||||||
\li Run QML translation test to find missing and elided translations.
|
\li Run translation test for the currently open document. This test
|
||||||
\li \l{Running the QML Translation Test}
|
shows translation warnings in \uicontrol{From Editor} and creates a
|
||||||
|
test report.
|
||||||
|
\li \l{Running Translation Test for a Single Document}
|
||||||
\row
|
\row
|
||||||
\li \inlineimage icons/export-translations.png
|
\li \inlineimage icons/export-translations.png
|
||||||
\li Export all translations used in your project or all translations
|
\li Export all translations used in your project or all translations
|
||||||
@@ -93,8 +95,8 @@
|
|||||||
"translation": "Password"
|
"translation": "Password"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"language": "sv",
|
"language": "fi",
|
||||||
"translation": "Lösenord"
|
"translation": "Salasana"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -120,8 +122,8 @@
|
|||||||
"translation": "Password"
|
"translation": "Password"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"language": "sv",
|
"language": "fi",
|
||||||
"translation": "Lösenord"
|
"translation": "Salasana"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
\endcode
|
\endcode
|
||||||
@@ -139,14 +141,14 @@
|
|||||||
in the \uicontrol Translations view. The files are generated
|
in the \uicontrol Translations view. The files are generated
|
||||||
in \e{<project-folder>/i18n}.
|
in \e{<project-folder>/i18n}.
|
||||||
|
|
||||||
\section1 Running the QML Translation Test
|
\section1 Running Translation Test for a Single Document
|
||||||
|
|
||||||
You can run the QML language test to find missing
|
You can run the translation test to find missing translations
|
||||||
and elided translations. Running the QML language test
|
and translations where the text exceeds the text element boundaries. Running
|
||||||
is a quick way to check the translations in the application you have open in
|
the test is a quick way to check the translations in the document you have
|
||||||
\uicontrol{Form Editor} as it highlights errors in the UI.
|
open in \uicontrol{Form Editor} as it highlights errors in the UI.
|
||||||
|
|
||||||
To run the QML translation test:
|
To run the test for the currently open document:
|
||||||
|
|
||||||
\list 1
|
\list 1
|
||||||
\li In the \uicontrol Translations view, select
|
\li In the \uicontrol Translations view, select
|
||||||
@@ -155,12 +157,11 @@
|
|||||||
\li Select the tests to run and the highlight color
|
\li Select the tests to run and the highlight color
|
||||||
for each test:
|
for each test:
|
||||||
\list
|
\list
|
||||||
\li \uicontrol{Show Translation Warnings} highlights missing
|
\li \uicontrol{Success} highlights translations without any warnings.
|
||||||
translations.
|
\li \uicontrol{Missing translation} highlights translations that are
|
||||||
\li \uicontrol{Show Found Translations} highlights all translations
|
missing for one or more languages.
|
||||||
that are correct.
|
\li \uicontrol{Exceeds boundaries} highlights translations where
|
||||||
\li \uicontrol{Show Elide Warnings} highlights all translations where
|
the text is too long to fit in the text object.
|
||||||
the text is too long to fit in the text object and therefore is elided.
|
|
||||||
\endlist
|
\endlist
|
||||||
\image translation-tester.png
|
\image translation-tester.png
|
||||||
\li Select \uicontrol{Run Tests}.
|
\li Select \uicontrol{Run Tests}.
|
||||||
@@ -205,16 +206,21 @@
|
|||||||
The report shows the type of error as well as line and column of the
|
The report shows the type of error as well as line and column of the
|
||||||
affected text element in the \e{ui.qml} file.
|
affected text element in the \e{ui.qml} file.
|
||||||
|
|
||||||
\section1 Running the Project Translation Test
|
\section1 Running Translation Test for Several Documents
|
||||||
|
|
||||||
You can run the project translation test on several \e{.ui.qml} files
|
You can run the project translation test on several \e{.ui.qml} files
|
||||||
at the same time. \QDS runs the same tests as during the
|
at the same time. \QDS runs the same tests as during the
|
||||||
\l{Running the QML Translation Test}{QML Translation Test} and generates the
|
\l{Running Translation Test for a Single Document}{Translation Test} and
|
||||||
same test reports but does not highlight errors in the UI.
|
generates the same test reports but does not highlight errors in the UI.
|
||||||
|
|
||||||
To run the project translation test, select
|
To run the translation test for several documents:
|
||||||
\inlineimage icons/project-translation-test.png
|
\list 1
|
||||||
in the \uicontrol Translations view.
|
\li Select
|
||||||
|
\inlineimage icons/project-translation-test.png
|
||||||
|
in the \uicontrol Translations view.
|
||||||
|
\li Select the files that you want to include in the test.
|
||||||
|
\li Select \uicontrol{Run Tests}.
|
||||||
|
\endlist
|
||||||
|
|
||||||
\section1 Exporting Translations in Other Ways
|
\section1 Exporting Translations in Other Ways
|
||||||
|
|
||||||
|