StringTables.cs 5.2 KB

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