Skip to content

Commit 06818f7

Browse files
committed
doc: Add section on plurals to strings policy
Thanks to @pryds for explaining this to me on Transifex.
1 parent ab0ec67 commit 06818f7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

doc/translation_strings_policy.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,44 @@ Avoid dividing up a message into fragments. Translators see every string separat
6464
There have been difficulties with use of HTML in translation strings; translators should not be able to accidentally affect the formatting of messages.
6565
This may sometimes be at conflict with the recommendation in the previous section.
6666

67+
### Plurals
68+
69+
Plurals can be complex in some languages. A quote from the gettext documentation:
70+
71+
In Polish we use e.g. plik (file) this way:
72+
1 plik,
73+
2,3,4 pliki,
74+
5-21 pliko'w,
75+
22-24 pliki,
76+
25-31 pliko'w
77+
and so on
78+
79+
In Qt code use tr's third argument for optional plurality. For example:
80+
81+
tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
82+
tr("%n day(s)","",secs/DAY_IN_SECONDS);
83+
tr("%n week(s)","",secs/WEEK_IN_SECONDS);
84+
85+
This adds `<numerusform>`s to the respective `.ts` file, which can be translated separately depending on the language. In English, this is simply:
86+
87+
<message numerus="yes">
88+
<source>%n active connection(s) to Bitcoin network</source>
89+
<translation>
90+
<numerusform>%n active connection to Bitcoin network</numerusform>
91+
<numerusform>%n active connections to Bitcoin network</numerusform>
92+
</translation>
93+
</message>
94+
95+
Where it is possible try to avoid embedding numbers into the flow of the string at all. e.g.
96+
97+
WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)
98+
99+
versus
100+
101+
WARNING: check your network connection, less blocks (%d) were received in the last %n hours than expected (%d).
102+
103+
The second example reduces the number of pluralized words that translators have to handle from three to one, at no cost to comprehensibility of the sentence.
104+
67105
### String freezes
68106

69107
During a string freeze (often before a major release), no translation strings are to be added, modified or removed.

0 commit comments

Comments
 (0)