libnick 2024.9.2
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
gettext.h
Go to the documentation of this file.
1
23#ifndef GETTEXT_H
24#define GETTEXT_H
25
26#include <string>
27#include <libintl.h>
28
29#define GETTEXT_CONTEXT_SEPARATOR "\004"
30#define _(String) dgettext(::Nickvision::Localization::Gettext::getDomainName().c_str(), String)
31#define _n(String, StringPlural, N) dngettext(::Nickvision::Localization::Gettext::getDomainName().c_str(), String, StringPlural, static_cast<unsigned long>(N))
32#define _p(Context, String) ::Nickvision::Localization::Gettext::pgettext(Context GETTEXT_CONTEXT_SEPARATOR String, String)
33#define _pn(Context, String, StringPlural, N) ::Nickvision::Localization::Gettext::pngettext(Context GETTEXT_CONTEXT_SEPARATOR String, String, StringPlural, static_cast<unsigned long>(N))
34
36{
42 bool init(const std::string& domainName);
47 const std::string& getDomainName();
54 const char* pgettext(const char* context, const char* msg);
63 const char* pngettext(const char* context, const char* msg, const char* msgPlural, unsigned long n);
64}
65
66#endif //GETTEXT_H
Definition gettext.h:36
const std::string & getDomainName()
Gets the domain name used for gettext translations.
const char * pgettext(const char *context, const char *msg)
Translates a message for a given context.
const char * pngettext(const char *context, const char *msg, const char *msgPlural, unsigned long n)
Translates a plural message for a given context.
bool init(const std::string &domainName)
Initializes the gettext system. This function should only be called once, regardless of with differen...