wxHtmlPrintout i18n and DIP fixes (PR #24916)

38 views
Skip to first unread message

Blake-Madden

unread,
Oct 27, 2024, 8:09:06 AMOct 27
to wx-...@googlegroups.com, Subscribed

Make default titles translatable, don't piece strings together for title
Also, make initial frame size DPI aware
Remove wxT() macros


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/24916

Commit Summary

  • 6215c51 Make default titles translatable, don't piece strings together for title

File Changes

(2 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916@github.com>

VZ

unread,
Oct 27, 2024, 8:39:56 AMOct 27
to wx-...@googlegroups.com, Subscribed

@vadz commented on this pull request.

Thanks, I'll merge it with the changes proposed below if you don't mind.


In src/html/htmprint.cpp:

>  
-    num.Printf(wxT("%lu"), (unsigned long)(m_PageBreaks.size() - 1));
-    r.Replace(wxT("@PAGESCNT@"), num);
+    num.Printf("%lu", (unsigned long)(m_PageBreaks.size() - 1));

As long as we're modifying this, we should make it

⬇️ Suggested change
-    num.Printf("%lu", (unsigned long)(m_PageBreaks.size() - 1));
+    num.Printf("%zu", m_PageBreaks.size() - 1);

In src/html/htmprint.cpp:

> +                                               m_ParentWindow ?
+                                                   m_ParentWindow->FromDIP(wxSize(650, 500)) :
+                                                   wxSize(650, 500));

This can be written more simply as

⬇️ Suggested change
-                                               m_ParentWindow ?
-                                                   m_ParentWindow->FromDIP(wxSize(650, 500)) :
-                                                   wxSize(650, 500));
+                                               wxWindow::FromDIP(wxSize(650, 500), m_ParentWindow));

In src/html/htmprint.cpp:

> @@ -709,8 +709,11 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr
     }
 
     wxPreviewFrame *frame = new wxPreviewFrame(preview, m_ParentWindow,
-                                               m_Name + _(" Preview"),
-                                               wxPoint(100, 100), wxSize(650, 500));
+                                               wxString::Format(_("%s Preview"), m_Name),
+                                               wxPoint(100, 100),

Probably should use wxDefaultPosition here.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/review/2397522793@github.com>

Blake-Madden

unread,
Oct 27, 2024, 9:26:23 AMOct 27
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • 26bb353 Use size_t format specifier


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/6215c518e5bbe18bb32aedc4511f4f9c684cbc06/after/26bb35312762c1b8da352d8a52c6eff1356b442c@github.com>

Blake-Madden

unread,
Oct 27, 2024, 9:26:55 AMOct 27
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/26bb35312762c1b8da352d8a52c6eff1356b442c/after/e380d7d3051cd8ed686d5cf8f8a840b622ee2f6f@github.com>

Blake-Madden

unread,
Oct 27, 2024, 9:28:38 AMOct 27
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/html/htmprint.cpp:

> @@ -709,8 +709,11 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr
     }
 
     wxPreviewFrame *frame = new wxPreviewFrame(preview, m_ParentWindow,
-                                               m_Name + _(" Preview"),
-                                               wxPoint(100, 100), wxSize(650, 500));
+                                               wxString::Format(_("%s Preview"), m_Name),
+                                               wxPoint(100, 100),

I thought that too when I saw it centering the window in the next line, but left it alone for fear of appearing too nit-picky :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/review/2397552534@github.com>

Blake-Madden

unread,
Oct 27, 2024, 9:30:42 AMOct 27
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/e380d7d3051cd8ed686d5cf8f8a840b622ee2f6f/after/e4072395b0f0b4b2a777c325c352ac10fa3a7dd8@github.com>

Lauri Nurmi

unread,
Oct 27, 2024, 4:34:00 PMOct 27
to wx-...@googlegroups.com, Subscribed

@lanurmi commented on this pull request.


In include/wx/html/htmprint.h:

