cldr.js.d.ts 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. // Type definitions for Cldr.js 0.4.4
  2. // Project: https://github.com/rxaviers/cldrjs
  3. // Definitions by: Raman But-Husaim <https://github.com/RamanBut-Husaim>, Grégoire Castre <https://github.com/gcastre/>
  4. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  5. declare namespace cldr {
  6. /**
  7. * @name Attributes
  8. * @memberof cldr
  9. * @kind interface
  10. *
  11. * @description
  12. * The object created during instance initialization and used internally by .get()
  13. * to replace dynamic parts of an item path.
  14. */
  15. interface Attributes {
  16. /**
  17. * @name language
  18. * @memberof cldr.Attributes
  19. * @kind property
  20. * @access public
  21. *
  22. * @type {any}
  23. *
  24. * @description
  25. * Language subtag {@link http://www.unicode.org/reports/tr35/#Language_Locale_Field_Definitions}
  26. */
  27. language: any;
  28. /**
  29. * @name script
  30. * @memberof cldr.Attributes
  31. * @kind property
  32. * @access public
  33. *
  34. * @type {any}
  35. *
  36. * @description
  37. * Script subtag {@link http://www.unicode.org/reports/tr35/#Language_Locale_Field_Definitions}
  38. */
  39. script: any;
  40. /**
  41. * @name region
  42. * @memberof cldr.Attributes
  43. * @kind property
  44. * @access public
  45. *
  46. * @type {any}
  47. *
  48. * @description
  49. * Region subtag {@link http://www.unicode.org/reports/tr35/#Language_Locale_Field_Definitions}
  50. */
  51. region: any;
  52. /**
  53. * @name territory
  54. * @memberof cldr.Attributes
  55. * @kind property
  56. * @access public
  57. *
  58. * @type {any}
  59. *
  60. * @description
  61. * Region subtag (territory variant) {@link http://www.unicode.org/reports/tr35/#Language_Locale_Field_Definitions}
  62. */
  63. territory: any;
  64. /**
  65. * @name languageId
  66. * @memberof cldr.Attributes
  67. * @kind property
  68. * @access public
  69. *
  70. * @type {any}
  71. *
  72. * @description
  73. * Language Id {@link http://www.unicode.org/reports/tr35/#Unicode_language_identifier}
  74. */
  75. languageId: any;
  76. /**
  77. * @name maxLanguageId
  78. * @memberof cldr.Attributes
  79. * @kind property
  80. * @access public
  81. *
  82. * @type {any}
  83. *
  84. * @description
  85. * Maximized Language Id {@link http://www.unicode.org/reports/tr35/#Likely_Subtags}
  86. */
  87. maxLanguageId: any;
  88. /**
  89. * @name minLanguageId
  90. * @memberof cldr.Attributes
  91. * @kind property
  92. * @access public
  93. *
  94. * @type {any}
  95. *
  96. * @description
  97. * Minimized Language Id {@link http://www.unicode.org/reports/tr35/#Likely_Subtags}
  98. */
  99. minLanguageId: any;
  100. }
  101. /**
  102. * @name CldrStatic
  103. * @memberof cldr
  104. * @kind interface
  105. *
  106. * @description
  107. * The cldr class definition.
  108. */
  109. interface CldrStatic {
  110. /**
  111. * @name get
  112. * @memberof cldr.CldrStatic
  113. * @kind function
  114. * @access public
  115. *
  116. * @description
  117. * Get the item data given its path, or 'undefined' if missing.
  118. *
  119. * @param {string} path The path to the cldr member.
  120. *
  121. * @returns {any} The cldr member.
  122. */
  123. get(path: string): any;
  124. /**
  125. * @name get
  126. * @memberof cldr.CldrStatic
  127. * @kind function
  128. * @access public
  129. *
  130. * @description
  131. * Get the item data given its path, or 'undefined' if missing.
  132. *
  133. * @param {Array<string>} paths The array with path parts to the cldr member.
  134. *
  135. * @returns {any} The cldr member.
  136. */
  137. get(paths: string[]): any;
  138. /**
  139. * @name main
  140. * @memberof cldr.CldrStatic
  141. * @kind function
  142. * @access public
  143. *
  144. * @description
  145. * It's an alias for .get(["main/{languageId}, ...])"
  146. *
  147. * @param {string} path The path to the cldr member.
  148. *
  149. * @returns {any} The cldr member.
  150. */
  151. main(path: string): any;
  152. /**
  153. * @name main
  154. * @memberof cldr.CldrStatic
  155. * @kind function
  156. * @access public
  157. *
  158. * @declaration
  159. * It's an alias for .get(["main/{languageId}, ...])"
  160. *
  161. * @param {Array<string>} paths The array with path parts to the cldr member.
  162. *
  163. * @returns {any} The cldr member.
  164. */
  165. main(paths: string[]): any;
  166. /**
  167. * @name locale
  168. * @memberof cldr.CldrStatic
  169. * @kind property
  170. * @access public
  171. *
  172. * @type {string}
  173. *
  174. * @declaration
  175. * The locale string.
  176. */
  177. locale: string;
  178. /**
  179. * @name attributes
  180. * @memberof cldr.CldrStatic
  181. * @kind property
  182. * @access public
  183. *
  184. * @type {cldr.Attributes}
  185. *
  186. * @declaration
  187. * The object created during instance initialization and used internally by .get()
  188. * to replace dynamic parts of an item path.
  189. */
  190. attributes: Attributes;
  191. }
  192. /**
  193. * @name CldrFactory
  194. * @memberof cldr
  195. * @kind inteface
  196. *
  197. * @description
  198. * The factory for {@link cldr.CldrStatic} class.
  199. */
  200. interface CldrFactory {
  201. /**
  202. * @name load
  203. * @memberof cldr.CldrFactory
  204. * @kind function
  205. * @access public
  206. *
  207. * @description
  208. * Load the CLDR content in the form of JSON.
  209. *
  210. * @param {any} json The json content.
  211. * @param {Array<any>} otherJson Optional. The parts of the JSON.
  212. *
  213. * @returns {void}
  214. */
  215. load(json: any, ...otherJson: any[]): void;
  216. /**
  217. * @name constructor
  218. * @memberof cldr.CldrFactory
  219. * @kind function
  220. * @access public
  221. *
  222. * @description
  223. * The constructor function for {@link cldr.CldrStatic} class.
  224. *
  225. * @param {string} locale The locale name that was previously loaded.
  226. *
  227. * @returns {cldr.CldrStatic} The instance of {@link cldr.CldrStatic} class.
  228. */
  229. new (locale: string): CldrStatic;
  230. /**
  231. * Allow user to override locale separator "-" (default) | "_".
  232. * According to http://www.unicode.org/reports/tr35/#Unicode_language_identifier, both "-" and "_" are valid locale separators (eg. "en_GB", "en-GB").
  233. * According to http://unicode.org/cldr/trac/ticket/6786 its usage must be consistent throughout the data set.
  234. */
  235. localeSep: "-" | "_";
  236. }
  237. }
  238. declare module "cldr" {
  239. export = cldr;
  240. }
  241. declare var Cldr: cldr.CldrFactory;