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?

                (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:
    --- a/src/qt/locale/bitcoin_en.ts
    +++ b/src/qt/locale/bitcoin_en.ts
    @@ -4203,6 +4203,19 @@ Note:  Since the fee is calculated on a per-byte basis, a fee rate of "100
             <translation type="unfinished"></translation>
         </message>
     </context>
    +<context>
    +    <name>SplashScreen</name>
    +    <message>
    +        <location filename="../splashscreen.cpp" line="+187"/>
    +        <source>(press q to shutdown and continue later)</source>
    +        <translation type="unfinished"></translation>
    +    </message>
    +    <message>
    +        <location line="+1"/>
    +        <source>press q to shutdown</source>
    +        <translation type="unfinished"></translation>
    +    </message>
    +</context>
     <context>
         <name>TrafficGraphWidget</name>
         <message>
    @@ -5829,5 +5842,15 @@ Go to File &gt; Open Wallet to load a wallet.
             <source>Wallet needed to be rewritten: restart %s to complete</source>
             <translation type="unfinished"></translation>
         </message>
    +    <message>
    +        <location filename="../bitcoin.cpp" line="-485"/>
    +        <source>Settings file could not be read</source>
    +        <translation type="unfinished"></translation>
    +    </message>
    +    <message>
    +        <location line="+23"/>
    +        <source>Settings file could not be written</source>
    +        <translation type="unfinished"></translation>
    +    </message>
     </context>
     </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: 2026-05-11 21:20 UTC

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