734173b8b660dacc74e696974c866f92184c9958
[reactos.git] / tools / wmc / lang.c
1 /*
2  * Wine Message Compiler language and codepage support
3  *
4  * Copyright 2000 Bertho A. Stultiens (BS)
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 #include <windows.h>
21 #include <stdio.h>
22 #include <stdlib.h>
23 #include <string.h>
24 #include <assert.h>
25
26 #include "wmc.h"
27 #include "lang.h"
28
29
30 /*
31  * Languages supported
32  *
33  * MUST be sorting ascending on language ID
34  */
35 static const language_t languages[] = {
36
37         {0x0402, 866, 1251, "Bulgarian", "Bulgaria"},
38         {0x0403, 850, 1252, "Catalan", "Spain"},
39         {0x0405, 852, 1250, "Czech", "Czech Republic"},
40         {0x0406, 850, 1252, "Danish", "Denmark"},
41         {0x0407, 850, 1252, "German", "Germany"},
42         {0x0408, 737, 1253, "Greek", "Greece"},
43         {0x0409, 437, 1252, "English", "United States"},
44         {0x040A, 850, 1252, "Spanish - Traditional Sort", "Spain"},
45         {0x040B, 850, 1252, "Finnish", "Finland"},
46         {0x040C, 850, 1252, "French", "France"},
47         {0x040E, 852, 1250, "Hungarian", "Hungary"},
48         {0x040F, 850, 1252, "Icelandic", "Iceland"},
49         {0x0410, 850, 1252, "Italian", "Italy"},
50         {0x0411, 932,  932, "Japanese", "Japan"},
51         {0x0412, 949,  949, "Korean", "Korea (south)"},
52         {0x0413, 850, 1252, "Dutch", "Netherlands"},
53         {0x0414, 850, 1252, "Norwegian (BokmÃ¥l)", "Norway"},
54         {0x0415, 852, 1250, "Polish", "Poland"},
55         {0x0416, 850, 1252, "Portuguese", "Brazil"},
56         {0x0418, 852, 1250, "Romanian", "Romania"},
57         {0x0419, 866, 1251, "Russian", "Russia"},
58         {0x041A, 852, 1250, "Croatian", "Croatia"},
59         {0x041B, 852, 1250, "Slovak", "Slovakia"},
60         {0x041C, 852, 1250, "Albanian", "Albania"},
61         {0x041D, 850, 1252, "Swedish", "Sweden"},
62         {0x041F, 857, 1254, "Turkish", "Turkey"},
63         {0x0421, 850, 1252, "Indonesian", "Indonesia"},
64         {0x0422, 866, 1251, "Ukrainian", "Ukraine"},
65         {0x0423, 866, 1251, "Belarusian", "Belarus"},
66         {0x0424, 852, 1250, "Slovene", "Slovenia"},
67         {0x0425, 775, 1257, "Estonian", "Estonia"},
68         {0x0426, 775, 1257, "Latvian", "Latvia"},
69         {0x0427, 775, 1257, "Lithuanian", "Lithuania"},
70 /*      {0x042A,   ?,    ?, "Vietnamese", "Vietnam"},*/
71         {0x042D, 850, 1252, "Basque", "Spain"},
72         {0x042F, 866, 1251, "Macedonian", "Former Yugoslav Republic of Macedonia"},
73         {0x0436, 850, 1252, "Afrikaans", "South Africa"},
74 /*      {0x0438, 852, 1252, "Faroese", "Faroe Islands"}, FIXME: Not sure about codepages */
75         {0x043C, 437, 1252, "Irish", "Ireland"},
76 /*      {0x048F,   ?,    ?, "Esperanto", "<none>"},*/
77 /*      {0x0804,   ?,    ?, "Chinese (People's replublic of China)", People's republic of China"},*/
78         {0x0807, 850, 1252, "German", "Switzerland"},
79         {0x0809, 850, 1252, "English", "United Kingdom"},
80         {0x080A, 850, 1252, "Spanish", "Mexico"},
81         {0x080C, 850, 1252, "French", "Belgium"},
82         {0x0810, 850, 1252, "Italian", "Switzerland"},
83         {0x0813, 850, 1252, "Dutch", "Belgium"},
84         {0x0814, 850, 1252, "Norwegian (Nynorsk)", "Norway"},
85         {0x0816, 850, 1252, "Portuguese", "Portugal"},
86 /*      {0x081A,   ?,    ?, "Serbian (latin)", "Yugoslavia"},*/
87         {0x081D, 850, 1252, "Swedish (Finland)", "Finland"},
88         {0x0C07, 850, 1252, "German", "Austria"},
89         {0x0C09, 850, 1252, "English", "Australia"},
90         {0x0C0A, 850, 1252, "Spanish - International Sort", "Spain"},
91         {0x0C0C, 850, 1252, "French", "Canada"},
92         {0x0C1A, 855, 1251, "Serbian (Cyrillic)", "Serbia"},
93         {0x1007, 850, 1252, "German", "Luxembourg"},
94         {0x1009, 850, 1252, "English", "Canada"},
95         {0x100A, 850, 1252, "Spanish", "Guatemala"},
96         {0x100C, 850, 1252, "French", "Switzerland"},
97         {0x1407, 850, 1252, "German", "Liechtenstein"},
98         {0x1409, 850, 1252, "English", "New Zealand"},
99         {0x140A, 850, 1252, "Spanish", "Costa Rica"},
100         {0x140C, 850, 1252, "French", "Luxembourg"},
101         {0x1809, 850, 1252, "English", "Ireland"},
102         {0x180A, 850, 1252, "Spanish", "Panama"},
103         {0x1C09, 437, 1252, "English", "South Africa"},
104         {0x1C0A, 850, 1252, "Spanish", "Dominican Republic"},
105         {0x2009, 850, 1252, "English", "Jamaica"},
106         {0x200A, 850, 1252, "Spanish", "Venezuela"},
107         {0x2409, 850, 1252, "English", "Caribbean"},
108         {0x240A, 850, 1252, "Spanish", "Colombia"},
109         {0x2809, 850, 1252, "English", "Belize"},
110         {0x280A, 850, 1252, "Spanish", "Peru"},
111         {0x2C09, 437, 1252, "English", "Trinidad & Tobago"},
112         {0x2C0A, 850, 1252, "Spanish", "Argentina"},
113         {0x300A, 850, 1252, "Spanish", "Ecuador"},
114         {0x340A, 850, 1252, "Spanish", "Chile"},
115         {0x380A, 850, 1252, "Spanish", "Uruguay"},
116         {0x3C0A, 850, 1252, "Spanish", "Paraguay"},
117         {0x400A, 850, 1252, "Spanish", "Bolivia"},
118         {0x440A, 850, 1252, "Spanish", "El Salvador"},
119         {0x480A, 850, 1252, "Spanish", "Honduras"},
120         {0x4C0A, 850, 1252, "Spanish", "Nicaragua"},
121         {0x500A, 850, 1252, "Spanish", "Puerto Rico"}
122 };
123
124 #define NLAN    (sizeof(languages)/sizeof(languages[0]))
125
126 void show_languages(void)
127 {
128         int i;
129         printf(" Code  | DOS-cp | WIN-cp |   Language   | Country\n");
130         printf("-------+--------+--------+--------------+---------\n");
131         for(i = 0; i < NLAN; i++)
132                 printf("0x%04x | %5d  | %5d   | %-12s | %s\n",
133                         languages[i].id,
134                         languages[i].doscp,
135                         languages[i].wincp,
136                         languages[i].name,
137                         languages[i].country);
138 }
139
140 static int langcmp(const void *p1, const void *p2)
141 {
142         return *(unsigned *)p1 - ((language_t *)p2)->id;
143 }
144
145 const language_t *find_language(unsigned id)
146 {
147         return (const language_t *)bsearch(&id, languages, NLAN, sizeof(languages[0]), langcmp);
148 }
149
150 void show_codepages(void)
151 {
152 #if 0
153         unsigned i;
154         const union cptable *cpp;
155         printf("Codepages:\n");
156         for(i = 0; (cpp = cp_enum_table(i)); i++)
157         {
158                 printf("%-5d %s\n", cpp->info.codepage, cpp->info.name);
159         }
160 #endif
161 }
162
163 #if 0
164 const union cptable *find_codepage(int id)
165 {
166         return cp_get_table(id);
167 }
168 #endif