1 /*
2  * Copyright (C) 2006 Jean Privat
3  *
4  * this file is  free software; you can redistribute  it and/or modify
5  * it under the  terms of the GNU General  Public License as published
6  * by the Free  Software Foundation; either version 2  of the License,
7  * or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT  ANY  WARRANTY;  without   even  the  implied  warranty  of
11  * MERCHANTABILITY or  FITNESS FOR A PARTICULAR PURPOSE.   See the GNU
12  * General Public License for more details.
13  */
14 
15 #ifndef LANG_H
16 #define LANG_H
17 
18 /*---------------------------------------------------------------------------*/
19 
20 #if ENABLE_NLS
21 
22 #include <libintl.h>
23 #define _(s) gettext(s)
24 #define gt_plural(msgid, msgid_plural, n) ngettext(msgid, msgid_plural, n)
25 
26 #else
27 
28 #define _(s) (s)
29 #define gt_plural(msgid, msgid_plural, n) ((n) == 1 ? (msgid) : (msgid_plural))
30 
31 #endif /* ENABLE_NLS */
32 
33 /* No-op, useful for marking up strings for extraction-only. */
34 #define N_(s) s
35 
36 /* Disambiguate strings with a caret-separated prefix. */
37 const char *gt_prefix(const char *);
38 
39 /*---------------------------------------------------------------------------*/
40 
41 #include "common.h"
42 #include "array.h"
43 #include "dir.h"
44 
45 struct lang_desc
46 {
47     char code[32];
48 
49     char name1[MAXSTR];
50     char name2[MAXSTR];
51     char font[MAXSTR];
52 };
53 
54 #define lang_name(desc) (*(desc)->name2 ? (desc)->name2 : (desc)->name1)
55 
56 const char *lang_path(const char *code);
57 const char *lang_code(const char *path);
58 
59 int  lang_load(struct lang_desc *, const char *);
60 void lang_free(struct lang_desc *);
61 
62 /*---------------------------------------------------------------------------*/
63 
64 #define LANG_GET(a, i) ((struct lang_desc *) DIR_ITEM_GET((a), (i))->data)
65 
66 Array lang_dir_scan(void);
67 void  lang_dir_free(Array);
68 
69 /*---------------------------------------------------------------------------*/
70 
71 extern struct lang_desc curr_lang;
72 
73 void lang_init(void);
74 void lang_quit(void);
75 
76 /*---------------------------------------------------------------------------*/
77 
78 #endif
79