Skip to content

Conversation

@laanwj
Copy link
Member

@laanwj laanwj commented Oct 13, 2021

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

Use `QObject::tr`, `QT_TR_NOOP`, and `QCoreApplication::translate` as
appropriate instead of using `_()` which doesn't get picked up.
@laanwj laanwj force-pushed the 2021-10-qt-use-at-translation branch from 5908a11 to 58765a4 Compare October 13, 2021 18:01
@hebasto
Copy link
Member

hebasto commented Oct 13, 2021

Concept ACK.

bitcoin/bitcoin#22764 (comment):

Closing in favor of bitcoin-core/gui#454.

@hebasto hebasto changed the title qt: Use only Qt translation primitives in GUI code Use only Qt translation primitives in GUI code Oct 14, 2021
InitMessage(splash, title + std::string("\n") +
(resume_possible ? _("(press q to shutdown and continue later)").translated
: _("press q to shutdown").translated) +
(resume_possible ? SplashScreen::tr("(press q to shutdown and continue later)").toStdString()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Copy link
Member Author

@laanwj laanwj Oct 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member

@hebasto hebasto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 58765a4

My steps to test this PR:

  1. on master (8a083bc) run make -C src translate and commit changes
  2. cherry pick this PR commit (58765a4)
  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>

@hebasto hebasto merged commit bdbefdc into bitcoin-core:master Oct 22, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Oct 22, 2021
… code

58765a4 qt: Use only Qt translation primitives in GUI code (W. J. van der Laan)

Pull request description:

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

  Replaces 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`

ACKs for top commit:
  hebasto:
    ACK 58765a4

Tree-SHA512: d0cc5901426c47d411d0fe75aac195b9684b51385f74c161da772dbf9f0977f7ad7a0976e17366f49b40718e9b6eb87c3e93306dc845f97adddbc47d00731742
@bitcoin-core bitcoin-core locked as resolved and limited conversation to collaborators Oct 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants