Localization.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. // WARNING - AUTOGENERATED - DO NOT EDIT
  2. //
  3. // Generated using `sharpie urho`
  4. //
  5. // Localization.cs
  6. //
  7. // Copyright 2015 Xamarin Inc. All rights reserved.
  8. using System;
  9. using System.Runtime.InteropServices;
  10. using System.Collections.Generic;
  11. using Urho.Urho2D;
  12. using Urho.Gui;
  13. using Urho.Resources;
  14. using Urho.IO;
  15. using Urho.Navigation;
  16. using Urho.Network;
  17. namespace Urho.Resources
  18. {
  19. /// <summary>
  20. /// %Localization subsystem. Stores all the strings in all languages.
  21. /// </summary>
  22. public unsafe partial class Localization : UrhoObject
  23. {
  24. unsafe partial void OnLocalizationCreated ();
  25. [Preserve]
  26. public Localization (IntPtr handle) : base (handle)
  27. {
  28. OnLocalizationCreated ();
  29. }
  30. [Preserve]
  31. protected Localization (UrhoObjectFlag emptyFlag) : base (emptyFlag)
  32. {
  33. OnLocalizationCreated ();
  34. }
  35. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  36. internal static extern int Localization_GetType (IntPtr handle);
  37. private StringHash UrhoGetType ()
  38. {
  39. Runtime.ValidateRefCounted (this);
  40. return new StringHash (Localization_GetType (handle));
  41. }
  42. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  43. internal static extern IntPtr Localization_GetTypeName (IntPtr handle);
  44. private string GetTypeName ()
  45. {
  46. Runtime.ValidateRefCounted (this);
  47. return Marshal.PtrToStringAnsi (Localization_GetTypeName (handle));
  48. }
  49. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  50. internal static extern int Localization_GetTypeStatic ();
  51. private static StringHash GetTypeStatic ()
  52. {
  53. Runtime.Validate (typeof(Localization));
  54. return new StringHash (Localization_GetTypeStatic ());
  55. }
  56. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  57. internal static extern IntPtr Localization_GetTypeNameStatic ();
  58. private static string GetTypeNameStatic ()
  59. {
  60. Runtime.Validate (typeof(Localization));
  61. return Marshal.PtrToStringAnsi (Localization_GetTypeNameStatic ());
  62. }
  63. [Preserve]
  64. public Localization () : this (Application.CurrentContext)
  65. {
  66. }
  67. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  68. internal static extern IntPtr Localization_Localization (IntPtr context);
  69. [Preserve]
  70. public Localization (Context context) : base (UrhoObjectFlag.Empty)
  71. {
  72. Runtime.Validate (typeof(Localization));
  73. handle = Localization_Localization ((object)context == null ? IntPtr.Zero : context.Handle);
  74. Runtime.RegisterObject (this);
  75. OnLocalizationCreated ();
  76. }
  77. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  78. internal static extern int Localization_GetNumLanguages (IntPtr handle);
  79. /// <summary>
  80. /// Return the number of languages.
  81. /// </summary>
  82. private int GetNumLanguages ()
  83. {
  84. Runtime.ValidateRefCounted (this);
  85. return Localization_GetNumLanguages (handle);
  86. }
  87. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  88. internal static extern int Localization_GetLanguageIndex (IntPtr handle);
  89. /// <summary>
  90. /// Return the index number of current language. The index is determined by the order of loading.
  91. /// </summary>
  92. private int GetLanguageIndex ()
  93. {
  94. Runtime.ValidateRefCounted (this);
  95. return Localization_GetLanguageIndex (handle);
  96. }
  97. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  98. internal static extern int Localization_GetLanguageIndex0 (IntPtr handle, string language);
  99. /// <summary>
  100. /// Return the index number of language. The index is determined by the order of loading.
  101. /// </summary>
  102. public int GetLanguageIndex (string language)
  103. {
  104. Runtime.ValidateRefCounted (this);
  105. return Localization_GetLanguageIndex0 (handle, language);
  106. }
  107. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  108. internal static extern IntPtr Localization_GetLanguage (IntPtr handle);
  109. /// <summary>
  110. /// Return the name of current language.
  111. /// </summary>
  112. private string GetLanguage ()
  113. {
  114. Runtime.ValidateRefCounted (this);
  115. return Marshal.PtrToStringAnsi (Localization_GetLanguage (handle));
  116. }
  117. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  118. internal static extern IntPtr Localization_GetLanguage1 (IntPtr handle, int index);
  119. /// <summary>
  120. /// Return the name of language.
  121. /// </summary>
  122. public string GetLanguage (int index)
  123. {
  124. Runtime.ValidateRefCounted (this);
  125. return Marshal.PtrToStringAnsi (Localization_GetLanguage1 (handle, index));
  126. }
  127. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  128. internal static extern void Localization_SetLanguage (IntPtr handle, int index);
  129. /// <summary>
  130. /// Set current language.
  131. /// </summary>
  132. public void SetLanguage (int index)
  133. {
  134. Runtime.ValidateRefCounted (this);
  135. Localization_SetLanguage (handle, index);
  136. }
  137. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  138. internal static extern void Localization_SetLanguage2 (IntPtr handle, string language);
  139. /// <summary>
  140. /// Set current language.
  141. /// </summary>
  142. public void SetLanguage (string language)
  143. {
  144. Runtime.ValidateRefCounted (this);
  145. Localization_SetLanguage2 (handle, language);
  146. }
  147. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  148. internal static extern IntPtr Localization_Get (IntPtr handle, string id);
  149. /// <summary>
  150. /// Return a string in the current language. Returns String::EMPTY if id is empty. Returns id if translation is not found and logs a warning.
  151. /// </summary>
  152. public string Get (string id)
  153. {
  154. Runtime.ValidateRefCounted (this);
  155. return Marshal.PtrToStringAnsi (Localization_Get (handle, id));
  156. }
  157. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  158. internal static extern void Localization_Reset (IntPtr handle);
  159. /// <summary>
  160. /// Clear all loaded strings.
  161. /// </summary>
  162. public void Reset ()
  163. {
  164. Runtime.ValidateRefCounted (this);
  165. Localization_Reset (handle);
  166. }
  167. [DllImport (Consts.NativeImport, CallingConvention = CallingConvention.Cdecl)]
  168. internal static extern void Localization_LoadJSONFile (IntPtr handle, string name);
  169. /// <summary>
  170. /// Load strings from JSONFile. The file should be UTF8 without BOM.
  171. /// </summary>
  172. public void LoadJsonFile (string name)
  173. {
  174. Runtime.ValidateRefCounted (this);
  175. Localization_LoadJSONFile (handle, name);
  176. }
  177. public override StringHash Type {
  178. get {
  179. return UrhoGetType ();
  180. }
  181. }
  182. public override string TypeName {
  183. get {
  184. return GetTypeName ();
  185. }
  186. }
  187. [Preserve]
  188. public static StringHash TypeStatic {
  189. get {
  190. return GetTypeStatic ();
  191. }
  192. }
  193. public static string TypeNameStatic {
  194. get {
  195. return GetTypeNameStatic ();
  196. }
  197. }
  198. /// <summary>
  199. /// Return the number of languages.
  200. /// </summary>
  201. public int NumLanguages {
  202. get {
  203. return GetNumLanguages ();
  204. }
  205. }
  206. /// <summary>
  207. /// Return the index number of current language. The index is determined by the order of loading.
  208. /// </summary>
  209. public int LanguageIndex {
  210. get {
  211. return GetLanguageIndex ();
  212. }
  213. }
  214. /// <summary>
  215. /// Return the name of current language.
  216. /// </summary>
  217. public string Language {
  218. get {
  219. return GetLanguage ();
  220. }
  221. }
  222. }
  223. }