Macros for translatable strings that need disambiguating context

This commit is contained in:
Paul Licameli 2020-05-20 13:41:39 -04:00
parent 7c246ddc26
commit 4e2f9671ff
2 changed files with 12 additions and 2 deletions

View File

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

View File

@ -32,7 +32,13 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
// '&', preceding menu accelerators, should NOT occur in the argument.
#define XO(s) (TranslatableString{ wxT(s), {} })
// Marks strings for extraction only, where '&', preceding men accelerators, MAY
// Alternative taking a second context argument. A context is a string literal,
// which is not translated, but serves to disambiguate uses of the first string
// that might need differing translations, such as "Light" meaning not-heavy in
// one place but not-dark elsewhere.
#define XC(s, c) (TranslatableString{ wxT(s), {} }.Context(c))
// Marks strings for extraction only, where '&', preceding menu accelerators, MAY
// occur.
// For now, expands exactly as macro XO does, but in future there will be a
// type distinction - for example XXO should be used for menu item names that
@ -86,6 +92,10 @@ extern AUDACITY_DLL_API const wxString& GetCustomSubstitution(const wxString& st
#define XP(sing, plur, n) \
TranslatableString{ wxT(sing), {} }.Plural<(n)>( wxT(plur) )
// Like XP but with an additional context argument, as for XC
#define XPC(sing, plur, n, c) \
TranslatableString{ wxT(sing), {} }.Context(c).Plural<(n)>( wxT(plur) )
#endif
class Internat