Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gettext literal #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Gettext literal #3

wants to merge 1 commit into from

Conversation

lanurmi
Copy link
Owner

@lanurmi lanurmi commented Nov 14, 2024

No description provided.

Point translation macros to wrapper functions that only accept
string literals. This is a backward-incompatible change,
though most incompatibilities found are likely to be bugs.

While at present the arguments do not technically need to be string
literals, variables can easily introduce subtle bugs that are not
obvious to spot. The fact that xgettext only picks string literals
is easy to forget.

Consider  the following code:
wxString itm("item");
_(itm);
wxGETTEXT_IN_CONTEXT("context_1", itm);
wxGETTEXT_IN_CONTEXT(itm, "item");
wxPLURAL(wxString::Format("%s", "singX"), "plurX", 1);
wxPLURAL("singY", wxString::Format("%s", "plurY"), 2);
wxGETTEXT_IN_CONTEXT_PLURAL("context_1", _("singZ"), "plurZ", 1);

All of these lines compile without warnings. However, only one string,
"singZ", is picked by xgettext, all others are silently ignored. Some
lines would work if accompanied by a proper wxTRANSLATE* call, but nested
calls (see the last line) to translation macros do not make sense in the
first place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant