33 #define DBG_G LOG_STREAM(debug, lg::general)
34 #define LOG_G LOG_STREAM(info, lg::general)
35 #define WRN_G LOG_STREAM(warn, lg::general)
36 #define ERR_G LOG_STREAM(err, lg::general)
45 return msgid[0] ==
'\0' ? msgid : (
::gettext)(msgid);
50 bind_textdomain_codeset(domainname,
"UTF-8");
51 const char *msgval =
::dgettext (domainname, msgid);
52 if (msgval == msgid) {
53 msgval = std::strrchr (msgid,
'^');
54 if (msgval ==
nullptr)
64 const char*
sgettext (
const char *msgid)
66 const char *msgval =
gettext (msgid);
67 if (msgval == msgid) {
68 msgval = std::strrchr (msgid,
'^');
69 if (msgval ==
nullptr)
77 const char*
sngettext (
const char *singular,
const char *plural,
int n)
79 const char *msgval = ngettext (singular, plural, n);
80 if (msgval == singular) {
81 msgval = std::strrchr (singular,
'^');
82 if (msgval ==
nullptr)
93 bind_textdomain_codeset(domainname,
"UTF-8");
94 const char *msgval = ::dngettext (domainname, singular, plural, n);
95 if (msgval == singular) {
96 msgval = std::strrchr (singular,
'^');
97 if (msgval ==
nullptr)
107 if(domain !=
nullptr && strchr(domain,
'/') !=
nullptr) {
110 ERR_G <<
"illegal textdomain name '" << domain
111 <<
"', skipping textdomain\n";
115 if(directory !=
nullptr)
116 bindtextdomain(domain, directory);
117 if(encoding !=
nullptr)
118 bind_textdomain_codeset(domain, encoding);
140 SetEnvironmentVariableA(
"LANG", win_locale.c_str());
142 _putenv(env.c_str());
146 unsetenv (
"LANGUAGE");
148 if (setenv(
"LANG", locale.c_str(), 1) == -1) {
149 ERR_G <<
"setenv LANG failed: " << strerror(errno);
154 std::vector<std::string>::const_iterator
i;
155 if (alternates) i = alternates->begin();
160 std::string::size_type
pos = locale.find(
'@');
161 if (pos != std::string::npos) {
163 extra = locale.substr(pos);
170 char const *encoding[] = {
".utf-8",
".UTF-8",
"" };
171 for (
int j = 0; j != 3; ++j)
173 locale = lang + encoding[j] + extra;
174 res = std::setlocale(LC_MESSAGES, locale.c_str());
176 LOG_G <<
"Set locale to '" << locale <<
"' result: '" << res <<
"'.\n";
181 if (!alternates || i == alternates->end())
break;
185 WRN_G <<
"setlocale() failed for '" << slocale <<
"'." << std::endl;
192 std::setlocale(LC_MESSAGES,
"");
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
std::string dsngettext(const char *domainname, const char *singular, const char *plural, int n)
std::string dgettext(const char *domain, const char *msgid)
void set_language(const std::string &slocale, const std::vector< std::string > *alternates)
std::string dsgettext(const char *domainname, const char *msgid)
void bind_textdomain(const char *domain, const char *directory, const char *encoding)
void set_default_textdomain(const char *domain)
static UNUSEDNOWARN std::string gettext(const char *str)
std::string egettext(char const *msgid)
static UNUSEDNOWARN std::string sgettext(const char *str)
Standard logging facilities (interface).
static UNUSEDNOWARN std::string sngettext(const char *str1, const char *str2, int n)
GLsizei const GLcharARB ** string