Made vgettext/vngetext internals harder to use accidentally (resolves #2716)
Also removed the two implementation function overloads that did not take a textdomain.
This commit is contained in:
parent
43252e8191
commit
78ab1faeaa
2 changed files with 32 additions and 32 deletions
|
@ -281,14 +281,7 @@ std::string format_disjunct_list(const t_string& empty, const std::vector<t_stri
|
|||
|
||||
}
|
||||
|
||||
std::string vgettext(const char *msgid, const utils::string_map& symbols)
|
||||
{
|
||||
const std::string orig(_(msgid));
|
||||
const std::string msg = utils::interpolate_variables_into_string(orig, &symbols);
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::string vgettext(const char *domain
|
||||
std::string vgettext_impl(const char *domain
|
||||
, const char *msgid
|
||||
, const utils::string_map& symbols)
|
||||
{
|
||||
|
@ -296,16 +289,14 @@ std::string vgettext(const char *domain
|
|||
const std::string msg = utils::interpolate_variables_into_string(orig, &symbols);
|
||||
return msg;
|
||||
}
|
||||
std::string vngettext(const char* sing, const char* plur, int n, const utils::string_map& symbols)
|
||||
{
|
||||
const std::string orig(_n(sing, plur, n));
|
||||
const std::string msg = utils::interpolate_variables_into_string(orig, &symbols);
|
||||
return msg;
|
||||
}
|
||||
|
||||
std::string vngettext(const char *domain, const char *sing, const char* plur, int n, const utils::string_map& symbols)
|
||||
std::string vngettext_impl(const char* domain,
|
||||
const char* singular,
|
||||
const char* plural,
|
||||
int count,
|
||||
const utils::string_map& symbols)
|
||||
{
|
||||
const std::string orig(translation::dsngettext(domain, sing, plur, n));
|
||||
const std::string orig(translation::dsngettext(domain, singular, plural, count));
|
||||
const std::string msg = utils::interpolate_variables_into_string(orig, &symbols);
|
||||
return msg;
|
||||
}
|
||||
|
|
|
@ -76,23 +76,32 @@ std::string format_disjunct_list(const t_string& empty, const std::vector<t_stri
|
|||
|
||||
}
|
||||
|
||||
/** Handy wrappers around interpolate_variables_into_string and gettext. */
|
||||
std::string vgettext(const char* msgid, const utils::string_map& symbols);
|
||||
std::string vgettext(const char* domain
|
||||
, const char* msgid
|
||||
, const utils::string_map& symbols);
|
||||
|
||||
std::string vngettext(const char*, const char*, int, const utils::string_map&);
|
||||
|
||||
std::string vngettext(const char*, const char*, const char*, int, const utils::string_map&);
|
||||
|
||||
/**
|
||||
* @todo Convert all functions.
|
||||
* Implementation functions for the VGETTEXT and VNGETTEXT macros.
|
||||
*
|
||||
* All function in this file should have an overloaded version with a domain
|
||||
* and probably convert all callers to use the macro instead of directly calling
|
||||
* the function.
|
||||
* DO NOT USE DIRECTLY unless you really know what you're doing.
|
||||
* See https://github.com/wesnoth/wesnoth/issues/2716 for more info.
|
||||
*/
|
||||
|
||||
#define VGETTEXT(msgid, ...) vgettext(GETTEXT_DOMAIN, msgid, __VA_ARGS__)
|
||||
#define VNGETTEXT(msgid, msgid_plural, count, ...) vngettext(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__)
|
||||
std::string vgettext_impl(const char* domain, const char* msgid, const utils::string_map& symbols);
|
||||
|
||||
std::string vngettext_impl(const char* domain,
|
||||
const char* singular,
|
||||
const char* plural,
|
||||
int count,
|
||||
const utils::string_map& symbols);
|
||||
|
||||
/**
|
||||
* Handy wrappers around interpolate_variables_into_string and gettext.
|
||||
*
|
||||
* These should cover most usecases. If you're not sure whether you want
|
||||
* these macros or their implementation functions, use these. The only time
|
||||
* you should need to use the implementation functions directly is to pass a
|
||||
* different textdomain than the current value of GETTEXT_DOMAIN.
|
||||
*/
|
||||
|
||||
#define VGETTEXT(msgid, ...) \
|
||||
vgettext_impl(GETTEXT_DOMAIN, msgid, __VA_ARGS__)
|
||||
|
||||
#define VNGETTEXT(msgid, msgid_plural, count, ...) \
|
||||
vngettext_impl(GETTEXT_DOMAIN, msgid, msgid_plural, count, __VA_ARGS__)
|
||||
|
|
Loading…
Add table
Reference in a new issue