Skip to content

Commit d2af959

Browse files
committed
Introduce translation_strings_policy.md
Adds guidelines for adding new translation strings in the code
1 parent 019b8f4 commit d2af959

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed

doc/translation_strings_policy.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Translation Strings Policy
2+
===========================
3+
4+
This document provides guidelines for internationalization of the PIVX Core software.
5+
6+
How to translate?
7+
------------------
8+
9+
To mark a message as translatable
10+
11+
- In GUI source code (under `src/qt`): use `tr("...")`
12+
13+
- In non-GUI source code (under `src`): use `_("...")`
14+
15+
No internationalization is used for e.g. developer scripts outside `src`.
16+
17+
Strings to be translated
18+
-------------------------
19+
20+
On a high level, these strings are to be translated:
21+
22+
- GUI strings, anything that appears in a dialog or window
23+
24+
### GUI strings
25+
26+
Anything that appears to the user in the GUI is to be translated. This includes labels, menu items, button texts, tooltips and window titles.
27+
This includes messages passed to the GUI through the UI interface through `InitMessage`, `ThreadSafeMessageBox` or `ShowProgress`.
28+
29+
General recommendations
30+
------------------------
31+
32+
### Avoid unnecessary translation strings
33+
34+
Try not to burden translators with translating messages that are e.g. slight variations of other messages.
35+
In the GUI, avoid the use of text where an icon or symbol will do.
36+
Make sure that placeholder texts in forms do not end up in the list of strings to be translated (use `<string notr="true">`).
37+
38+
### Make translated strings understandable
39+
40+
Try to write translation strings in an understandable way, for both the user and the translator. Avoid overly technical or detailed messages.
41+
42+
### Do not translate internal errors
43+
44+
Do not translate internal errors, log messages, or messages that appear on the RPC interface. If an error is to be shown to the user,
45+
use a translatable generic message, then log the detailed message to the log. E.g., "A fatal internal error occurred, see debug.log for details".
46+
This helps troubleshooting; if the error is the same for everyone, the likelihood is increased that it can be found using a search engine.
47+
48+
### Avoid fragments
49+
50+
Avoid dividing up a message into fragments. Translators see every string separately, so they may misunderstand the context if the messages are not self-contained.
51+
52+
### Avoid HTML in translation strings
53+
54+
There have been difficulties with the use of HTML in translation strings; translators should not be able to accidentally affect the formatting of messages.
55+
This may sometimes be at conflict with the recommendation in the previous section.
56+
57+
### Plurals
58+
59+
Plurals can be complex in some languages. A quote from the gettext documentation:
60+
61+
In Polish we use e.g. plik (file) this way:
62+
1 plik,
63+
2,3,4 pliki,
64+
5-21 pliko'w,
65+
22-24 pliki,
66+
25-31 pliko'w
67+
and so on
68+
69+
In Qt code, use tr's third argument for optional plurality. For example:
70+
71+
tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
72+
tr("%n day(s)","",secs/DAY_IN_SECONDS);
73+
tr("%n week(s)","",secs/WEEK_IN_SECONDS);
74+
75+
This adds `<numerusform>`s to the respective `.ts` file, which can be translated separately depending on the language. In English, this is simply:
76+
77+
<message numerus="yes">
78+
<source>%n active connection(s) to PIVX network</source>
79+
<translation>
80+
<numerusform>%n active connection to PIVX network</numerusform>
81+
<numerusform>%n active connections to PIVX network</numerusform>
82+
</translation>
83+
</message>
84+
85+
Where possible, try to avoid embedding numbers into the flow of the string at all. E.g.,
86+
87+
WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)
88+
89+
versus
90+
91+
WARNING: check your network connection, less blocks (%d) were received in the last %n hours than expected (%d).
92+
93+
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.
94+
95+
### String freezes
96+
97+
During a string freeze (often before a major release), no translation strings are to be added, modified or removed.
98+
99+
This can be checked by executing `make translate` in the `src` directory, then verifying that `pivx_en.ts` remains unchanged.

0 commit comments

Comments
 (0)