> @@ -231,7 +231,7 @@ class WXDLLIMPEXP_HTML wxHtmlPrintout : public wxPrintout
 class WXDLLIMPEXP_HTML wxHtmlEasyPrinting : public wxObject
 {
 public:
-    wxHtmlEasyPrinting(const wxString& name = wxT("Printing"), wxWindow *parentWindow = nullptr);
+    wxHtmlEasyPrinting(const wxString& name = _("Printing"), wxWindow *parentWindow = nullptr);

As all of these are individual words marked as translatable, they could use a /* TRANSLATORS: ... */ comment to clarify what the string actually means, and in what context.

For instance, does "Printing" mean the same as "printout" (as a noun), or does it mean "now printing a document".


In src/html/htmprint.cpp:

> @@ -709,8 +709,9 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr
     }
 
     wxPreviewFrame *frame = new wxPreviewFrame(preview, m_ParentWindow,
-                                               m_Name + _(" Preview"),
-                                               wxPoint(100, 100), wxSize(650, 500));
+                                               wxString::Format(_("%s Preview"), m_Name),

Also here, a TRANSLATORS: comment could clarify that this related to rpinting, and that %s is a name (of a document?).


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/review/2397612585@github.com>

Blake-Madden

unread,
Oct 28, 2024, 10:09:07 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • e9eee4f Add wxGETTEXT_IN_CONTEXT to explain context of translatable strings


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/e4072395b0f0b4b2a777c325c352ac10fa3a7dd8/after/e9eee4fd23e05af9b87567c0795f5adf20e9b72d@github.com>

Blake-Madden

unread,
Oct 28, 2024, 10:09:47 AMOct 28
to wx-...@googlegroups.com, Subscribed

@Blake-Madden commented on this pull request.


In src/html/htmprint.cpp:

> @@ -709,8 +709,9 @@ bool wxHtmlEasyPrinting::DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *pr
     }
 
     wxPreviewFrame *frame = new wxPreviewFrame(preview, m_ParentWindow,
-                                               m_Name + _(" Preview"),
-                                               wxPoint(100, 100), wxSize(650, 500));
+                                               wxString::Format(_("%s Preview"), m_Name),

Got it. I added wxGETTEXT_IN_CONTEXT to all the strings. Thanks.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/review/2399208981@github.com>

Blake-Madden

unread,
Oct 28, 2024, 10:27:41 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • 802da65 Use wxGetTranslation instead of wxGETTEXT_IN_CONTEXT


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/e9eee4fd23e05af9b87567c0795f5adf20e9b72d/after/802da6554560b35d104c2ac97d07ba361ff77d81@github.com>

Lauri Nurmi

unread,
Oct 28, 2024, 10:57:58 AMOct 28
to wx-...@googlegroups.com, Subscribed

@lanurmi commented on this pull request.

I don't think this will work at all, for various reasons. Firstly, passing the formatted and localized "%s Preview" to wxGetTranslation() means a translation will virtually never be found for the argument. wxGetTranslation() (or _()) within wxGetTranslation() cannot be right.

