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, "");
35 setlocale(LC_NUMERIC, "C");
37 bindtextdomain(domain, dir ? dir : default_dir);
38 bind_textdomain_codeset(domain, DEFAULT_CODESET);
45 const char *sgettext(const char *msgid)
48 const char *msgval = gettext(msgid);
50 const char *msgval = msgid;
55 if ((msgval = strrchr(msgid, '^')))
62 const char *get_local_text(const char *msgid)
65 char *msgstr, *domain = textdomain(NULL);
67 bind_textdomain_codeset(domain, "");
68 msgstr = gettext(msgid);
69 bind_textdomain_codeset(domain, DEFAULT_CODESET);
77 /*---------------------------------------------------------------------------*/