aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/snippets
diff options
context:
space:
mode:
authorAndreas Eliasson <andreas.eliasson@qt.io>2024-09-17 20:38:20 +0200
committerAndreas Eliasson <andreas.eliasson@qt.io>2024-10-02 08:46:46 +0000
commitc612dc3d141d988642250ae5aa9a671fbae564c7 (patch)
tree089885f0fc4995f0aad713271aca140e2daaa437 /src/qml/doc/snippets
parent864db17dd2457cf2762f614ca11b7068be350656 (diff)
Doc: Add snippet that shows how to use the n param in qsTr()
Fixes: QTBUG-127795 Pick-to: 6.8 6.7 6.5 6.2 Change-Id: I4b9a958805b4bdcd0b06758e94aca5278847c314 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/doc/snippets')
-rw-r--r--src/qml/doc/snippets/qml/qsTr.qml12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/qml/doc/snippets/qml/qsTr.qml b/src/qml/doc/snippets/qml/qsTr.qml
index c1a48c9d32..b53c216a95 100644
--- a/src/qml/doc/snippets/qml/qsTr.qml
+++ b/src/qml/doc/snippets/qml/qsTr.qml
@@ -3,6 +3,16 @@
import QtQuick
+Item {
//![0]
-Text { text: qsTr("hello") }
+ Text { text: qsTr("hello") }
//![0]
+
+//![1]
+ // Translates the source text into the correct
+ // plural form and replaces %n with the value of total.
+ Text {
+ text: qsTr("%n message(s) saved", "", total)
+ }
+//![1]
+}