2 * Copyright (C) 2006 Jean Privat
3 * Part of the Neverball Project http://icculus.org/neverball/
5 * NEVERBALL is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published
7 * by the Free Software Foundation; either version 2 of the License,
8 * or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
23 /*---------------------------------------------------------------------------*/
25 #define DEFAULT_CODESET "UTF-8"
27 /*---------------------------------------------------------------------------*/
29 void lang_init(const char *domain, const char *default_dir)
32 char *dir = getenv("NEVERBALL_LOCALE");
34 setlocale(LC_ALL, "");
36 bindtextdomain(domain, dir ? dir : default_dir);
37 bind_textdomain_codeset(domain, DEFAULT_CODESET);
44 const char *sgettext(const char *msgid)
47 const char *msgval = gettext(msgid);
49 const char *msgval = msgid;
54 if ((msgval = strrchr(msgid, '^')))
61 const char *get_local_text(const char *msgid)
64 char *msgstr, *domain = textdomain(NULL);
66 bind_textdomain_codeset(domain, "");
67 msgstr = gettext(msgid);
68 bind_textdomain_codeset(domain, DEFAULT_CODESET);
76 /*---------------------------------------------------------------------------*/