13#include <wx/translation.h>
26 case Request::Context:
27 return NullContextName;
29 case Request::DebugFormat:
43 auto prevFormatter = mFormatter;
44 mFormatter = [prevFormatter, codes]
47 case Request::Context:
50 case Request::DebugFormat:
52 bool debug = request == Request::DebugFormat;
58 if ( codes & MenuCodes ) {
61 decltype( result ) temp;
63 for (
auto iter = temp.begin(),
end = temp.end();
64 iter !=
end; ++iter ) {
69 if ( *iter ==
'&' && ++iter ==
end )
71 result.append( 1, *iter );
74 if ( codes & Ellipses ) {
75 if (result.EndsWith(
wxT(
"...")))
76 result = result.Left( result.length() - 3 );
78 else if (result.EndsWith(
wxT(
"\u2026")))
79 result = result.Left( result.length() - 1 );
95 const wxString &
format,
const wxString &context,
bool debug )
100 ( debug ?
format : wxGetTranslation(
format, wxString{}, context ) );
105 const wxString &singular,
const wxString &plural,
unsigned nn,
bool debug )
114 ? ( nn == 1 ? singular : plural )
127 auto prevFormatter = mFormatter;
131 separator](
const wxString &
str,
Request request)
134 case Request::Context:
136 case Request::Format:
137 case Request::DebugFormat:
139 bool debug = request == Request::DebugFormat;
145 + arg.DoFormat( debug );
#define HAS_I18N_CONTEXTS
An explicitly nonlocalized string, not meant for the user to see.
Class to construct the HTTP request.
Holds a msgid for the translation catalog; may also bind format arguments.
static wxString DoChooseFormat(const Formatter &formatter, const wxString &singular, const wxString &plural, unsigned nn, bool debug)
Identifier MSGID() const
MSGID is the English lookup key in the catalog, not necessarily for user's eyes if locale is some oth...
static const wxChar *const NullContextName
@ Format
Given the msgid, format the string for end users.
@ DebugFormat
Given the msgid, format the string for developers.
@ Context
return a disambiguating context string
std::function< wxString(const wxString &, Request) > Formatter
A multi-purpose function, depending on the enum argument.
static const TranslatableString Inaudible
A special string value that will have no screen reader pronunciation.
static wxString DoGetContext(const Formatter &formatter)
bool IsVerbatim() const
Returns true if context is NullContextFormatter.
TranslatableString & Strip(unsigned options=MenuCodes) &
static wxString DoSubstitute(const Formatter &formatter, const wxString &format, const wxString &context, bool debug)
TranslatableString & Join(TranslatableString arg, const wxString &separator={}) &
Append another translatable string.
static const Formatter NullContextFormatter
const char * end(const char *str) noexcept