Rename macro wxPLURAL as XP (brief, and eliminates mention of "wx")

This commit is contained in:
Paul Licameli 2020-05-20 12:38:44 -04:00
parent 6286772049
commit f8a070dde7
7 changed files with 13 additions and 12 deletions

View File

@ -441,7 +441,7 @@ public:
return *this;
}
// Implements the wxPLURAL macro, which specifies a second msgid, a list
// Implements the XP macro, which specifies a second msgid, a list
// of format arguments, and which of those format arguments selects among
// messages; the translated strings to select among, depending on language,
// might actually be more or fewer than two. See Internat.h.

View File

@ -5,7 +5,7 @@ sed -E 's/\.\.\///g' |\
xargs xgettext \
--default-domain=audacity \
--directory=.. \
--keyword=_ --keyword=XO --keyword=XXO --keyword=wxPLURAL:1,2 \
--keyword=_ --keyword=XO --keyword=XXO --keyword=XP:1,2 \
--add-comments=" i18n" \
--add-location=file \
--copyright-holder='Audacity Team' \

View File

@ -60,8 +60,8 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
#define _(s) GetCustomTranslation((s))
#endif
#ifdef wxPLURAL
#undef wxPLURAL
#ifdef XP
#undef XP
#endif
@ -73,7 +73,7 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
// which (intentionally) will fail to compile. The macro inserts wxT).
//
// Note too: it seems an i18n-hint comment is not extracted if it precedes
// wxPLURAL directly. A workaround: after the comment, insert a line
// XP directly. A workaround: after the comment, insert a line
// _("dummyStringXXXX");
// where for XXXX subsitute something making this dummy string unique in the
// program. Then check in your generated audacity.pot that the dummy is
@ -85,7 +85,7 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
// The macro call is then followed by a sequence of format arguments in
// parentheses. The third argument of the macro call is the zero-based index
// of the format argument that selects singular or plural
#define wxPLURAL(sing, plur, n) \
#define XP(sing, plur, n) \
TranslatableString{ wxT(sing), {} }.Plural<(n)>( wxT(plur) )
#endif

View File

@ -1897,7 +1897,7 @@ bool PluginManager::DropFile(const wxString &fileName)
// Ask whether to enable the plug-ins
if (auto nIds = ids.size()) {
auto message = wxPLURAL(
auto message = XP(
"Enable this plug-in?\n",
"Enable these plug-ins?\n",
0

View File

@ -1044,9 +1044,9 @@ TranslatableString ProjectManager::GetHoursMinsString(int iMinutes)
int iHours = iMinutes / 60;
int iMins = iMinutes % 60;
auto sHours = wxPLURAL( "%d hour", "%d hours", 0 )( iHours );
auto sHours = XP( "%d hour", "%d hours", 0 )( iHours );
auto sMins = wxPLURAL( "%d minute", "%d minutes", 0 )( iMins );
auto sMins = XP( "%d minute", "%d minutes", 0 )( iMins );
/* i18n-hint: A time in hours and minutes. Only translate the "and". */
return XO("%s and %s.").Format( sHours, sMins );

View File

@ -3371,6 +3371,7 @@ static void RegisterFunctions()
// All function names must be UP-CASED
static const FUNDEF functions[] = {
{ "_", SUBR, gettext },
// to do: more i18n functions, for contexts and plurals
{ "NGETTEXT", SUBR, ngettext },
{ "AUD-DO", SUBR, xlc_aud_do },
};

View File

@ -328,7 +328,7 @@ TranslatableString ClipBoundaryMessage(
clips.
*/
XO("dummyStringClipBoundaryMessage");
str = wxPLURAL(
str = XP(
"%s %d of %d clip %s",
"%s %d of %d clips %s",
2
@ -350,7 +350,7 @@ TranslatableString ClipBoundaryMessage(
clips.
*/
XO("dummyStringClipBoundaryMessageLong");
str = wxPLURAL(
str = XP(
"%s %d and %s %d of %d clip %s",
"%s %d and %s %d of %d clips %s",
4
@ -586,7 +586,7 @@ void DoSelectClip(AudacityProject &project, bool next)
last number counts the clips,
string names a track */
XO("dummyStringOnSelectClip");
auto str = wxPLURAL(
auto str = XP(
"%d of %d clip %s",
"%d of %d clips %s",
1