Also the messages will not be properly picked with context by xgettext, if calling wxGetTranslation() with multiple arguments. wxGETTEXT_IN_CONTEXT` is what should be used when dealing with string literals.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/review/2399356623@github.com>

Blake-Madden

unread,
Oct 28, 2024, 10:58:21 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • adbc6a4 Wrap strings in wxString to fix type ambiguity


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/802da6554560b35d104c2ac97d07ba361ff77d81/after/adbc6a42b842672f29f2e8a18307b210938a72ba@github.com>

Blake-Madden

unread,
Oct 28, 2024, 11:04:10 AMOct 28
to wx-...@googlegroups.com, Subscribed

wxGETTEXT_IN_CONTEXT is what should be used when dealing with string literals.

Some compilers are failing with wxGETTEXT_IN_CONTEXT, complaining about ambiguity between const char* and unsigned int. I was calling wxGETTEXT_IN_CONTEXT the same way it is called throughout the rest of the wx code base, so I have no idea what compiles in other places but not here.

So, for wxGETTEXT_IN_CONTEXT, what is the proper way to call it? With an 'L' in front of the literal string? Or wrap it in a wxString CTOR? Again, I tried simply calling wxGETTEXT_IN_CONTEXT with string literals like I see in many other places, but 4 or so build environments fail.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2441846201@github.com>

Blake-Madden

unread,
Oct 28, 2024, 11:09:52 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • 94d10ba Use wxGETTEXT_IN_CONTEXT, wrap literal string in wxString CTOR to fix ambiguity compile errors


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/adbc6a42b842672f29f2e8a18307b210938a72ba/after/94d10ba2ad6f31ead4731a7fb90be3405affadfb@github.com>

Blake-Madden

unread,
Oct 28, 2024, 11:34:16 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • 187e57a Try wide string literals with wxGETTEXT_IN_CONTEXT


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/94d10ba2ad6f31ead4731a7fb90be3405affadfb/after/187e57a505eb4f56d10d7662b67e95ccaed45c76@github.com>

Blake-Madden

unread,
Oct 28, 2024, 11:39:01 AMOct 28
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.

  • f7866f2 Remove wxGETTEXT_IN_CONTEXT


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/187e57a505eb4f56d10d7662b67e95ccaed45c76/after/f7866f2fcaf6eb017ddcd7d3ca083e7a1e9930b7@github.com>

Blake-Madden

unread,
Oct 28, 2024, 11:40:49 AMOct 28
to wx-...@googlegroups.com, Subscribed

I cannot get wxGETTEXT_IN_CONTEXT to compile with string literals in all build environments. I have tried wxString CTOR wrappers, L wide strings, char*, etc. Rolling back to simple _() calls.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2441943225@github.com>

Blake-Madden

unread,
Oct 28, 2024, 4:16:40 PMOct 28
to wx-...@googlegroups.com, Subscribed

AppVeyor "failed" configuration says "All tests passed (1162787 assertions in 385 test cases)".

This seems to be good to go.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2442535743@github.com>

Lauri Nurmi

unread,
Oct 28, 2024, 4:35:55 PMOct 28
to wx-...@googlegroups.com, Subscribed

This seems to be good to go.

It is still entirely possible to add the /* TRANSLATORS: ... */ comments that I suggested earlier.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2442571968@github.com>

Maarten

unread,
Oct 28, 2024, 4:49:53 PMOct 28
to wx-...@googlegroups.com, Subscribed

This seems to be good to go.

It runs two tests, test.exe and test_gui.exe. It seems the second one got stuck and AppVeyor timed out after 1 hour. I think this sometimes randomly happens.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2442600521@github.com>

Blake-Madden

unread,
Oct 29, 2024, 8:19:45 AMOct 29
to wx-...@googlegroups.com, Push

@Blake-Madden pushed 1 commit.


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/before/f7866f2fcaf6eb017ddcd7d3ca083e7a1e9930b7/after/0677b75952ece8e5dfe07c7a382971cedf53b01f@github.com>

Blake-Madden

unread,
Oct 29, 2024, 8:23:14 AMOct 29
to wx-...@googlegroups.com, Subscribed

Translator comments are in there now :)


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2444062775@github.com>

Blake-Madden

unread,
Oct 29, 2024, 9:30:52 AMOct 29
to wx-...@googlegroups.com, Subscribed

Failure is from unrelated "CHECK( m_browser->GetCurrentTitle() == "Title" )"


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/c2444242006@github.com>

VZ

unread,
Nov 1, 2024, 11:05:28 PM (11 days ago) Nov 1
to wx-...@googlegroups.com, Subscribed

Closed #24916 via 48df3a3.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/24916/issue_event/15076378769@github.com>

Reply all
Reply to author
Forward
0 new messages