You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

translation_strings_policy.md 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. Translation Strings Policy
  2. ===========================
  3. This document provides guidelines for internationalization of the Bitcoin Core software.
  4. How to translate?
  5. ------------------
  6. To mark a message as translatable
  7. - In GUI source code (under `src/qt`): use `tr("...")`
  8. - In non-GUI source code (under `src`): use `_("...")`
  9. No internationalization is used for e.g. developer scripts outside `src`.
  10. Strings to be translated
  11. -------------------------
  12. On a high level, these strings are to be translated:
  13. - GUI strings, anything that appears in a dialog or window
  14. - Command-line option documentation
  15. ### GUI strings
  16. Anything that appears to the user in the GUI is to be translated. This includes labels, menu items, button texts, tooltips and window titles.
  17. This includes messages passed to the GUI through the UI interface through `InitMessage`, `ThreadSafeMessageBox` or `ShowProgress`.
  18. ### Command-line options
  19. Documentation for the command line options in the output of `--help` should be translated as well.
  20. Make sure that default values do not end up in the string, but use string formatting like `strprintf(_("Threshold for disconnecting misbehaving peers (default: %u)"), 100)`. Putting default values in strings has led to accidental translations in the past, and forces the string to be retranslated every time the value changes.
  21. Do not translate messages that are only shown to developers, such as those that only appear when `--help-debug` is used.
  22. General recommendations
  23. ------------------------
  24. ### Avoid unnecessary translation strings
  25. Try not to burden translators with translating messages that are e.g. slight variations of other messages.
  26. In the GUI, avoid the use of text where an icon or symbol will do.
  27. Make sure that placeholder texts in forms don't end up in the list of strings to be translated (use `<string notr="true">`).
  28. ### Make translated strings understandable
  29. Try to write translation strings in an understandable way, for both the user and the translator. Avoid overly technical or detailed messages
  30. ### Do not translate internal errors
  31. Do not translate internal errors, or log messages, or messages that appear on the RPC interface. If an error is to be shown to the user,
  32. 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".
  33. This helps troubleshooting; if the error is the same for everyone, the likelihood is increased that it can be found using a search engine.
  34. ### Avoid fragments
  35. Avoid dividing up a message into fragments. Translators see every string separately, so may misunderstand the context if the messages are not self-contained.
  36. ### Avoid HTML in translation strings
  37. There have been difficulties with use of HTML in translation strings; translators should not be able to accidentally affect the formatting of messages.
  38. This may sometimes be at conflict with the recommendation in the previous section.
  39. ### Plurals
  40. Plurals can be complex in some languages. A quote from the gettext documentation:
  41. In Polish we use e.g. plik (file) this way:
  42. 1 plik,
  43. 2,3,4 pliki,
  44. 5-21 pliko'w,
  45. 22-24 pliki,
  46. 25-31 pliko'w
  47. and so on
  48. In Qt code use tr's third argument for optional plurality. For example:
  49. tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
  50. tr("%n day(s)","",secs/DAY_IN_SECONDS);
  51. tr("%n week(s)","",secs/WEEK_IN_SECONDS);
  52. This adds `<numerusform>`s to the respective `.ts` file, which can be translated separately depending on the language. In English, this is simply:
  53. <message numerus="yes">
  54. <source>%n active connection(s) to Bitcoin network</source>
  55. <translation>
  56. <numerusform>%n active connection to Bitcoin network</numerusform>
  57. <numerusform>%n active connections to Bitcoin network</numerusform>
  58. </translation>
  59. </message>
  60. Where it is possible try to avoid embedding numbers into the flow of the string at all. e.g.
  61. WARNING: check your network connection, %d blocks received in the last %d hours (%d expected)
  62. versus
  63. WARNING: check your network connection, less blocks (%d) were received in the last %n hours than expected (%d).
  64. 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.
  65. ### String freezes
  66. During a string freeze (often before a major release), no translation strings are to be added, modified or removed.
  67. This can be checked by executing `make translate` in the `src` directory, then verifying that `bitcoin_en.ts` remains unchanged.