1 /*
2 
3     eboard - chess client
4     http://www.bergo.eng.br/eboard
5     https://github.com/fbergo/eboard
6     Copyright (C) 2000-2016 Felipe Bergo
7     fbergo/at/gmail/dot/com
8 
9     This program is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13 
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, write to the Free Software
21     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22 
23 */
24 
25 #ifndef LANGS_H
26 #define LANGS_H 1
27 
28 #include <stdio.h>
29 #include "stl.h"
30 
31 class TEntry {
32  public:
33   TEntry(const char *K, const char *D);
34   virtual ~TEntry();
35 
36   bool  match(const char *testkey);
37   int   calcHash();
38   char *getData();
39 
40   static int hashOf(const char *x);
41 
42  private:
43   char *key, *data;
44 };
45 
46 class Translator {
47  public:
48   Translator();
49   virtual ~Translator();
50 
51   /* language = 0 will guess based on the environment */
52   void setContext(const char *language, const char *package,
53 		  const char *searchpath);
54 
55   const char *translate(const char *key);
56 
57  private:
58   bool ready;
59 
60   char Lang[3];
61   char SubLang[3];
62   char Package[32];
63 
64   void guessLanguage();
65   void setLanguage(const char *locale);
66   bool loadDictionary(FILE *f);
67 
68   list<TEntry *> dict[128];
69 };
70 
71 void langs_prepare(const char *language,
72 		   const char *package,
73 		   const char *searchpath);
74 
75 char * langs_translate(const char *key);
76 
77 #endif
78