locale_set.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * JavaScript code in this page
  4. *
  5. * Copyright 2022 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * JavaScript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.LocaleSetNamespace = void 0;
  27. var _namespaces = require("./namespaces.js");
  28. var _xfa_object = require("./xfa_object.js");
  29. var _utils = require("./utils.js");
  30. const LOCALE_SET_NS_ID = _namespaces.NamespaceIds.localeSet.id;
  31. class CalendarSymbols extends _xfa_object.XFAObject {
  32. constructor(attributes) {
  33. super(LOCALE_SET_NS_ID, "calendarSymbols", true);
  34. this.name = "gregorian";
  35. this.dayNames = new _xfa_object.XFAObjectArray(2);
  36. this.eraNames = null;
  37. this.meridiemNames = null;
  38. this.monthNames = new _xfa_object.XFAObjectArray(2);
  39. }
  40. }
  41. class CurrencySymbol extends _xfa_object.StringObject {
  42. constructor(attributes) {
  43. super(LOCALE_SET_NS_ID, "currencySymbol");
  44. this.name = (0, _utils.getStringOption)(attributes.name, ["symbol", "isoname", "decimal"]);
  45. }
  46. }
  47. class CurrencySymbols extends _xfa_object.XFAObject {
  48. constructor(attributes) {
  49. super(LOCALE_SET_NS_ID, "currencySymbols", true);
  50. this.currencySymbol = new _xfa_object.XFAObjectArray(3);
  51. }
  52. }
  53. class DatePattern extends _xfa_object.StringObject {
  54. constructor(attributes) {
  55. super(LOCALE_SET_NS_ID, "datePattern");
  56. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  57. }
  58. }
  59. class DatePatterns extends _xfa_object.XFAObject {
  60. constructor(attributes) {
  61. super(LOCALE_SET_NS_ID, "datePatterns", true);
  62. this.datePattern = new _xfa_object.XFAObjectArray(4);
  63. }
  64. }
  65. class DateTimeSymbols extends _xfa_object.ContentObject {
  66. constructor(attributes) {
  67. super(LOCALE_SET_NS_ID, "dateTimeSymbols");
  68. }
  69. }
  70. class Day extends _xfa_object.StringObject {
  71. constructor(attributes) {
  72. super(LOCALE_SET_NS_ID, "day");
  73. }
  74. }
  75. class DayNames extends _xfa_object.XFAObject {
  76. constructor(attributes) {
  77. super(LOCALE_SET_NS_ID, "dayNames", true);
  78. this.abbr = (0, _utils.getInteger)({
  79. data: attributes.abbr,
  80. defaultValue: 0,
  81. validate: x => x === 1
  82. });
  83. this.day = new _xfa_object.XFAObjectArray(7);
  84. }
  85. }
  86. class Era extends _xfa_object.StringObject {
  87. constructor(attributes) {
  88. super(LOCALE_SET_NS_ID, "era");
  89. }
  90. }
  91. class EraNames extends _xfa_object.XFAObject {
  92. constructor(attributes) {
  93. super(LOCALE_SET_NS_ID, "eraNames", true);
  94. this.era = new _xfa_object.XFAObjectArray(2);
  95. }
  96. }
  97. class Locale extends _xfa_object.XFAObject {
  98. constructor(attributes) {
  99. super(LOCALE_SET_NS_ID, "locale", true);
  100. this.desc = attributes.desc || "";
  101. this.name = "isoname";
  102. this.calendarSymbols = null;
  103. this.currencySymbols = null;
  104. this.datePatterns = null;
  105. this.dateTimeSymbols = null;
  106. this.numberPatterns = null;
  107. this.numberSymbols = null;
  108. this.timePatterns = null;
  109. this.typeFaces = null;
  110. }
  111. }
  112. class LocaleSet extends _xfa_object.XFAObject {
  113. constructor(attributes) {
  114. super(LOCALE_SET_NS_ID, "localeSet", true);
  115. this.locale = new _xfa_object.XFAObjectArray();
  116. }
  117. }
  118. class Meridiem extends _xfa_object.StringObject {
  119. constructor(attributes) {
  120. super(LOCALE_SET_NS_ID, "meridiem");
  121. }
  122. }
  123. class MeridiemNames extends _xfa_object.XFAObject {
  124. constructor(attributes) {
  125. super(LOCALE_SET_NS_ID, "meridiemNames", true);
  126. this.meridiem = new _xfa_object.XFAObjectArray(2);
  127. }
  128. }
  129. class Month extends _xfa_object.StringObject {
  130. constructor(attributes) {
  131. super(LOCALE_SET_NS_ID, "month");
  132. }
  133. }
  134. class MonthNames extends _xfa_object.XFAObject {
  135. constructor(attributes) {
  136. super(LOCALE_SET_NS_ID, "monthNames", true);
  137. this.abbr = (0, _utils.getInteger)({
  138. data: attributes.abbr,
  139. defaultValue: 0,
  140. validate: x => x === 1
  141. });
  142. this.month = new _xfa_object.XFAObjectArray(12);
  143. }
  144. }
  145. class NumberPattern extends _xfa_object.StringObject {
  146. constructor(attributes) {
  147. super(LOCALE_SET_NS_ID, "numberPattern");
  148. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  149. }
  150. }
  151. class NumberPatterns extends _xfa_object.XFAObject {
  152. constructor(attributes) {
  153. super(LOCALE_SET_NS_ID, "numberPatterns", true);
  154. this.numberPattern = new _xfa_object.XFAObjectArray(4);
  155. }
  156. }
  157. class NumberSymbol extends _xfa_object.StringObject {
  158. constructor(attributes) {
  159. super(LOCALE_SET_NS_ID, "numberSymbol");
  160. this.name = (0, _utils.getStringOption)(attributes.name, ["decimal", "grouping", "percent", "minus", "zero"]);
  161. }
  162. }
  163. class NumberSymbols extends _xfa_object.XFAObject {
  164. constructor(attributes) {
  165. super(LOCALE_SET_NS_ID, "numberSymbols", true);
  166. this.numberSymbol = new _xfa_object.XFAObjectArray(5);
  167. }
  168. }
  169. class TimePattern extends _xfa_object.StringObject {
  170. constructor(attributes) {
  171. super(LOCALE_SET_NS_ID, "timePattern");
  172. this.name = (0, _utils.getStringOption)(attributes.name, ["full", "long", "med", "short"]);
  173. }
  174. }
  175. class TimePatterns extends _xfa_object.XFAObject {
  176. constructor(attributes) {
  177. super(LOCALE_SET_NS_ID, "timePatterns", true);
  178. this.timePattern = new _xfa_object.XFAObjectArray(4);
  179. }
  180. }
  181. class TypeFace extends _xfa_object.XFAObject {
  182. constructor(attributes) {
  183. super(LOCALE_SET_NS_ID, "typeFace", true);
  184. this.name = attributes.name | "";
  185. }
  186. }
  187. class TypeFaces extends _xfa_object.XFAObject {
  188. constructor(attributes) {
  189. super(LOCALE_SET_NS_ID, "typeFaces", true);
  190. this.typeFace = new _xfa_object.XFAObjectArray();
  191. }
  192. }
  193. class LocaleSetNamespace {
  194. static [_namespaces.$buildXFAObject](name, attributes) {
  195. if (LocaleSetNamespace.hasOwnProperty(name)) {
  196. return LocaleSetNamespace[name](attributes);
  197. }
  198. return undefined;
  199. }
  200. static calendarSymbols(attrs) {
  201. return new CalendarSymbols(attrs);
  202. }
  203. static currencySymbol(attrs) {
  204. return new CurrencySymbol(attrs);
  205. }
  206. static currencySymbols(attrs) {
  207. return new CurrencySymbols(attrs);
  208. }
  209. static datePattern(attrs) {
  210. return new DatePattern(attrs);
  211. }
  212. static datePatterns(attrs) {
  213. return new DatePatterns(attrs);
  214. }
  215. static dateTimeSymbols(attrs) {
  216. return new DateTimeSymbols(attrs);
  217. }
  218. static day(attrs) {
  219. return new Day(attrs);
  220. }
  221. static dayNames(attrs) {
  222. return new DayNames(attrs);
  223. }
  224. static era(attrs) {
  225. return new Era(attrs);
  226. }
  227. static eraNames(attrs) {
  228. return new EraNames(attrs);
  229. }
  230. static locale(attrs) {
  231. return new Locale(attrs);
  232. }
  233. static localeSet(attrs) {
  234. return new LocaleSet(attrs);
  235. }
  236. static meridiem(attrs) {
  237. return new Meridiem(attrs);
  238. }
  239. static meridiemNames(attrs) {
  240. return new MeridiemNames(attrs);
  241. }
  242. static month(attrs) {
  243. return new Month(attrs);
  244. }
  245. static monthNames(attrs) {
  246. return new MonthNames(attrs);
  247. }
  248. static numberPattern(attrs) {
  249. return new NumberPattern(attrs);
  250. }
  251. static numberPatterns(attrs) {
  252. return new NumberPatterns(attrs);
  253. }
  254. static numberSymbol(attrs) {
  255. return new NumberSymbol(attrs);
  256. }
  257. static numberSymbols(attrs) {
  258. return new NumberSymbols(attrs);
  259. }
  260. static timePattern(attrs) {
  261. return new TimePattern(attrs);
  262. }
  263. static timePatterns(attrs) {
  264. return new TimePatterns(attrs);
  265. }
  266. static typeFace(attrs) {
  267. return new TypeFace(attrs);
  268. }
  269. static typeFaces(attrs) {
  270. return new TypeFaces(attrs);
  271. }
  272. }
  273. exports.LocaleSetNamespace = LocaleSetNamespace;