26 lines
No EOL
1.1 KiB
C++
26 lines
No EOL
1.1 KiB
C++
#pragma once
|
|
#include <libintl.h>
|
|
#include <string>
|
|
#include <vector>
|
|
// Based on the code found in gettext.h, but without any additional things we don't need.
|
|
inline static const char *gettext_ctx(const char *ctx, const char *msgid) {
|
|
std::string msg_ctxt_id = (std::string(ctx) + std::string("\004") + std::string(msgid));
|
|
const char *translation = gettext(msg_ctxt_id.c_str());
|
|
if (std::string(translation) == msg_ctxt_id) {
|
|
return msgid;
|
|
} else {
|
|
return translation;
|
|
}
|
|
}
|
|
#define _TR(str) gettext(str)
|
|
#define _TR_CTX(ctx, str) gettext_ctx(ctx, str)
|
|
#define _TRS(str) std::string(_TR(str))
|
|
#define _TRS_CTX(ctx, str) std::string(_TR_CTX(ctx, str))
|
|
#define _TRIS(icon, str) (std::string(icon) + _TRS(str))
|
|
#define _TRI(icon, str) _TRIS(icon, str).c_str()
|
|
#define _TRIS_CTX(icon, ctx, str) (std::string(icon) + _TRS_CTX(ctx, str))
|
|
#define _TRI_CTX(icon, ctx, str) _TRIS_CTX(icon, ctx, str).c_str()
|
|
#define CURRENT_LANGUAGE setlocale(LC_MESSAGES, NULL)
|
|
// The value required to set the operating system's default language.
|
|
#define DEFAULT_LANG ""
|
|
#define SET_LANG(lang) setlocale(LC_MESSAGES, lang) |