Oops! Fixed newly envmapped glass being scheduled as opaque.
[neverball] / share / lang.c
1 /*
2  * Copyright (C) 2006 Jean Privat
3  * Part of the Neverball Project http://icculus.org/neverball/
4  *
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.
9  *
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.
14  */
15
16 #include <string.h>
17 #include <locale.h>
18 #include <stdlib.h>
19 #include <stdio.h>
20
21 #include "lang.h"
22
23 /*---------------------------------------------------------------------------*/
24
25 #define DEFAULT_CODESET "UTF-8"
26
27 /*---------------------------------------------------------------------------*/
28
29 void lang_init(const char *domain, const char *default_dir)
30 {
31 #if ENABLE_NLS
32     char *dir = getenv("NEVERBALL_LOCALE");
33
34     setlocale(LC_ALL, "");
35
36     bindtextdomain(domain, dir ? dir : default_dir);
37     bind_textdomain_codeset(domain, DEFAULT_CODESET);
38     textdomain(domain);
39 #else
40     return;
41 #endif
42 }
43
44 const char *sgettext(const char *msgid)
45 {
46 #if ENABLE_NLS
47     const char *msgval = gettext(msgid);
48 #else
49     const char *msgval = msgid;
50 #endif
51
52     if (msgval == msgid)
53     {
54         if ((msgval = strrchr(msgid, '^')))
55             msgval++;
56         else msgval = msgid;
57     }
58     return msgval;
59 }
60
61 const char *get_local_text(const char *msgid)
62 {
63 #if ENABLE_NLS
64     char *msgstr, *domain = textdomain(NULL);
65
66     bind_textdomain_codeset(domain, "");
67     msgstr = gettext(msgid);
68     bind_textdomain_codeset(domain, DEFAULT_CODESET);
69
70     return msgstr;
71 #else
72     return msgid;
73 #endif
74 }
75
76 /*---------------------------------------------------------------------------*/