]> git.lyx.org Git - lyx.git/blob - src/language.C
6a14782a18f39bfd955dd99aa2960982678b4322
[lyx.git] / src / language.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *        
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "language.h"
18 #include "gettext.h"
19 #include "encoding.h"
20
21 Languages languages;
22 Language const * default_language;
23 Language ignore_lang("ignore", "Ignore", false, 0, "ignore");
24 Language const * ignore_language = &ignore_lang;
25
26 ///
27 class LangInit {
28 public:
29         ///
30         LangInit() {
31                 if (!init) initL();
32                 init = true;
33         }
34 private:
35         ///
36         void initL();
37         ///
38         static bool init;
39 };
40
41
42 struct lang_item {
43         char const * lang;
44         char const * display;
45         bool rtl;
46         Encoding const * encoding;
47         char const * code;
48 };
49
50
51 void LangInit::initL()
52 {
53         // Use this style of initialization to lower compilation times.
54         // Same method is used in LyXAction.C (Lgb)
55
56         lang_item items[] = {
57         { "afrikaans", N_("Afrikaans"), false, &iso8859_1, "af_ZA" },
58         { "american", N_("American"), false, &iso8859_1, "en_US" },
59         { "arabic", N_("Arabic"), true, &iso8859_6, "ar_SA" },
60         { "austrian", N_("Austrian"), false, &iso8859_1, "de_AU" },
61         { "bahasa", N_("Bahasa"), false, &iso8859_1, "in_ID" },
62         { "brazil", N_("Brazil"), false, &iso8859_1, "pt_BR" },
63         { "breton", N_("Breton"), false, &iso8859_1, "br_FR" },
64         { "british", N_("British"), false, &iso8859_1, "en" },
65         { "canadian", N_("Canadian"), false, &iso8859_1, "en_CA" },
66         { "catalan", N_("Catalan"), false, &iso8859_1, "ca_ES" },
67         { "croatian", N_("Croatian"), false, &iso8859_2, "hr" },
68         { "czech", N_("Czech"), false, &iso8859_2, "cs_CZ" },
69         { "danish", N_("Danish"), false, &iso8859_1, "da_DK" },
70         { "default", N_("Document wide language"), false, &iso8859_1, "" },
71         { "dutch", N_("Dutch"), false, &iso8859_1, "nl" },
72         // changed from en_EN (Garst)
73         { "esperanto", N_("Esperanto"), false, &iso8859_3, "eo" },
74         // and what country code should esperanto have?? (Garst)
75         { "estonian", N_("Estonian"), false, &iso8859_4, "et_EE" },
76         { "finnish", N_("Finnish"), false, &iso8859_1, "fi" },
77         { "frenchb", N_("French"), false, &iso8859_1, "fr" },
78         { "frenchc", N_("French Canadien"), false, &iso8859_1, "fr_CA" },
79         { "french", N_("French (GUTenberg)"), false, &iso8859_1, "fr" },
80         { "galician", N_("Galician"), false, &iso8859_1, "gl_ES" },
81         /*There are two Galicia's, one in Spain, one in E.Europe. Because of
82         the font encoding, I am assuming this is the one in Spain. (Garst)
83         */
84         { "german", N_("German"), false, &iso8859_1, "de" },
85         { "greek", N_("Greek"), false, &iso8859_7, "el_GR" },
86         { "hebrew", N_("Hebrew"), true, &cp1255, "he_IL" },
87         /* According to Zrubecz Laszlo <zrubi@k2.jozsef.kando.hu>,
88            "magyar" is better. I kept it here in case we want
89            to  provide aliasing of languages. (JMarc) 
90         */
91         //{ "hungarian", N_("Hungarian"), false, &iso8859_2, "" },
92         { "irish", N_("Irish"), false, &iso8859_1, "ga_IE" },
93         { "italian", N_("Italian"), false, &iso8859_1, "it" },
94         { "lsorbian", N_("Lsorbian"), false, &iso8859_2, "" },
95         // no ISO listing for lsorbian (Garst)
96         { "magyar", N_("Magyar"), false, &iso8859_2, "hu" },
97         { "norsk", N_("Norsk"), false, &iso8859_1, "no" },
98         { "polish", N_("Polish"), false, &iso8859_2, "pl" },
99         { "portuges", N_("Portuges"), false, &iso8859_1, "pt" },
100         { "romanian", N_("Romanian"), false, &iso8859_2, "ro" },
101         { "russian", N_("Russian"), false, &koi8, "ru" },
102         { "scottish", N_("Scottish"), false, &iso8859_1, "gd_GB" },
103         { "spanish", N_("Spanish"), false, &iso8859_1, "es" },
104         { "slovak", N_("Slovak"), false, &iso8859_2, "sk_SL" },
105         { "slovene", N_("Slovene"), false, &iso8859_2, "sl_SI" },
106         { "swedish", N_("Swedish"), false, &iso8859_1, "sv_SE" },
107         { "turkish", N_("Turkish"), false, &iso8859_9, "tr" },
108         { "usorbian", N_("Usorbian"), false, &iso8859_2, "" },
109         // no ISO listing for usorbian (Garst)
110         { "welsh", N_("Welsh"), false, &iso8859_1, "cy_GB" },
111         { 0, 0, false, 0, 0 }
112         };
113
114         int i = 0;
115         while (items[i].lang) {
116                 languages[items[i].lang] =
117                         Language(items[i].lang, items[i].display, 
118                                  items[i].rtl, items[i].encoding,
119                                  items[i].code);
120                 ++i;
121         }
122         
123         default_language = &languages["default"];
124 }
125
126
127 static
128 LangInit langinit;
129
130 bool LangInit::init = false;