looper/translation.h
Zachary Hall 3ea8e9707e Remove currentLanguage for now
Also remove icon.h from the index
2023-07-25 06:59:23 -07:00

22 lines
No EOL
922 B
C++

#pragma once
#include <libintl.h>
#include <string>
#include <vector>
// Based on the code found in gettext.h, but without any additionall things we don't need.
inline static const char *gettext_ctx(const char *ctx, const char *msgid) {
const char *msg_ctxt_id = (std::string(ctx) + std::string("\004") + std::string(msgid)).c_str();
const char *translation = gettext(msg_ctxt_id);
if (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()