StringTables.cs 4.9 KB

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