Use only Qt translation primitives in GUI code #454

pull laanwj wants to merge 1 commits into bitcoin-core:master from laanwj:2021-10-qt-use-at-translation changing 2 files +10 −8
  1. laanwj commented at 4:06 pm on October 13, 2021: member

    Use Object::tr, QT_TRANSLATE_NOOP, and QCoreApplication::translate as appropriate instead of using _() which doesn’t get picked up.

    Replaces bitcoin/bitcoin#22764

    Edit: I checked that the strings end up in the appropriate context in bitcoin_en.ts after make translate:

    • “Settings file could not be read” “Settings file could not be written” end up in bitcoin-core
    • “(press q to shutdown and continue later)” and “press q to shutdown” end up in SplashScreen
  2. laanwj added the label Translations on Oct 13, 2021
  3. laanwj force-pushed on Oct 13, 2021
  4. laanwj force-pushed on Oct 13, 2021
  5. qt: Use only Qt translation primitives in GUI code
    Use `QObject::tr`, `QT_TR_NOOP`, and `QCoreApplication::translate` as
    appropriate instead of using `_()` which doesn't get picked up.
    58765a450c
  6. laanwj force-pushed on Oct 13, 2021
  7. hebasto commented at 8:13 pm on October 13, 2021: member
  8. hebasto renamed this:
    qt: Use only Qt translation primitives in GUI code
    Use only Qt translation primitives in GUI code
    on Oct 14, 2021
  9. in src/qt/splashscreen.cpp:187 in 58765a450c
    183@@ -184,8 +184,8 @@ static void InitMessage(SplashScreen *splash, const std::string &message)
    184 static void ShowProgress(SplashScreen *splash, const std::string &title, int nProgress, bool resume_possible)
    185 {
    186     InitMessage(splash, title + std::string("\n") +
    187-            (resume_possible ? _("(press q to shutdown and continue later)").translated
    188-                                : _("press q to shutdown").translated) +
    189+            (resume_possible ? SplashScreen::tr("(press q to shutdown and continue later)").toStdString()
    


    jarolrod commented at 2:47 pm on October 15, 2021:

    Is there a code clarification reason here & L188 to use SplashScreen::tr?

    0            (resume_possible ? QObject::tr("(press q to shutdown and continue later)").toStdString()
    

    laanwj commented at 4:47 pm on October 21, 2021:
    It’s about the context, I thought it was better to have these end up in the QSplashScreen context than QObject which is very general and uninformative.
  10. hebasto approved
  11. hebasto commented at 6:08 pm on October 21, 2021: member

    ACK 58765a450c40152db8160bca8a6b0f5b754c5858

    My steps to test this PR:

    1. on master (8a083bc5b57ff98f2e3c550f1b10dba202e3aa79) run make -C src translate and commit changes
    2. cherry pick this PR commit (58765a450c40152db8160bca8a6b0f5b754c5858)
    3. run make -C src translate again, and observe the substantial diff in the qt/locale/bitcoin_en.ts:
     0--- a/src/qt/locale/bitcoin_en.ts
     1+++ b/src/qt/locale/bitcoin_en.ts
     2@@ -4203,6 +4203,19 @@ Note:  Since the fee is calculated on a per-byte basis, a fee rate of "100
     3         <translation type="unfinished"></translation>
     4     </message>
     5 </context>
     6+<context>
     7+    <name>SplashScreen</name>
     8+    <message>
     9+        <location filename="../splashscreen.cpp" line="+187"/>
    10+        <source>(press q to shutdown and continue later)</source>
    11+        <translation type="unfinished"></translation>
    12+    </message>
    13+    <message>
    14+        <location line="+1"/>
    15+        <source>press q to shutdown</source>
    16+        <translation type="unfinished"></translation>
    17+    </message>
    18+</context>
    19 <context>
    20     <name>TrafficGraphWidget</name>
    21     <message>
    22@@ -5829,5 +5842,15 @@ Go to File &gt; Open Wallet to load a wallet.
    23         <source>Wallet needed to be rewritten: restart %s to complete</source>
    24         <translation type="unfinished"></translation>
    25     </message>
    26+    <message>
    27+        <location filename="../bitcoin.cpp" line="-485"/>
    28+        <source>Settings file could not be read</source>
    29+        <translation type="unfinished"></translation>
    30+    </message>
    31+    <message>
    32+        <location line="+23"/>
    33+        <source>Settings file could not be written</source>
    34+        <translation type="unfinished"></translation>
    35+    </message>
    36 </context>
    37 </TS>
    
  12. hebasto merged this on Oct 22, 2021
  13. hebasto closed this on Oct 22, 2021

  14. sidhujag referenced this in commit 45ce973966 on Oct 22, 2021
  15. bitcoin-core locked this on Oct 23, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-21 12:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me