translated main menu to german, omitting header info in gettext calls, libs, test gettext call in menuitem render
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4629 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "weapon.h"
|
||||
#include "entity.h"
|
||||
#include "world.h"
|
||||
#include "i18n.h"
|
||||
|
||||
#ifndef STANDALONE
|
||||
#include "command.h"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// internationalization and localization
|
||||
|
||||
#include "pch.h"
|
||||
#include "cube.h"
|
||||
|
||||
i18nmanager::i18nmanager(const char *domain, const char *basepath) : domain(domain), basepath(basepath)
|
||||
{
|
||||
locale = setlocale(LC_ALL, ""); // use current default locale
|
||||
bindtextdomain(domain, basepath); // set base path
|
||||
textdomain(domain);
|
||||
|
||||
printf("current locale: %s\n", locale);
|
||||
|
||||
printf(_("hello world\n")); // test output
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
// internationalization and localization
|
||||
|
||||
// localization manager
|
||||
struct i18nmanager
|
||||
{
|
||||
const char *basepath;
|
||||
const char *domain;
|
||||
char *locale;
|
||||
|
||||
i18nmanager(const char *domain, const char *basepath); // initialize locale system
|
||||
|
||||
};
|
||||
@@ -606,6 +606,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
if(!quitdirectly)
|
||||
{
|
||||
i18nmanager i18n("AC", path("packages/locale", true));
|
||||
|
||||
initing = NOT_INITING;
|
||||
|
||||
initlog("sdl");
|
||||
|
||||
@@ -158,7 +158,7 @@ struct mitemmanual : mitem
|
||||
virtual void render(int x, int y, int w)
|
||||
{
|
||||
mitem::render(x, y, w);
|
||||
draw_text(text, x, y);
|
||||
draw_text(_(text), x, y);
|
||||
}
|
||||
|
||||
virtual void focus(bool on)
|
||||
|
||||
+9
-1
@@ -638,7 +638,15 @@ inline char *newstring(const char *s) { return newstring(s, strlen(s))
|
||||
inline char *newstringbuf() { return newstring(_MAXDEFSTR-1); }
|
||||
inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); }
|
||||
|
||||
#define _(STRING) gettext(STRING)
|
||||
inline char *_gettext(const char *msgid)
|
||||
{
|
||||
if(msgid && msgid[0] != '\0')
|
||||
return gettext(msgid);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
#define _(s) _gettext(s)
|
||||
|
||||
extern const char *timestring(bool local = false, const char *fmt = NULL);
|
||||
extern const char *asctime();
|
||||
|
||||
Reference in New Issue
Block a user