lang.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23. #include <assert.h>
  24. #include "wmc.h"
  25. #include "lang.h"
  26. /*
  27. * Languages supported
  28. *
  29. * MUST be sorting ascending on language ID
  30. */
  31. static const struct language languages[] = {
  32. {0x0000, 437, "Neutral", NULL},
  33. {0x0002, 866, "Bulgarian", NULL},
  34. {0x0003, 850, "Catalan", NULL},
  35. {0x0005, 852, "Czech", NULL},
  36. {0x0006, 850, "Danish", NULL},
  37. {0x0007, 850, "German", NULL},
  38. {0x0008, 737, "Greek", NULL},
  39. {0x0009, 437, "English", NULL},
  40. {0x000A, 850, "Spanish - Traditional Sort", NULL},
  41. {0x000B, 850, "Finnish", NULL},
  42. {0x000C, 850, "French", NULL},
  43. {0x000E, 852, "Hungarian", NULL},
  44. {0x000F, 850, "Icelandic", NULL},
  45. {0x0010, 850, "Italian", NULL},
  46. {0x0011, 932, "Japanese", NULL},
  47. {0x0012, 949, "Korean", NULL},
  48. {0x0013, 850, "Dutch", NULL},
  49. {0x0014, 850, "Norwegian (Bokmål)", NULL},
  50. {0x0015, 852, "Polish", NULL},
  51. {0x0016, 850, "Portuguese", NULL},
  52. {0x0018, 852, "Romanian", NULL},
  53. {0x0019, 866, "Russian", NULL},
  54. {0x001A, 852, "Serbian", NULL},
  55. {0x001B, 852, "Slovak", NULL},
  56. {0x001C, 852, "Albanian", NULL},
  57. {0x001D, 850, "Swedish", NULL},
  58. {0x001F, 857, "Turkish", NULL},
  59. {0x0021, 850, "Indonesian", NULL},
  60. {0x0022, 866, "Ukrainian", NULL},
  61. {0x0023, 866, "Belarusian", NULL},
  62. {0x0024, 852, "Slovene", NULL},
  63. {0x0025, 775, "Estonian", NULL},
  64. {0x0026, 775, "Latvian", NULL},
  65. {0x0027, 775, "Lithuanian", NULL},
  66. {0x002A,1258, "Vietnamese", NULL},
  67. {0x002D, 850, "Basque", NULL},
  68. {0x002F, 866, "Macedonian", NULL},
  69. {0x0036, 850, "Afrikaans", NULL},
  70. {0x0038, 852, "Faroese", NULL},
  71. {0x003C, 437, "Irish", NULL},
  72. {0x003E, 850, "Malay", NULL},
  73. {0x0402, 866, "Bulgarian", "Bulgaria"},
  74. {0x0403, 850, "Catalan", "Spain"},
  75. {0x0405, 852, "Czech", "Czech Republic"},
  76. {0x0406, 850, "Danish", "Denmark"},
  77. {0x0407, 850, "German", "Germany"},
  78. {0x0408, 737, "Greek", "Greece"},
  79. {0x0409, 437, "English", "United States"},
  80. {0x040A, 850, "Spanish - Traditional Sort", "Spain"},
  81. {0x040B, 850, "Finnish", "Finland"},
  82. {0x040C, 850, "French", "France"},
  83. {0x040E, 852, "Hungarian", "Hungary"},
  84. {0x040F, 850, "Icelandic", "Iceland"},
  85. {0x0410, 850, "Italian", "Italy"},
  86. {0x0411, 932, "Japanese", "Japan"},
  87. {0x0412, 949, "Korean", "Korea (south)"},
  88. {0x0413, 850, "Dutch", "Netherlands"},
  89. {0x0414, 850, "Norwegian (Bokmål)", "Norway"},
  90. {0x0415, 852, "Polish", "Poland"},
  91. {0x0416, 850, "Portuguese", "Brazil"},
  92. {0x0418, 852, "Romanian", "Romania"},
  93. {0x0419, 866, "Russian", "Russia"},
  94. {0x041A, 852, "Croatian", "Croatia"},
  95. {0x041B, 852, "Slovak", "Slovakia"},
  96. {0x041C, 852, "Albanian", "Albania"},
  97. {0x041D, 850, "Swedish", "Sweden"},
  98. {0x041F, 857, "Turkish", "Turkey"},
  99. {0x0421, 850, "Indonesian", "Indonesia"},
  100. {0x0422, 866, "Ukrainian", "Ukraine"},
  101. {0x0423, 866, "Belarusian", "Belarus"},
  102. {0x0424, 852, "Slovene", "Slovenia"},
  103. {0x0425, 775, "Estonian", "Estonia"},
  104. {0x0426, 775, "Latvian", "Latvia"},
  105. {0x0427, 775, "Lithuanian", "Lithuania"},
  106. {0x042A,1258, "Vietnamese", "Vietnam"},
  107. {0x042D, 850, "Basque", "Spain"},
  108. {0x042F, 866, "Macedonian", "Former Yugoslav Republic of Macedonia"},
  109. {0x0436, 850, "Afrikaans", "South Africa"},
  110. {0x0438, 852, "Faroese", "Faroe Islands"},
  111. {0x043C, 437, "Irish", "Ireland"},
  112. {0x043E, 850, "Malay", "Malaysia"},
  113. /* {0x048F, ?, "Esperanto", "<none>"},*/
  114. {0x0804, 936, "Chinese (People's republic of China)", "People's republic of China"},
  115. {0x0807, 850, "German", "Switzerland"},
  116. {0x0809, 850, "English", "United Kingdom"},
  117. {0x080A, 850, "Spanish", "Mexico"},
  118. {0x080C, 850, "French", "Belgium"},
  119. {0x0810, 850, "Italian", "Switzerland"},
  120. {0x0813, 850, "Dutch", "Belgium"},
  121. {0x0814, 850, "Norwegian (Nynorsk)", "Norway"},
  122. {0x0816, 850, "Portuguese", "Portugal"},
  123. {0x081A, 852, "Serbian (latin)", "Yugoslavia"},
  124. {0x081D, 850, "Swedish (Finland)", "Finland"},
  125. {0x0C07, 850, "German", "Austria"},
  126. {0x0C09, 850, "English", "Australia"},
  127. {0x0C0A, 850, "Spanish - International Sort", "Spain"},
  128. {0x0C0C, 850, "French", "Canada"},
  129. {0x0C1A, 855, "Serbian (Cyrillic)", "Serbia"},
  130. {0x1007, 850, "German", "Luxembourg"},
  131. {0x1009, 850, "English", "Canada"},
  132. {0x100A, 850, "Spanish", "Guatemala"},
  133. {0x100C, 850, "French", "Switzerland"},
  134. {0x1407, 850, "German", "Liechtenstein"},
  135. {0x1409, 850, "English", "New Zealand"},
  136. {0x140A, 850, "Spanish", "Costa Rica"},
  137. {0x140C, 850, "French", "Luxembourg"},
  138. {0x1809, 850, "English", "Ireland"},
  139. {0x180A, 850, "Spanish", "Panama"},
  140. {0x1C09, 437, "English", "South Africa"},
  141. {0x1C0A, 850, "Spanish", "Dominican Republic"},
  142. {0x2009, 850, "English", "Jamaica"},
  143. {0x200A, 850, "Spanish", "Venezuela"},
  144. {0x2409, 850, "English", "Caribbean"},
  145. {0x240A, 850, "Spanish", "Colombia"},
  146. {0x2809, 850, "English", "Belize"},
  147. {0x280A, 850, "Spanish", "Peru"},
  148. {0x2C09, 437, "English", "Trinidad & Tobago"},
  149. {0x2C0A, 850, "Spanish", "Argentina"},
  150. {0x300A, 850, "Spanish", "Ecuador"},
  151. {0x340A, 850, "Spanish", "Chile"},
  152. {0x380A, 850, "Spanish", "Uruguay"},
  153. {0x3C0A, 850, "Spanish", "Paraguay"},
  154. {0x400A, 850, "Spanish", "Bolivia"},
  155. {0x440A, 850, "Spanish", "El Salvador"},
  156. {0x480A, 850, "Spanish", "Honduras"},
  157. {0x4C0A, 850, "Spanish", "Nicaragua"},
  158. {0x500A, 850, "Spanish", "Puerto Rico"}
  159. };
  160. void show_languages(void)
  161. {
  162. unsigned int i;
  163. printf(" Code | DOS-cp | Language | Country\n");
  164. printf("-------+--------+--------------+---------\n");
  165. for(i = 0; i < ARRAY_SIZE(languages); i++)
  166. printf("0x%04x | %5d | %-12s | %s\n",
  167. languages[i].id,
  168. languages[i].doscp,
  169. languages[i].name,
  170. languages[i].country ? languages[i].country : "Neutral");
  171. }
  172. static int langcmp(const void *p1, const void *p2)
  173. {
  174. return *(const unsigned *)p1 - ((const struct language *)p2)->id;
  175. }
  176. const struct language *find_language(unsigned id)
  177. {
  178. return (const struct language *)bsearch(&id, languages, ARRAY_SIZE(languages),
  179. sizeof(languages[0]), langcmp);
  180. }