StringTables.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. using System;
  4. using System.Runtime.CompilerServices;
  5. namespace BansheeEngine
  6. {
  7. /// <summary>
  8. /// Manages string tables used for localizing text. Allows you to add and remove different tables and change the
  9. /// active language.
  10. /// </summary>
  11. public static class StringTables
  12. {
  13. /// <summary>
  14. /// Currently active language that determines the translations retrieved from localized strings.
  15. /// </summary>
  16. public static Language ActiveLanguage
  17. {
  18. get
  19. {
  20. Language value;
  21. Internal_GetActiveLanguage(out value);
  22. return value;
  23. }
  24. set
  25. {
  26. Internal_SetActiveLanguage(value);
  27. }
  28. }
  29. /// <summary>
  30. /// Returns the string table with the specified id. If the table doesn't exist new one is created.
  31. /// </summary>
  32. /// <param name="id">Identifier of the string table.</param>
  33. /// <returns>String table with the specified identifier.</returns>
  34. public static StringTable GetTable(int id)
  35. {
  36. return Internal_GetTable(id);
  37. }
  38. /// <summary>
  39. /// Registers a new string table or replaces an old one at the specified id.
  40. /// </summary>
  41. /// <param name="id">Id of the string table to add/replace.</param>
  42. /// <param name="table">New string table to assign to the specified identifier.</param>
  43. public static void RegisterTable(int id, StringTable table)
  44. {
  45. Internal_SetTable(id, table);
  46. }
  47. /// <summary>
  48. /// Removes the string table with the specified id.
  49. /// </summary>
  50. /// <param name="id">Identifier of the table to remove.</param>
  51. public static void UnregisterTable(int id)
  52. {
  53. Internal_RemoveTable(id);
  54. }
  55. [MethodImpl(MethodImplOptions.InternalCall)]
  56. private static extern void Internal_GetActiveLanguage(out Language value);
  57. [MethodImpl(MethodImplOptions.InternalCall)]
  58. private static extern void Internal_SetActiveLanguage(Language value);
  59. [MethodImpl(MethodImplOptions.InternalCall)]
  60. private static extern StringTable Internal_GetTable(int id);
  61. [MethodImpl(MethodImplOptions.InternalCall)]
  62. private static extern void Internal_SetTable(int id, StringTable table);
  63. [MethodImpl(MethodImplOptions.InternalCall)]
  64. private static extern void Internal_RemoveTable(int id);
  65. }
  66. /// <summary>
  67. /// A set of all languages that localized strings can be translated to. Loosely based on ISO 639-1 two letter language
  68. /// codes.
  69. /// </summary>
  70. public enum Language
  71. {
  72. Afar,
  73. Abkhazian,
  74. Avestan,
  75. Afrikaans,
  76. Akan,
  77. Amharic,
  78. Aragonese,
  79. Arabic,
  80. Assamese,
  81. Avaric,
  82. Aymara,
  83. Azerbaijani,
  84. Bashkir,
  85. Belarusian,
  86. Bulgarian,
  87. Bihari,
  88. Bislama,
  89. Bambara,
  90. Bengali,
  91. Tibetan,
  92. Breton,
  93. Bosnian,
  94. Catalan,
  95. Chechen,
  96. Chamorro,
  97. Corsican,
  98. Cree,
  99. Czech,
  100. ChurchSlavic,
  101. Chuvash,
  102. Welsh,
  103. Danish,
  104. German,
  105. Maldivian,
  106. Bhutani,
  107. Ewe,
  108. Greek,
  109. EnglishUK,
  110. EnglishUS,
  111. Esperanto,
  112. Spanish,
  113. Estonian,
  114. Basque,
  115. Persian,
  116. Fulah,
  117. Finnish,
  118. Fijian,
  119. Faroese,
  120. French,
  121. WesternFrisian,
  122. Irish,
  123. ScottishGaelic,
  124. Galician,
  125. Guarani,
  126. Gujarati,
  127. Manx,
  128. Hausa,
  129. Hebrew,
  130. Hindi,
  131. HiriMotu,
  132. Croatian,
  133. Haitian,
  134. Hungarian,
  135. Armenian,
  136. Herero,
  137. Interlingua,
  138. Indonesian,
  139. Interlingue,
  140. Igbo,
  141. SichuanYi,
  142. Inupiak,
  143. Ido,
  144. Icelandic,
  145. Italian,
  146. Inuktitut,
  147. Japanese,
  148. Javanese,
  149. Georgian,
  150. Kongo,
  151. Kikuyu,
  152. Kuanyama,
  153. Kazakh,
  154. Kalaallisut,
  155. Cambodian,
  156. Kannada,
  157. Korean,
  158. Kanuri,
  159. Kashmiri,
  160. Kurdish,
  161. Komi,
  162. Cornish,
  163. Kirghiz,
  164. Latin,
  165. Luxembourgish,
  166. Ganda,
  167. Limburgish,
  168. Lingala,
  169. Laotian,
  170. Lithuanian,
  171. LubaKatanga,
  172. Latvian,
  173. Malagasy,
  174. Marshallese,
  175. Maori,
  176. Macedonian,
  177. Malayalam,
  178. Mongolian,
  179. Moldavian,
  180. Marathi,
  181. Malay,
  182. Maltese,
  183. Burmese,
  184. Nauru,
  185. NorwegianBokmal,
  186. Ndebele,
  187. Nepali,
  188. Ndonga,
  189. Dutch,
  190. NorwegianNynorsk,
  191. Norwegian,
  192. Navaho,
  193. Nyanja,
  194. Provençal,
  195. Ojibwa,
  196. Oromo,
  197. Oriya,
  198. Ossetic,
  199. Punjabi,
  200. Pali,
  201. Polish,
  202. Pushto,
  203. Portuguese,
  204. Quechua,
  205. Romansh,
  206. Kirundi,
  207. Romanian,
  208. Russian,
  209. Kinyarwanda,
  210. Sanskrit,
  211. Sardinian,
  212. Sindhi,
  213. NorthernSami,
  214. Sangro,
  215. Sinhalese,
  216. Slovak,
  217. Slovenian,
  218. Samoan,
  219. Shona,
  220. Somali,
  221. Albanian,
  222. Serbian,
  223. Swati,
  224. Sesotho,
  225. Sundanese,
  226. Swedish,
  227. Swahili,
  228. Tamil,
  229. Telugu,
  230. Tajik,
  231. Thai,
  232. Tigrinya,
  233. Turkmen,
  234. Tagalog,
  235. Setswana,
  236. Tonga,
  237. Turkish,
  238. Tsonga,
  239. Tatar,
  240. Twi,
  241. Tahitian,
  242. Uighur,
  243. Ukrainian,
  244. Urdu,
  245. Uzbek,
  246. Venda,
  247. Vietnamese,
  248. Volapuk,
  249. Walloon,
  250. Wolof,
  251. Xhosa,
  252. Yiddish,
  253. Yoruba,
  254. Zhuang,
  255. Chinese,
  256. Zulu,
  257. Count // Number of entries
  258. };
  259. }