@ui5/webcomponents-localization 0.0.0-2f7664755 → 0.0.0-31ad69297

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.eslintignore +2 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +733 -0
  4. package/README.md +2 -1
  5. package/dist/.tsbuildinfo +1 -0
  6. package/dist/Assets-static.js.map +1 -1
  7. package/dist/Assets.js.map +1 -1
  8. package/dist/DateFormat.js.map +1 -1
  9. package/dist/LocaleData.js.map +1 -1
  10. package/dist/dates/CalendarDate.d.ts +7 -5
  11. package/dist/dates/CalendarDate.js +8 -7
  12. package/dist/dates/CalendarDate.js.map +1 -1
  13. package/dist/dates/ExtremeDates.d.ts +2 -2
  14. package/dist/dates/ExtremeDates.js.map +1 -1
  15. package/dist/dates/UI5Date.d.ts +6 -0
  16. package/dist/dates/UI5Date.js +7 -0
  17. package/dist/dates/UI5Date.js.map +1 -0
  18. package/dist/dates/UniversalDate.d.ts +2 -1
  19. package/dist/dates/UniversalDate.js.map +1 -1
  20. package/dist/dates/calculateWeekNumber.d.ts +3 -1
  21. package/dist/dates/calculateWeekNumber.js +6 -6
  22. package/dist/dates/calculateWeekNumber.js.map +1 -1
  23. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +1 -1
  24. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -1
  25. package/dist/dates/getDaysInMonth.js.map +1 -1
  26. package/dist/dates/getRoundedTimestamp.js +1 -0
  27. package/dist/dates/getRoundedTimestamp.js.map +1 -1
  28. package/dist/dates/getTodayUTCTimestamp.d.ts +1 -1
  29. package/dist/dates/getTodayUTCTimestamp.js +2 -1
  30. package/dist/dates/getTodayUTCTimestamp.js.map +1 -1
  31. package/dist/dates/modifyDateBy.d.ts +2 -1
  32. package/dist/dates/modifyDateBy.js +34 -19
  33. package/dist/dates/modifyDateBy.js.map +1 -1
  34. package/dist/dates/transformDateToSecondaryType.d.ts +1 -1
  35. package/dist/dates/transformDateToSecondaryType.js +3 -2
  36. package/dist/dates/transformDateToSecondaryType.js.map +1 -1
  37. package/dist/features/calendar/Buddhist.js.map +1 -1
  38. package/dist/features/calendar/Gregorian.js.map +1 -1
  39. package/dist/features/calendar/Islamic.js.map +1 -1
  40. package/dist/features/calendar/Japanese.js.map +1 -1
  41. package/dist/features/calendar/Persian.js.map +1 -1
  42. package/dist/generated/assets/cldr/ar.json +5571 -6704
  43. package/dist/generated/assets/cldr/ar_EG.json +5571 -6704
  44. package/dist/generated/assets/cldr/ar_SA.json +5570 -6704
  45. package/dist/generated/assets/cldr/bg.json +4491 -5742
  46. package/dist/generated/assets/cldr/ca.json +4478 -5793
  47. package/dist/generated/assets/cldr/cnr.json +4667 -0
  48. package/dist/generated/assets/cldr/cs.json +5067 -6294
  49. package/dist/generated/assets/cldr/cy.json +5479 -6612
  50. package/dist/generated/assets/cldr/da.json +4371 -5651
  51. package/dist/generated/assets/cldr/de.json +4420 -5713
  52. package/dist/generated/assets/cldr/de_AT.json +4421 -5714
  53. package/dist/generated/assets/cldr/de_CH.json +4419 -5712
  54. package/dist/generated/assets/cldr/el.json +4309 -5579
  55. package/dist/generated/assets/cldr/el_CY.json +4309 -5579
  56. package/dist/generated/assets/cldr/en.json +4342 -5732
  57. package/dist/generated/assets/cldr/en_AU.json +4382 -5724
  58. package/dist/generated/assets/cldr/en_GB.json +4373 -5733
  59. package/dist/generated/assets/cldr/en_HK.json +4382 -5739
  60. package/dist/generated/assets/cldr/en_IE.json +4373 -5733
  61. package/dist/generated/assets/cldr/en_IN.json +4378 -5734
  62. package/dist/generated/assets/cldr/en_NZ.json +4373 -5733
  63. package/dist/generated/assets/cldr/en_PG.json +4374 -5734
  64. package/dist/generated/assets/cldr/en_SG.json +4378 -5735
  65. package/dist/generated/assets/cldr/en_ZA.json +4374 -5734
  66. package/dist/generated/assets/cldr/es.json +4584 -5641
  67. package/dist/generated/assets/cldr/es_AR.json +4587 -5643
  68. package/dist/generated/assets/cldr/es_BO.json +4586 -5642
  69. package/dist/generated/assets/cldr/es_CL.json +4479 -5643
  70. package/dist/generated/assets/cldr/es_CO.json +4479 -5642
  71. package/dist/generated/assets/cldr/es_MX.json +4588 -5644
  72. package/dist/generated/assets/cldr/es_PE.json +4370 -5642
  73. package/dist/generated/assets/cldr/es_UY.json +4372 -5644
  74. package/dist/generated/assets/cldr/es_VE.json +4371 -5643
  75. package/dist/generated/assets/cldr/et.json +4373 -5729
  76. package/dist/generated/assets/cldr/fa.json +4429 -5647
  77. package/dist/generated/assets/cldr/fi.json +4514 -5804
  78. package/dist/generated/assets/cldr/fr.json +4383 -5741
  79. package/dist/generated/assets/cldr/fr_BE.json +4383 -5741
  80. package/dist/generated/assets/cldr/fr_CA.json +4377 -5735
  81. package/dist/generated/assets/cldr/fr_CH.json +4401 -5759
  82. package/dist/generated/assets/cldr/fr_LU.json +4383 -5741
  83. package/dist/generated/assets/cldr/he.json +4980 -6175
  84. package/dist/generated/assets/cldr/hi.json +4345 -5558
  85. package/dist/generated/assets/cldr/hr.json +4640 -5681
  86. package/dist/generated/assets/cldr/hu.json +4415 -5686
  87. package/dist/generated/assets/cldr/id.json +4132 -5420
  88. package/dist/generated/assets/cldr/it.json +4355 -5712
  89. package/dist/generated/assets/cldr/it_CH.json +4355 -5712
  90. package/dist/generated/assets/cldr/ja.json +4251 -5626
  91. package/dist/generated/assets/cldr/kk.json +4503 -5487
  92. package/dist/generated/assets/cldr/ko.json +4210 -5534
  93. package/dist/generated/assets/cldr/lt.json +4939 -6243
  94. package/dist/generated/assets/cldr/lv.json +4651 -5874
  95. package/dist/generated/assets/cldr/mk.json +4408 -0
  96. package/dist/generated/assets/cldr/ms.json +4093 -5245
  97. package/dist/generated/assets/cldr/nb.json +4403 -5740
  98. package/dist/generated/assets/cldr/nl.json +4542 -5613
  99. package/dist/generated/assets/cldr/nl_BE.json +4542 -5613
  100. package/dist/generated/assets/cldr/pl.json +4978 -5972
  101. package/dist/generated/assets/cldr/pt.json +4597 -5567
  102. package/dist/generated/assets/cldr/pt_PT.json +4648 -5702
  103. package/dist/generated/assets/cldr/ro.json +4633 -5852
  104. package/dist/generated/assets/cldr/ru.json +4947 -6169
  105. package/dist/generated/assets/cldr/ru_UA.json +4947 -6169
  106. package/dist/generated/assets/cldr/sk.json +4980 -6166
  107. package/dist/generated/assets/cldr/sl.json +4948 -6136
  108. package/dist/generated/assets/cldr/sr.json +4737 -5888
  109. package/dist/generated/assets/cldr/sr_Latn.json +4722 -5889
  110. package/dist/generated/assets/cldr/sv.json +4406 -5774
  111. package/dist/generated/assets/cldr/th.json +4234 -5627
  112. package/dist/generated/assets/cldr/tr.json +4451 -5809
  113. package/dist/generated/assets/cldr/uk.json +4908 -6115
  114. package/dist/generated/assets/cldr/vi.json +4094 -5435
  115. package/dist/generated/assets/cldr/zh_CN.json +4124 -5429
  116. package/dist/generated/assets/cldr/zh_HK.json +4132 -5437
  117. package/dist/generated/assets/cldr/zh_SG.json +4132 -5437
  118. package/dist/generated/assets/cldr/zh_TW.json +4155 -5525
  119. package/dist/generated/json-imports/LocaleData-static.d.ts +1 -0
  120. package/dist/generated/json-imports/LocaleData-static.js +11 -11
  121. package/dist/generated/json-imports/LocaleData-static.js.map +1 -0
  122. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  123. package/dist/generated/json-imports/LocaleData.js +88 -88
  124. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  125. package/dist/getCachedLocaleDataInstance.js.map +1 -1
  126. package/dist/locale/getLocaleData.js.map +1 -1
  127. package/dist/sap/base/Event.js +59 -0
  128. package/dist/sap/base/Eventing.js +146 -0
  129. package/dist/sap/base/Log.js +2 -239
  130. package/dist/sap/base/assert.js +28 -1
  131. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  132. package/dist/sap/base/config.js +17 -0
  133. package/dist/sap/base/i18n/Formatting.js +1133 -0
  134. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  135. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  136. package/dist/sap/base/i18n/Localization.js +12 -0
  137. package/dist/sap/base/i18n/Localization.js.map +1 -0
  138. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  139. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  140. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  141. package/dist/sap/base/strings/camelize.js +30 -0
  142. package/dist/sap/base/strings/formatMessage.js +88 -15
  143. package/dist/sap/base/util/LoaderExtensions.js.map +1 -1
  144. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  145. package/dist/sap/base/util/ObjectPath.js +4 -33
  146. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  147. package/dist/sap/base/util/Version.js +157 -0
  148. package/dist/sap/base/util/_merge.js +83 -26
  149. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  150. package/dist/sap/base/util/deepClone.js +102 -0
  151. package/dist/sap/base/util/deepEqual.js +75 -51
  152. package/dist/sap/base/util/extend.js +58 -7
  153. package/dist/sap/base/util/isEmptyObject.js +34 -0
  154. package/dist/sap/base/util/isPlainObject.js +35 -1
  155. package/dist/sap/base/util/now.js +24 -3
  156. package/dist/sap/base/util/resolveReference.js +3 -0
  157. package/dist/sap/base/util/uid.js +27 -0
  158. package/dist/sap/ui/base/DataType.js +657 -0
  159. package/dist/sap/ui/base/Interface.js +47 -1
  160. package/dist/sap/ui/base/Metadata.js +435 -171
  161. package/dist/sap/ui/base/Object.js +284 -48
  162. package/dist/sap/ui/core/CalendarType.js +24 -8
  163. package/dist/sap/ui/core/Configuration.d.ts +2 -1
  164. package/dist/sap/ui/core/Configuration.js +4 -1
  165. package/dist/sap/ui/core/Configuration.js.map +1 -1
  166. package/dist/sap/ui/core/Core.d.ts +3 -2
  167. package/dist/sap/ui/core/Core.js.map +1 -1
  168. package/dist/sap/ui/core/FormatSettings.d.ts +1 -1
  169. package/dist/sap/ui/core/FormatSettings.js +2 -1
  170. package/dist/sap/ui/core/FormatSettings.js.map +1 -1
  171. package/dist/sap/ui/core/Locale.js +190 -155
  172. package/dist/sap/ui/core/LocaleData.js +2662 -1300
  173. package/dist/sap/ui/core/Supportability.js +5 -0
  174. package/dist/sap/ui/core/Theming.js +539 -0
  175. package/dist/sap/ui/core/date/Buddhist.js +162 -87
  176. package/dist/sap/ui/core/date/CalendarUtils.js +61 -32
  177. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -7
  178. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  179. package/dist/sap/ui/core/date/Islamic.js +298 -185
  180. package/dist/sap/ui/core/date/Japanese.js +210 -115
  181. package/dist/sap/ui/core/date/Persian.js +324 -195
  182. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  183. package/dist/sap/ui/core/date/UniversalDate.js +1238 -255
  184. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  185. package/dist/sap/ui/core/format/DateFormat.js +3167 -2093
  186. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -94
  187. package/package-scripts.cjs +28 -0
  188. package/package.json +14 -7
  189. package/tsconfig.json +12 -1
  190. package/used-modules.txt +25 -1
  191. package/dist/sap/ui/Device.js +0 -5
  192. package/package-scripts.js +0 -38
  193. package/src/Assets-static.ts +0 -2
  194. package/src/Assets.ts +0 -2
  195. package/src/DateFormat.ts +0 -8
  196. package/src/LocaleData.ts +0 -8
  197. package/src/dates/CalendarDate.ts +0 -232
  198. package/src/dates/ExtremeDates.ts +0 -40
  199. package/src/dates/UniversalDate.ts +0 -51
  200. package/src/dates/calculateWeekNumber.ts +0 -53
  201. package/src/dates/convertMonthNumbersToMonthNames.ts +0 -34
  202. package/src/dates/getDaysInMonth.ts +0 -11
  203. package/src/dates/getRoundedTimestamp.ts +0 -14
  204. package/src/dates/getTodayUTCTimestamp.ts +0 -10
  205. package/src/dates/modifyDateBy.ts +0 -42
  206. package/src/dates/transformDateToSecondaryType.ts +0 -21
  207. package/src/features/calendar/Buddhist.ts +0 -1
  208. package/src/features/calendar/Gregorian.ts +0 -1
  209. package/src/features/calendar/Islamic.ts +0 -1
  210. package/src/features/calendar/Japanese.ts +0 -1
  211. package/src/features/calendar/Persian.ts +0 -1
  212. package/src/getCachedLocaleDataInstance.ts +0 -15
  213. package/src/locale/getLocaleData.ts +0 -28
  214. package/src/sap/base/util/LoaderExtensions.ts +0 -17
  215. package/src/sap/ui/core/Configuration.ts +0 -22
  216. package/src/sap/ui/core/Core.ts +0 -15
  217. package/src/sap/ui/core/FormatSettings.ts +0 -15
  218. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
@@ -0,0 +1,1133 @@
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2009-2024 SAP SE or an SAP affiliate company.
4
+ * Licensed under the Apache License, Version 2.0 - see LICENSE.txt.
5
+ */
6
+ import assert from "../assert.js";
7
+ import BaseConfig from "../config.js";
8
+ import Eventing from "../Eventing.js";
9
+ import Log from "../Log.js";
10
+ import Localization from "./Localization.js";
11
+ import LanguageTag from "./LanguageTag.js";
12
+ import CalendarType from "./date/CalendarType.js";
13
+ import CalendarWeekNumbering from "./date/CalendarWeekNumbering.js";
14
+ import deepEqual from "../util/deepEqual.js";
15
+ import extend from "../util/extend.js";
16
+ import isEmptyObject from "../util/isEmptyObject.js";
17
+ const oEventing = new Eventing();
18
+ const oWritableConfig = BaseConfig.getWritableInstance();
19
+ const mSettings = {};
20
+ let mChanges;
21
+ let aCustomIslamicCalendarData;
22
+ const M_ABAP_DATE_FORMAT_PATTERN = {
23
+ "": {
24
+ pattern: null
25
+ },
26
+ "1": {
27
+ pattern: "dd.MM.yyyy"
28
+ },
29
+ "2": {
30
+ pattern: "MM/dd/yyyy"
31
+ },
32
+ "3": {
33
+ pattern: "MM-dd-yyyy"
34
+ },
35
+ "4": {
36
+ pattern: "yyyy.MM.dd"
37
+ },
38
+ "5": {
39
+ pattern: "yyyy/MM/dd"
40
+ },
41
+ "6": {
42
+ pattern: "yyyy-MM-dd"
43
+ },
44
+ "7": {
45
+ pattern: "Gyy.MM.dd"
46
+ },
47
+ "8": {
48
+ pattern: "Gyy/MM/dd"
49
+ },
50
+ "9": {
51
+ pattern: "Gyy-MM-dd"
52
+ },
53
+ "A": {
54
+ pattern: "yyyy/MM/dd"
55
+ },
56
+ "B": {
57
+ pattern: "yyyy/MM/dd"
58
+ },
59
+ "C": {
60
+ pattern: "yyyy/MM/dd"
61
+ }
62
+ };
63
+ const M_ABAP_TIME_FORMAT_PATTERN = {
64
+ "": {
65
+ "short": null,
66
+ medium: null,
67
+ dayPeriods: null
68
+ },
69
+ "0": {
70
+ "short": "HH:mm",
71
+ medium: "HH:mm:ss",
72
+ dayPeriods: null
73
+ },
74
+ "1": {
75
+ "short": "hh:mm a",
76
+ medium: "hh:mm:ss a",
77
+ dayPeriods: ["AM", "PM"]
78
+ },
79
+ "2": {
80
+ "short": "hh:mm a",
81
+ medium: "hh:mm:ss a",
82
+ dayPeriods: ["am", "pm"]
83
+ },
84
+ "3": {
85
+ "short": "KK:mm a",
86
+ medium: "KK:mm:ss a",
87
+ dayPeriods: ["AM", "PM"]
88
+ },
89
+ "4": {
90
+ "short": "KK:mm a",
91
+ medium: "KK:mm:ss a",
92
+ dayPeriods: ["am", "pm"]
93
+ }
94
+ };
95
+ const M_ABAP_NUMBER_FORMAT_SYMBOLS = {
96
+ "": {
97
+ groupingSeparator: null,
98
+ decimalSeparator: null
99
+ },
100
+ " ": {
101
+ groupingSeparator: ".",
102
+ decimalSeparator: ","
103
+ },
104
+ "X": {
105
+ groupingSeparator: ",",
106
+ decimalSeparator: "."
107
+ },
108
+ "Y": {
109
+ groupingSeparator: " ",
110
+ decimalSeparator: ","
111
+ }
112
+ };
113
+ function check(bCondition, sMessage) {
114
+ if (!bCondition) {
115
+ throw new TypeError(sMessage);
116
+ }
117
+ }
118
+ function _set(sKey, oValue) {
119
+ // Invalidating the BaseConfig is necessary, because Formatting.getLanguageTag
120
+ // does defaulting depending on the mSettings. In case no specifc LaguageTag was
121
+ // set the default would become applied and cached. If the mSettings are changed
122
+ // inbetween the cache would not become invalidated because there is no direct
123
+ // change to the Configuration and therefore the cached value would be wrong.
124
+ BaseConfig._.invalidate();
125
+ const oOldValue = mSettings[sKey];
126
+ if (oValue != null) {
127
+ mSettings[sKey] = oValue;
128
+ } else {
129
+ delete mSettings[sKey];
130
+ }
131
+ // report a change only if old and new value differ (null/undefined are treated as the same value)
132
+ if ((oOldValue != null || oValue != null) && !deepEqual(oOldValue, oValue)) {
133
+ const bFireEvent = !mChanges;
134
+ mChanges ??= {};
135
+ mChanges[sKey] = oValue;
136
+ if (bFireEvent) {
137
+ fireChange();
138
+ }
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Helper that creates a LanguageTag object from the given language
144
+ * or, throws an error for non BCP-47 compliant languages.
145
+ *
146
+ * @param {string|module:sap/base/i18n/LanguageTag} vLanguageTag A BCP-47 compliant language tag
147
+ * @returns {module:sap/base/i18n/LanguageTag} The resulting LanguageTag
148
+ * @private
149
+ * @since 1.116.0
150
+ */
151
+ function createLanguageTag(vLanguageTag) {
152
+ let oLanguageTag;
153
+ if (vLanguageTag && typeof vLanguageTag === 'string') {
154
+ try {
155
+ oLanguageTag = new LanguageTag(vLanguageTag);
156
+ } catch (e) {
157
+ // ignore
158
+ }
159
+ } else if (vLanguageTag instanceof LanguageTag) {
160
+ oLanguageTag = vLanguageTag;
161
+ }
162
+ return oLanguageTag;
163
+ }
164
+
165
+ /**
166
+ * Configuration for formatting specific parameters
167
+ * @public
168
+ * @alias module:sap/base/i18n/Formatting
169
+ * @namespace
170
+ * @since 1.120
171
+ */
172
+ const Formatting = {
173
+ /**
174
+ * The <code>change</code> event is fired, when the configuration options are changed.
175
+ * For the event parameters please refer to {@link module:sap/base/i18n/Formatting$ChangeEvent
176
+ * Formatting$ChangeEvent}.
177
+ *
178
+ * @name module:sap/base/i18n/Formatting.change
179
+ * @event
180
+ * @param {module:sap/base/i18n/Formatting$ChangeEvent} oEvent
181
+ * @public
182
+ * @since 1.120
183
+ */
184
+
185
+ /**
186
+ * The formatting change event. Contains only the parameters which were changed.
187
+ *
188
+ * The list below shows the possible combinations of parameters available as part of the change event.
189
+ *
190
+ * <ul>
191
+ * <li>{@link module:sap/base/i18n/Formatting.setLanguageTag Formatting.setLanguageTag}:
192
+ * <ul>
193
+ * <li><code>languageTag</code></li>
194
+ * </ul>
195
+ * </li>
196
+ * <li>{@link module:sap/base/i18n/Formatting.setCustomIslamicCalendarData Formatting.setCustomIslamicCalendarData}:
197
+ * <ul>
198
+ * <li><code>customIslamicCalendarData</code></li>
199
+ * </ul>
200
+ * </li>
201
+ * <li>{@link module:sap/base/i18n/Formatting.setCalendarWeekNumbering Formatting.setCalendarWeekNumbering}:
202
+ * <ul>
203
+ * <li><code>calendarWeekNumbering</code></li>
204
+ * </ul>
205
+ * </li>
206
+ * <li>{@link module:sap/base/i18n/Formatting.setCalendarType Formatting.setCalendarType}:
207
+ * <ul>
208
+ * <li><code>calendarType</code></li>
209
+ * </ul>
210
+ * </li>
211
+ * <li>{@link module:sap/base/i18n/Formatting.addCustomCurrencies Formatting.addCustomCurrencies} / {@link module:sap/base/i18n/Formatting.setCustomCurrencies Formatting.setCustomCurrencies}:
212
+ * <ul>
213
+ * <li><code>currency</code></li>
214
+ * </ul>
215
+ * </li>
216
+ * <li>{@link module:sap/base/i18n/Formatting.setABAPDateFormat Formatting.setABAPDateFormat} (all parameters listed below):
217
+ * <ul>
218
+ * <li><code>ABAPDateFormat</code></li>
219
+ * <li><code>"dateFormats-short"</code></li>
220
+ * <li><code>"dateFormats-medium"</code></li>
221
+ * </ul>
222
+ * </li>
223
+ * <li>{@link module:sap/base/i18n/Formatting.setABAPTimeFormat Formatting.setABAPTimeFormat} (all parameters listed below):
224
+ * <ul>
225
+ * <li><code>ABAPTimeFormat</code></li>
226
+ * <li><code>"timeFormats-short"</code></li>
227
+ * <li><code>"timeFormats-medium"</code></li>
228
+ * <li><code>"dayPeriods-format-abbreviated"</code></li>
229
+ * </ul>
230
+ * </li>
231
+ * <li>{@link module:sap/base/i18n/Formatting.setABAPNumberFormat Formatting.setABAPNumberFormat} (all parameters listed below):
232
+ * <ul>
233
+ * <li><code>ABAPNumberFormat</code></li>
234
+ * <li><code>"symbols-latn-group"</code></li>
235
+ * <li><code>"symbols-latn-decimal"</code></li>
236
+ * </ul>
237
+ * </li>
238
+ * <li>{@link module:sap/base/i18n/Formatting.setDatePattern Formatting.setDatePattern} (one of the parameters listed below):
239
+ * <ul>
240
+ * <li><code>"dateFormats-short"</code></li>
241
+ * <li><code>"dateFormats-medium"</code></li>
242
+ * <li><code>"dateFormats-long"</code></li>
243
+ * <li><code>"dateFormats-full"</code></li>
244
+ * </ul>
245
+ * </li>
246
+ * <li>{@link module:sap/base/i18n/Formatting.setTimePattern Formatting.setTimePattern} (one of the parameters listed below):
247
+ * <ul>
248
+ * <li><code>"timeFormats-short"</code></li>
249
+ * <li><code>"timeFormats-medium"</code></li>
250
+ * <li><code>"timeFormats-long"</code></li>
251
+ * <li><code>"timeFormats-full"</code></li>
252
+ * </ul>
253
+ * </li>
254
+ * <li>{@link module:sap/base/i18n/Formatting.setNumberSymbol Formatting.setNumberSymbol} (one of the parameters listed below):
255
+ * <ul>
256
+ * <li><code>"symbols-latn-group"</code></li>
257
+ * <li><code>"symbols-latn-decimal"</code></li>
258
+ * <li><code>"symbols-latn-plusSign"</code></li>
259
+ * <li><code>"symbols-latn-minusSign"</code></li>
260
+ * </ul>
261
+ * </li>
262
+ * </ul>
263
+ *
264
+ * @typedef {object} module:sap/base/i18n/Formatting$ChangeEvent
265
+ * @property {string} [languageTag] The formatting language tag.
266
+ * @property {string} [ABAPDateFormat] The ABAP date format.
267
+ * @property {string} [ABAPTimeFormat] The ABAP time format.
268
+ * @property {string} [ABAPNumberFormat] The ABAP number format.
269
+ * @property {object[]} [legacyDateCalendarCustomizing] The legacy date calendar customizing.
270
+ * @property {object} [calendarWeekNumbering] The calendar week numbering.
271
+ * @property {object} [calendarType] The calendar type.
272
+ * @property {string} ["dateFormats-short"] The short date format.
273
+ * @property {string} ["dateFormats-medium"] The medium date format.
274
+ * @property {string} ["dateFormats-long"] The long date format.
275
+ * @property {string} ["dateFormats-full"] The full date format.
276
+ * @property {string} ["timeFormats-short"] The short time format.
277
+ * @property {string} ["timeFormats-medium"] The medium time format.
278
+ * @property {string} ["timeFormats-long"] The long time format.
279
+ * @property {string} ["timeFormats-full"] The full time format.
280
+ * @property {string} ["symbols-latn-group"] The latin symbols group.
281
+ * @property {string} ["symbols-latn-decimal"] The latin symbols decimal.
282
+ * @property {string} ["symbols-latn-plusSign"] The latin symbols plusSign.
283
+ * @property {string} ["symbols-latn-minusSign"] The latin symbols minusSign.
284
+ * @property {Object<string,string>} [currency] The currency.
285
+ * @property {string[]} ["dayPeriods-format-abbreviated"] The abbreviated day periods format.
286
+ * @public
287
+ * @since 1.120
288
+ */
289
+
290
+ /**
291
+ * Attaches the <code>fnFunction</code> event handler to the {@link #event:change change} event
292
+ * of <code>module:sap/base/i18n/Formatting</code>.
293
+ *
294
+ * @param {function(module:sap/base/i18n/Formatting$ChangeEvent)} fnFunction
295
+ * The function to be called when the event occurs
296
+ * @public
297
+ * @since 1.120
298
+ */
299
+ attachChange(fnFunction) {
300
+ oEventing.attachEvent("change", fnFunction);
301
+ },
302
+ /**
303
+ * Detaches event handler <code>fnFunction</code> from the {@link #event:change change} event of
304
+ * this <code>module:sap/base/i18n/Formatting</code>.
305
+ *
306
+ * @param {function(module:sap/base/i18n/Formatting$ChangeEvent)} fnFunction Function to be called when the event occurs
307
+ * @public
308
+ * @since 1.120
309
+ */
310
+ detachChange(fnFunction) {
311
+ oEventing.detachEvent("change", fnFunction);
312
+ },
313
+ /**
314
+ * Returns the LanguageTag to be used for formatting.
315
+ *
316
+ * If no such LanguageTag has been defined, this method falls back to the language,
317
+ * see {@link module:sap/base/i18n/Localization.getLanguage Localization.getLanguage()}.
318
+ *
319
+ * If any user preferences for date, time or number formatting have been set,
320
+ * and if no format LanguageTag has been specified, then a special private use subtag
321
+ * is added to the LanguageTag, indicating to the framework that these user preferences
322
+ * should be applied.
323
+ *
324
+ * @returns {module:sap/base/i18n/LanguageTag} the format LanguageTag
325
+ * @public
326
+ * @since 1.120
327
+ */
328
+ getLanguageTag() {
329
+ function fallback() {
330
+ let oLanguageTag = new LanguageTag(Localization.getLanguage());
331
+ // if any user settings have been defined, add the private use subtag "sapufmt"
332
+ if (!isEmptyObject(mSettings) || Formatting.getCalendarWeekNumbering() !== CalendarWeekNumbering.Default) {
333
+ let l = oLanguageTag.toString();
334
+ if (l.indexOf("-x-") < 0) {
335
+ l += "-x-sapufmt";
336
+ } else if (l.indexOf("-sapufmt") <= l.indexOf("-x-")) {
337
+ l += "-sapufmt";
338
+ }
339
+ oLanguageTag = new LanguageTag(l);
340
+ }
341
+ return oLanguageTag;
342
+ }
343
+ return oWritableConfig.get({
344
+ name: "sapUiFormatLocale",
345
+ type: function (sFormatLocale) {
346
+ return new LanguageTag(sFormatLocale);
347
+ },
348
+ defaultValue: fallback,
349
+ external: true
350
+ });
351
+ },
352
+ /**
353
+ * Sets a new language tag to be used from now on for retrieving language
354
+ * specific formatters. Modifying this setting does not have an impact on
355
+ * the retrieval of translated texts!
356
+ *
357
+ * Can either be set to a concrete value (a BCP47 or Java locale compliant
358
+ * language tag) or to <code>null</code>. When set to <code>null</code> (default
359
+ * value) then locale specific formatters are retrieved for the current language.
360
+ *
361
+ * After changing the format locale, the framework tries to update localization
362
+ * specific parts of the UI. See the documentation of
363
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
364
+ * for details and restrictions.
365
+ *
366
+ * <b>Note</b>: When a language tag is set, it has higher priority than a number,
367
+ * date or time format defined with a call to <code>setABAPNumberFormat</code>,
368
+ * <code>setABAPDateFormat</code> or <code>setABAPTimeFormat</code>.
369
+ *
370
+ * <b>Note</b>: See documentation of
371
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
372
+ * for restrictions.
373
+ *
374
+ * @param {string|module:sap/base/i18n/LanguageTag|null} vLanguageTag the new BCP47 compliant language tag;
375
+ * case doesn't matter and underscores can be used instead of dashes to separate
376
+ * components (compatibility with Java Locale IDs)
377
+ * @throws {TypeError} When <code>sLanguageTag</code> is given, but is not a valid BCP47 language
378
+ * tag or Java locale identifier
379
+ * @public
380
+ * @since 1.120
381
+ */
382
+ setLanguageTag(vLanguageTag) {
383
+ const oLanguageTag = createLanguageTag(vLanguageTag);
384
+ check(vLanguageTag == null || oLanguageTag, "vLanguageTag must be a BCP47 language tag or Java Locale id or null");
385
+ const oOldLanguageTag = Formatting.getLanguageTag();
386
+ oWritableConfig.set("sapUiFormatLocale", oLanguageTag?.toString());
387
+ const oCurrentLanguageTag = Formatting.getLanguageTag();
388
+ if (oOldLanguageTag.toString() !== oCurrentLanguageTag.toString()) {
389
+ const bFireEvent = !mChanges;
390
+ mChanges ??= {};
391
+ mChanges.languageTag = oCurrentLanguageTag.toString();
392
+ if (bFireEvent) {
393
+ fireChange();
394
+ }
395
+ }
396
+ },
397
+ /**
398
+ * @deprecated As of Version 1.120
399
+ */
400
+ _set: _set,
401
+ /**
402
+ * Retrieves the custom units.
403
+ * These custom units are set by {@link #setCustomUnits} and {@link #addCustomUnits}
404
+ * @returns {object} custom units object
405
+ * @see {@link module:sap/base/i18n/Formatting.setCustomUnits}
406
+ * @see {@link module:sap/base/i18n/Formatting.addCustomUnits}
407
+ * @private
408
+ * @since 1.116.0
409
+ */
410
+ getCustomUnits() {
411
+ return mSettings["units"]?.["short"];
412
+ },
413
+ /**
414
+ * Sets custom units which can be used to do Unit Formatting.
415
+ *
416
+ * The custom unit object consists of:
417
+ * * a custom unit key which can then be referenced to use this unit.
418
+ * * <code>displayName</code> which represents the name of the unit.
419
+ * * <code>unitPattern-count-&lt;pluralName&gt;</code> which represents the plural category of the locale for the given value.
420
+ * The plural category is defined within the locale, e.g. in the 'en' locale:
421
+ * <code>unitPattern-count-one</code> for <code>1</code>,
422
+ * <code>unitPattern-count-zero</code> for <code>0</code>,
423
+ * <code>unitPattern-count-other</code> for all the res
424
+ * To retrieve all plural categories defined for a locale use <code>sap.ui.core.LocaleData.prototype.getPluralCategories</code>.
425
+ *
426
+ * A Sample custom unit definition could look like this:
427
+ * <code>
428
+ * {
429
+ * "BAG": {
430
+ * "displayName": "Bag",
431
+ * "unitPattern-count-one": "{0} bag",
432
+ * "unitPattern-count-other": "{0} bags"
433
+ * }
434
+ * }
435
+ * </code>
436
+ * In the above snippet:
437
+ * * <code>"BAG"</code> represent the unit key which is used to reference it.
438
+ * * <code>"unitPattern-count-one"</code> represent the unit pattern for the form "one", e.g. the number <code>1</code> in the 'en' locale.
439
+ * * <code>"unitPattern-count-other"</code> represent the unit pattern for all other numbers which do not
440
+ * match the plural forms of the previous patterns.
441
+ * * In the patterns <code>{0}</code> is replaced by the number
442
+ *
443
+ * E.g. In locale 'en' value <code>1</code> would result in <code>1 Bag</code>, while <code>2</code> would result in <code>2 Bags</code>
444
+ * @param {object} mUnits custom unit object which replaces the current custom unit definition. Call with <code>null</code> to delete custom units.
445
+ * @private
446
+ * @since 1.116.0
447
+ */
448
+ setCustomUnits(mUnits) {
449
+ // add custom units, or remove the existing ones if none are given
450
+ let mUnitsshort = null;
451
+ if (mUnits) {
452
+ mUnitsshort = {
453
+ "short": mUnits
454
+ };
455
+ }
456
+ _set("units", mUnitsshort);
457
+ },
458
+ /**
459
+ * Adds custom units.
460
+ * Similar to {@link #setCustomUnits} but instead of setting the custom units, it will add additional ones.
461
+ * @param {object} mUnits custom unit object which replaces the current custom unit definition. Call with <code>null</code> to delete custom units.
462
+ * @see {@link module:sap/base/i18n/Formatting.setCustomUnits}
463
+ * @private
464
+ * @since 1.116.0
465
+ */
466
+ addCustomUnits(mUnits) {
467
+ // add custom units, or remove the existing ones if none are given
468
+ const mExistingUnits = Formatting.getCustomUnits();
469
+ if (mExistingUnits) {
470
+ mUnits = extend({}, mExistingUnits, mUnits);
471
+ }
472
+ Formatting.setCustomUnits(mUnits);
473
+ },
474
+ /**
475
+ * Sets custom unit mappings.
476
+ * Unit mappings contain key value pairs (both strings)
477
+ * * {string} key: a new entry which maps to an existing unit key
478
+ * * {string} value: an existing unit key
479
+ *
480
+ * Example:
481
+ * <code>
482
+ * {
483
+ * "my": "my-custom-unit",
484
+ * "cm": "length-centimeter"
485
+ * }
486
+ * </code>
487
+ * Note: It is possible to create multiple entries per unit key.
488
+ * Call with <code>null</code> to delete unit mappings.
489
+ * @param {object} mUnitMappings unit mappings
490
+ * @private
491
+ * @since 1.116.0
492
+ */
493
+ setUnitMappings(mUnitMappings) {
494
+ _set("unitMappings", mUnitMappings);
495
+ },
496
+ /**
497
+ * Adds unit mappings.
498
+ * Similar to {@link #setUnitMappings} but instead of setting the unit mappings, it will add additional ones.
499
+ * @param {object} mUnitMappings unit mappings
500
+ * @see {@link module:sap/base/i18n/Formatting.setUnitMappings}
501
+ * @private
502
+ * @since 1.116.0
503
+ */
504
+ addUnitMappings(mUnitMappings) {
505
+ // add custom units, or remove the existing ones if none are given
506
+ const mExistingUnits = Formatting.getUnitMappings();
507
+ if (mExistingUnits) {
508
+ mUnitMappings = extend({}, mExistingUnits, mUnitMappings);
509
+ }
510
+ Formatting.setUnitMappings(mUnitMappings);
511
+ },
512
+ /**
513
+ * Retrieves the unit mappings.
514
+ * These unit mappings are set by {@link #setUnitMappings} and {@link #addUnitMappings}
515
+ * @private
516
+ * @returns {object} unit mapping object
517
+ * @see {@link module:sap/base/i18n/Formatting.setUnitMappings}
518
+ * @see {@link module:sap/base/i18n/Formatting.addUnitMappings}
519
+ * @since 1.116.0
520
+ */
521
+ getUnitMappings() {
522
+ return mSettings["unitMappings"];
523
+ },
524
+ /**
525
+ * Returns the currently set date pattern or undefined if no pattern has been defined.
526
+ * @param {"short"|"medium"|"long"|"full"} sStyle The date style (short, medium, long or full)
527
+ * @returns {string} The resulting date pattern
528
+ * @public
529
+ * @since 1.120
530
+ */
531
+ getDatePattern(sStyle) {
532
+ assert(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
533
+ return mSettings["dateFormats-" + sStyle];
534
+ },
535
+ /**
536
+ * Defines the preferred format pattern for the given date format style.
537
+ *
538
+ * Calling this method with a null or undefined pattern removes a previously set pattern.
539
+ *
540
+ * If a pattern is defined, it will be preferred over patterns derived from the current locale.
541
+ *
542
+ * See class {@link sap.ui.core.format.DateFormat DateFormat} for details about the pattern syntax.
543
+ *
544
+ * After changing the date pattern, the framework tries to update localization
545
+ * specific parts of the UI. See the documentation of {@link module:sap/base/i18n/Localization.setLanguage
546
+ * Localization.setLanguage()} for details and restrictions.
547
+ *
548
+ * @param {"short"|"medium"|"long"|"full"} sStyle must be one of short, medium, long or full.
549
+ * @param {string} sPattern the format pattern to be used in LDML syntax.
550
+ * @public
551
+ * @since 1.120
552
+ */
553
+ setDatePattern(sStyle, sPattern) {
554
+ check(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
555
+ _set("dateFormats-" + sStyle, sPattern);
556
+ },
557
+ /**
558
+ * Returns the currently set time pattern or undefined if no pattern has been defined.
559
+ * @param {"short"|"medium"|"long"|"full"} sStyle The time style (short, medium, long or full)
560
+ * @returns {string} The resulting time pattern
561
+ * @public
562
+ * @since 1.120
563
+ */
564
+ getTimePattern(sStyle) {
565
+ assert(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
566
+ return mSettings["timeFormats-" + sStyle];
567
+ },
568
+ /**
569
+ * Defines the preferred format pattern for the given time format style.
570
+ *
571
+ * Calling this method with a null or undefined pattern removes a previously set pattern.
572
+ *
573
+ * If a pattern is defined, it will be preferred over patterns derived from the current locale.
574
+ *
575
+ * See class {@link sap.ui.core.format.DateFormat DateFormat} for details about the pattern syntax.
576
+ *
577
+ * After changing the time pattern, the framework tries to update localization
578
+ * specific parts of the UI. See the documentation of
579
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
580
+ * for details and restrictions.
581
+ *
582
+ * @param {"short"|"medium"|"long"|"full"} sStyle must be one of short, medium, long or full.
583
+ * @param {string} sPattern the format pattern to be used in LDML syntax.
584
+ * @public
585
+ * @since 1.120
586
+ */
587
+ setTimePattern(sStyle, sPattern) {
588
+ check(sStyle == "short" || sStyle == "medium" || sStyle == "long" || sStyle == "full", "sStyle must be short, medium, long or full");
589
+ _set("timeFormats-" + sStyle, sPattern);
590
+ },
591
+ /**
592
+ * Returns the currently set number symbol of the given type or undefined if no symbol has been defined.
593
+ *
594
+ * @param {"group"|"decimal"|"plusSign"|"minusSign"} sType the type of symbol
595
+ * @returns {string} A non-numerical symbol used as part of a number for the given type,
596
+ * e.g. for locale de_DE:
597
+ * <ul>
598
+ * <li>"group": "." (grouping separator)</li>
599
+ * <li>"decimal": "," (decimal separator)</li>
600
+ * <li>"plusSign": "+" (plus sign)</li>
601
+ * <li>"minusSign": "-" (minus sign)</li>
602
+ * </ul>
603
+ * @public
604
+ * @since 1.120
605
+ */
606
+ getNumberSymbol(sType) {
607
+ assert(["group", "decimal", "plusSign", "minusSign"].includes(sType), "sType must be decimal, group, plusSign or minusSign");
608
+ return mSettings["symbols-latn-" + sType];
609
+ },
610
+ /**
611
+ * Defines the string to be used for the given number symbol.
612
+ *
613
+ * Calling this method with a null or undefined symbol removes a previously set symbol string.
614
+ * Note that an empty string is explicitly allowed.
615
+ *
616
+ * If a symbol is defined, it will be preferred over symbols derived from the current locale.
617
+ *
618
+ * See class {@link sap.ui.core.format.NumberFormat NumberFormat} for details about the symbols.
619
+ *
620
+ * After changing the number symbol, the framework tries to update localization
621
+ * specific parts of the UI. See the documentation of
622
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
623
+ * for details and restrictions.
624
+ *
625
+ * @param {"group"|"decimal"|"plusSign"|"minusSign"} sType the type of symbol
626
+ * @param {string} sSymbol will be used to represent the given symbol type
627
+ * @public
628
+ * @since 1.120
629
+ */
630
+ setNumberSymbol(sType, sSymbol) {
631
+ check(["group", "decimal", "plusSign", "minusSign"].includes(sType), "sType must be decimal, group, plusSign or minusSign");
632
+ _set("symbols-latn-" + sType, sSymbol);
633
+ },
634
+ /**
635
+ * Retrieves the custom currencies.
636
+ * E.g.
637
+ * <code>
638
+ * {
639
+ * "KWD": {"digits": 3},
640
+ * "TND" : {"digits": 3}
641
+ * }
642
+ * </code>
643
+ * @returns {object} the mapping between custom currencies and its digits
644
+ * @public
645
+ * @since 1.120
646
+ * @see {@link module:sap/base/i18n/Formatting.setCustomCurrencies Formatting.setCustomCurrencies}
647
+ * @see {@link module:sap/base/i18n/Formatting.addCustomCurrencies Formatting.addCustomCurrencies}
648
+ */
649
+ getCustomCurrencies() {
650
+ return mSettings["currency"];
651
+ },
652
+ /**
653
+ * Sets custom currencies and replaces existing entries.
654
+ *
655
+ * There is a special currency code named "DEFAULT" that is optional.
656
+ * In case it is set it will be used for all currencies not contained
657
+ * in the list, otherwise currency digits as defined by the CLDR will
658
+ * be used as a fallback.
659
+ *
660
+ * Example:
661
+ * To use CLDR, but override single currencies
662
+ * <code>
663
+ * {
664
+ * "KWD": {"digits": 3},
665
+ * "TND" : {"digits": 3}
666
+ * }
667
+ * </code>
668
+ *
669
+ * To replace the CLDR currency digits completely
670
+ * <code>
671
+ * {
672
+ * "DEFAULT": {"digits": 2},
673
+ * "ADP": {"digits": 0},
674
+ * ...
675
+ * "XPF": {"digits": 0}
676
+ * }
677
+ * </code>
678
+ *
679
+ * Note: To unset the custom currencies: call with <code>undefined</code>
680
+ * Custom currencies must not only consist of digits but contain at least one non-digit character, e.g. "a",
681
+ * so that the measure part can be distinguished from the number part.
682
+ * @public
683
+ * @since 1.120
684
+ * @param {object} mCurrencies currency map which is set
685
+ * @see {@link module:sap/base/i18n/Formatting.addCustomCurrencies Formatting.addCustomCurrencies}
686
+ */
687
+ setCustomCurrencies(mCurrencies) {
688
+ check(typeof mCurrencies === "object" || mCurrencies == null, "mCurrencyDigits must be an object");
689
+ Object.keys(mCurrencies || {}).forEach(function (sCurrencyDigit) {
690
+ check(typeof sCurrencyDigit === "string");
691
+ check(typeof mCurrencies[sCurrencyDigit] === "object");
692
+ });
693
+ _set("currency", mCurrencies);
694
+ },
695
+ /**
696
+ * Adds custom currencies to the existing entries.
697
+ * E.g.
698
+ * <code>
699
+ * {
700
+ * "KWD": {"digits": 3},
701
+ * "TND" : {"digits": 3}
702
+ * }
703
+ * </code>
704
+ *
705
+ * @public
706
+ * @since 1.120
707
+ * @param {object} mCurrencies adds to the currency map
708
+ * @see {@link module:sap/base/i18n/Formatting.setCustomCurrencies Formatting.setCustomCurrencies}
709
+ */
710
+ addCustomCurrencies(mCurrencies) {
711
+ // add custom units, or remove the existing ones if none are given
712
+ const mExistingCurrencies = Formatting.getCustomCurrencies();
713
+ if (mExistingCurrencies) {
714
+ mCurrencies = extend({}, mExistingCurrencies, mCurrencies);
715
+ }
716
+ Formatting.setCustomCurrencies(mCurrencies);
717
+ },
718
+ _setDayPeriods(sWidth, aTexts) {
719
+ assert(sWidth == "narrow" || sWidth == "abbreviated" || sWidth == "wide", "sWidth must be narrow, abbreviated or wide");
720
+ _set("dayPeriods-format-" + sWidth, aTexts);
721
+ },
722
+ /**
723
+ * Returns the currently set ABAP date format (its id) or undefined if none has been set.
724
+ *
725
+ * @returns {"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"|"A"|"B"|"C"|undefined} ID of the ABAP date format,
726
+ * if not set or set to <code>""</code>, <code>undefined</code> will be returned
727
+ * @public
728
+ * @since 1.120
729
+ */
730
+ getABAPDateFormat() {
731
+ const sABAPDateFormat = oWritableConfig.get({
732
+ name: "sapUiABAPDateFormat",
733
+ type: BaseConfig.Type.String,
734
+ /**
735
+ * @deprecated As of Version 1.120
736
+ */
737
+ defaultValue: oWritableConfig.get({
738
+ name: "sapUiLegacyDateFormat",
739
+ type: BaseConfig.Type.String,
740
+ external: true
741
+ }),
742
+ external: true
743
+ });
744
+ return sABAPDateFormat ? sABAPDateFormat.toUpperCase() : undefined;
745
+ },
746
+ /**
747
+ * Allows to specify one of the ABAP date formats.
748
+ *
749
+ * This method modifies the date patterns for 'short' and 'medium' style with the corresponding ABAP
750
+ * format. When called with a null or undefined format id, any previously applied format will be removed.
751
+ *
752
+ * After changing the date format, the framework tries to update localization
753
+ * specific parts of the UI. See the documentation of
754
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
755
+ * for details and restrictions.
756
+ *
757
+ * @param {""|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9"|"A"|"B"|"C"} [sFormatId=""] ID of the ABAP date format,
758
+ * <code>""</code> will reset the date patterns for 'short' and 'medium' style to the
759
+ * locale-specific ones.
760
+ * @public
761
+ * @since 1.120
762
+ */
763
+ setABAPDateFormat(sFormatId) {
764
+ sFormatId = sFormatId ? String(sFormatId).toUpperCase() : "";
765
+ check(M_ABAP_DATE_FORMAT_PATTERN.hasOwnProperty(sFormatId), "sFormatId must be one of ['1','2','3','4','5','6','7','8','9','A','B','C'] or empty");
766
+ const bFireEvent = !mChanges;
767
+ const sOldFormat = Formatting.getABAPDateFormat();
768
+ if (sOldFormat !== sFormatId) {
769
+ mChanges ??= {};
770
+ oWritableConfig.set("sapUiABAPDateFormat", sFormatId);
771
+ mChanges.ABAPDateFormat = sFormatId;
772
+ Formatting.setDatePattern("short", M_ABAP_DATE_FORMAT_PATTERN[sFormatId].pattern);
773
+ Formatting.setDatePattern("medium", M_ABAP_DATE_FORMAT_PATTERN[sFormatId].pattern);
774
+ if (bFireEvent) {
775
+ fireChange();
776
+ }
777
+ }
778
+ },
779
+ /**
780
+ * Returns the currently set ABAP time format (its id) or undefined if none has been set.
781
+ *
782
+ * @returns {"0"|"1"|"2"|"3"|"4"|undefined} ID of the ABAP date format,
783
+ * if not set or set to <code>""</code>, <code>undefined</code> will be returned
784
+ * @public
785
+ * @since 1.120
786
+ */
787
+ getABAPTimeFormat() {
788
+ const sABAPTimeFormat = oWritableConfig.get({
789
+ name: "sapUiABAPTimeFormat",
790
+ type: BaseConfig.Type.String,
791
+ /**
792
+ * @deprecated As of Version 1.120
793
+ */
794
+ defaultValue: oWritableConfig.get({
795
+ name: "sapUiLegacyTimeFormat",
796
+ type: BaseConfig.Type.String,
797
+ external: true
798
+ }),
799
+ external: true
800
+ });
801
+ return sABAPTimeFormat ? sABAPTimeFormat.toUpperCase() : undefined;
802
+ },
803
+ /**
804
+ * Allows to specify one of the ABAP time formats.
805
+ *
806
+ * This method sets the time patterns for 'short' and 'medium' style to the corresponding ABAP
807
+ * formats and sets the day period texts to "AM"/"PM" or "am"/"pm" respectively. When called
808
+ * with a null or undefined format id, any previously applied format will be removed.
809
+ *
810
+ * After changing the time format, the framework tries to update localization
811
+ * specific parts of the UI. See the documentation of
812
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
813
+ * for details and restrictions.
814
+ *
815
+ * @param {""|"0"|"1"|"2"|"3"|"4"} [sFormatId=""] ID of the ABAP time format,
816
+ * <code>""</code> will reset the time patterns for 'short' and 'medium' style and the day
817
+ * period texts to the locale-specific ones.
818
+ * @public
819
+ * @since 1.120
820
+ */
821
+ setABAPTimeFormat(sFormatId) {
822
+ sFormatId = sFormatId || "";
823
+ check(M_ABAP_TIME_FORMAT_PATTERN.hasOwnProperty(sFormatId), "sFormatId must be one of ['0','1','2','3','4'] or empty");
824
+ const bFireEvent = !mChanges;
825
+ const sOldFormat = Formatting.getABAPTimeFormat();
826
+ if (sOldFormat !== sFormatId) {
827
+ mChanges ??= {};
828
+ oWritableConfig.set("sapUiABAPTimeFormat", sFormatId);
829
+ mChanges.ABAPTimeFormat = sFormatId;
830
+ Formatting.setTimePattern("short", M_ABAP_TIME_FORMAT_PATTERN[sFormatId]["short"]);
831
+ Formatting.setTimePattern("medium", M_ABAP_TIME_FORMAT_PATTERN[sFormatId]["medium"]);
832
+ Formatting._setDayPeriods("abbreviated", M_ABAP_TIME_FORMAT_PATTERN[sFormatId].dayPeriods);
833
+ if (bFireEvent) {
834
+ fireChange();
835
+ }
836
+ }
837
+ },
838
+ /**
839
+ * Returns the currently set ABAP number format (its id) or undefined if none has been set.
840
+ *
841
+ * @returns {" "|"X"|"Y"|undefined} ID of the ABAP number format,
842
+ * if not set or set to <code>""</code>, <code>undefined</code> will be returned
843
+ * @public
844
+ * @since 1.120
845
+ */
846
+ getABAPNumberFormat() {
847
+ const sABAPNumberFormat = oWritableConfig.get({
848
+ name: "sapUiABAPNumberFormat",
849
+ type: BaseConfig.Type.String,
850
+ /**
851
+ * @deprecated As of Version 1.120
852
+ */
853
+ defaultValue: oWritableConfig.get({
854
+ name: "sapUiLegacyNumberFormat",
855
+ type: BaseConfig.Type.String,
856
+ external: true
857
+ }),
858
+ external: true
859
+ });
860
+ return sABAPNumberFormat ? sABAPNumberFormat.toUpperCase() : undefined;
861
+ },
862
+ /**
863
+ * Allows to specify one of the ABAP number format.
864
+ *
865
+ * This method will modify the 'group' and 'decimal' symbols. When called with a null
866
+ * or undefined format id, any previously applied format will be removed.
867
+ *
868
+ * After changing the number format, the framework tries to update localization
869
+ * specific parts of the UI. See the documentation of
870
+ * {@link module:sap/base/i18n/Localization.setLanguage Localization.setLanguage()}
871
+ * for details and restrictions.
872
+ *
873
+ * @param {""|" "|"X"|"Y"} [sFormatId=""] ID of the ABAP number format set,
874
+ * <code>""</code> will reset the 'group' and 'decimal' symbols to the locale-specific
875
+ * ones.
876
+ * @public
877
+ * @since 1.120
878
+ */
879
+ setABAPNumberFormat(sFormatId) {
880
+ sFormatId = sFormatId ? sFormatId.toUpperCase() : "";
881
+ check(M_ABAP_NUMBER_FORMAT_SYMBOLS.hasOwnProperty(sFormatId), "sFormatId must be one of [' ','X','Y'] or empty");
882
+ const bFireEvent = !mChanges;
883
+ const sOldFormat = Formatting.getABAPNumberFormat();
884
+ if (sOldFormat !== sFormatId) {
885
+ mChanges ??= {};
886
+ oWritableConfig.set("sapUiABAPNumberFormat", sFormatId);
887
+ mChanges.ABAPNumberFormat = sFormatId;
888
+ Formatting.setNumberSymbol("group", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].groupingSeparator);
889
+ Formatting.setNumberSymbol("decimal", M_ABAP_NUMBER_FORMAT_SYMBOLS[sFormatId].decimalSeparator);
890
+ if (bFireEvent) {
891
+ fireChange();
892
+ }
893
+ }
894
+ },
895
+ /**
896
+ *
897
+ * Customizing data for the support of Islamic calendar.
898
+ * Represents one row of data from Table TISLCAL.
899
+ *
900
+ * @typedef {object} module:sap/base/i18n/Formatting.CustomIslamicCalendarData
901
+ *
902
+ * @property {"A"|"B"} dateFormat The date format. Column DATFM in TISLCAL.
903
+ * @property {string} islamicMonthStart The Islamic date in format: 'yyyyMMdd'. Column ISLMONTHSTART in TISLCAL.
904
+ * @property {string} gregDate The corresponding Gregorian date format: 'yyyyMMdd'. Column GREGDATE in TISLCAL.
905
+ *
906
+ * @public
907
+ */
908
+
909
+ /**
910
+ * Allows to specify the customizing data for Islamic calendar support
911
+ *
912
+ * See: {@link module:sap/base/i18n/Formatting.CustomIslamicCalendarData}
913
+ *
914
+ * @param {module:sap/base/i18n/Formatting.CustomIslamicCalendarData[]} aCustomCalendarData Contains the customizing data for the support of Islamic calendar.
915
+ * One JSON object in the array represents one row of data from Table TISLCAL
916
+ * @public
917
+ * @since 1.120
918
+ */
919
+ setCustomIslamicCalendarData(aCustomCalendarData) {
920
+ check(Array.isArray(aCustomCalendarData), "aCustomCalendarData must be an Array");
921
+ const bFireEvent = !mChanges;
922
+ mChanges ??= {};
923
+ aCustomIslamicCalendarData = mChanges.customIslamicCalendarData = aCustomCalendarData.slice();
924
+ if (bFireEvent) {
925
+ fireChange();
926
+ }
927
+ },
928
+ /**
929
+ * Returns the currently set customizing data for Islamic calendar support.
930
+ *
931
+ * See: {@link module:sap/base/i18n/Formatting.CustomIslamicCalendarData}
932
+ *
933
+ * @returns {module:sap/base/i18n/Formatting.CustomIslamicCalendarData[]|undefined} Returns an array that contains the customizing data. Each element in the array has properties: dateFormat, islamicMonthStart, gregDate. For details, please see {@link #.setCustomIslamicCalendarData}
934
+ * @public
935
+ * @since 1.120
936
+ */
937
+ getCustomIslamicCalendarData() {
938
+ return aCustomIslamicCalendarData?.slice() ?? undefined;
939
+ },
940
+ /**
941
+ * Define whether the NumberFormatter shall always place the currency code after the numeric value, with
942
+ * the only exception of right-to-left locales, where the currency code shall be placed before the numeric value.
943
+ * Default configuration setting is <code>true</code>.
944
+ *
945
+ * When set to <code>false</code> the placement of the currency code is done dynamically, depending on the
946
+ * configured locale using data provided by the Unicode Common Locale Data Repository (CLDR).
947
+ *
948
+ * Each currency instance ({@link sap.ui.core.format.NumberFormat.getCurrencyInstance
949
+ * NumberFormat.getCurrencyInstance}) will be created with this setting unless overwritten on instance level.
950
+ *
951
+ * @param {boolean} bTrailingCurrencyCode Whether currency codes shall always be placed after the numeric value
952
+ * @public
953
+ * @since 1.120
954
+ */
955
+ setTrailingCurrencyCode(bTrailingCurrencyCode) {
956
+ check(typeof bTrailingCurrencyCode === "boolean", "bTrailingCurrencyCode must be a boolean");
957
+ oWritableConfig.set("sapUiTrailingCurrencyCode", bTrailingCurrencyCode);
958
+ },
959
+ /**
960
+ * Returns current trailingCurrencyCode configuration for new NumberFormatter instances
961
+ *
962
+ * @return {boolean} Whether currency codes shall always be placed after the numeric value
963
+ * @public
964
+ * @since 1.120
965
+ */
966
+ getTrailingCurrencyCode() {
967
+ return oWritableConfig.get({
968
+ name: "sapUiTrailingCurrencyCode",
969
+ type: BaseConfig.Type.Boolean,
970
+ defaultValue: true,
971
+ external: true
972
+ });
973
+ },
974
+ /**
975
+ * Returns a live object with the current settings
976
+ * TODO this method is part of the facade to be accessible from LocaleData, but it shouldn't be
977
+ *
978
+ * @returns {mSettings} The custom LocaleData settings object
979
+ * @private
980
+ * @ui5-restricted sap.ui.core
981
+ * @since 1.116.0
982
+ */
983
+ getCustomLocaleData() {
984
+ return mSettings;
985
+ },
986
+ /**
987
+ * Returns the calendar week numbering algorithm used to determine the first day of the week
988
+ * and the first calendar week of the year, see {@link module:sap/base/i18n/date/CalendarWeekNumbering
989
+ * CalendarWeekNumbering}.
990
+ *
991
+ * @returns {module:sap/base/i18n/date/CalendarWeekNumbering} The calendar week numbering algorithm
992
+ *
993
+ * @public
994
+ * @since 1.120
995
+ */
996
+ getCalendarWeekNumbering() {
997
+ let oCalendarWeekNumbering = CalendarWeekNumbering.Default;
998
+ try {
999
+ oCalendarWeekNumbering = oWritableConfig.get({
1000
+ name: "sapUiCalendarWeekNumbering",
1001
+ type: CalendarWeekNumbering,
1002
+ defaultValue: CalendarWeekNumbering.Default,
1003
+ external: true
1004
+ });
1005
+ } catch (err) {
1006
+ //nothing to do, return default;
1007
+ }
1008
+ return oCalendarWeekNumbering;
1009
+ },
1010
+ /**
1011
+ * Sets the calendar week numbering algorithm which is used to determine the first day of the week
1012
+ * and the first calendar week of the year, see {@link module:sap/base/i18n/date/CalendarWeekNumbering
1013
+ * CalendarWeekNumbering}.
1014
+ *
1015
+ * @param {module:sap/base/i18n/date/CalendarWeekNumbering} sCalendarWeekNumbering
1016
+ * The calendar week numbering algorithm
1017
+ * @throws {TypeError}
1018
+ * If <code>sCalendarWeekNumbering</code> is not a valid calendar week numbering algorithm,
1019
+ * defined in {@link module:sap/base/i18n/date/CalendarWeekNumbering CalendarWeekNumbering}
1020
+ *
1021
+ * @public
1022
+ * @since 1.120
1023
+ */
1024
+ setCalendarWeekNumbering(sCalendarWeekNumbering) {
1025
+ BaseConfig._.checkEnum(CalendarWeekNumbering, sCalendarWeekNumbering, "calendarWeekNumbering");
1026
+ const sCurrentWeekNumbering = oWritableConfig.get({
1027
+ name: "sapUiCalendarWeekNumbering",
1028
+ type: CalendarWeekNumbering,
1029
+ defaultValue: CalendarWeekNumbering.Default,
1030
+ external: true
1031
+ });
1032
+ if (sCurrentWeekNumbering !== sCalendarWeekNumbering) {
1033
+ const bFireEvent = !mChanges;
1034
+ mChanges ??= {};
1035
+ oWritableConfig.set("sapUiCalendarWeekNumbering", sCalendarWeekNumbering);
1036
+ mChanges.calendarWeekNumbering = sCalendarWeekNumbering;
1037
+ if (bFireEvent) {
1038
+ fireChange();
1039
+ }
1040
+ }
1041
+ },
1042
+ /**
1043
+ * Returns the calendar type which is being used in locale dependent functionality.
1044
+ *
1045
+ * When it's explicitly set by calling <code>setCalendarType</code>, the set calendar type is returned.
1046
+ * Otherwise, the calendar type is determined by checking the format settings and current locale.
1047
+ *
1048
+ * @returns {module:sap/base/i18n/date/CalendarType} the current calendar type, e.g. <code>Gregorian</code>
1049
+ * @public
1050
+ * @since 1.120
1051
+ */
1052
+ getCalendarType() {
1053
+ let sName,
1054
+ sCalendarType = oWritableConfig.get({
1055
+ name: "sapUiCalendarType",
1056
+ type: BaseConfig.Type.String,
1057
+ external: true
1058
+ });
1059
+ sCalendarType ??= null;
1060
+ if (sCalendarType) {
1061
+ for (sName in CalendarType) {
1062
+ if (sName.toLowerCase() === sCalendarType.toLowerCase()) {
1063
+ return sName;
1064
+ }
1065
+ }
1066
+ Log.warning("Parameter 'calendarType' is set to " + sCalendarType + " which isn't a valid value and therefore ignored. The calendar type is determined from format setting and current locale");
1067
+ }
1068
+ const sABAPDateFormat = Formatting.getABAPDateFormat();
1069
+ switch (sABAPDateFormat) {
1070
+ case "1":
1071
+ case "2":
1072
+ case "3":
1073
+ case "4":
1074
+ case "5":
1075
+ case "6":
1076
+ return CalendarType.Gregorian;
1077
+ case "7":
1078
+ case "8":
1079
+ case "9":
1080
+ return CalendarType.Japanese;
1081
+ case "A":
1082
+ case "B":
1083
+ return CalendarType.Islamic;
1084
+ case "C":
1085
+ return CalendarType.Persian;
1086
+ default:
1087
+ return Localization.getPreferredCalendarType();
1088
+ }
1089
+ },
1090
+ /**
1091
+ * Sets the new calendar type to be used from now on in locale dependent functionality (for example,
1092
+ * formatting, translation texts, etc.).
1093
+ *
1094
+ * @param {module:sap/base/i18n/date/CalendarType|null} sCalendarType the new calendar type. Set it with null to clear the calendar type
1095
+ * and the calendar type is calculated based on the format settings and current locale.
1096
+ * @public
1097
+ * @since 1.120
1098
+ */
1099
+ setCalendarType(sCalendarType) {
1100
+ const sOldCalendarType = Formatting.getCalendarType();
1101
+ oWritableConfig.set("sapUiCalendarType", sCalendarType);
1102
+ const sCurrentCalendarType = Formatting.getCalendarType();
1103
+ if (sOldCalendarType !== sCurrentCalendarType) {
1104
+ const bFireEvent = !mChanges;
1105
+ mChanges ??= {};
1106
+ mChanges.calendarType = sCurrentCalendarType;
1107
+ if (bFireEvent) {
1108
+ fireChange();
1109
+ }
1110
+ }
1111
+ }
1112
+ };
1113
+ function fireChange() {
1114
+ oEventing.fireEvent("change", mChanges);
1115
+ mChanges = undefined;
1116
+ }
1117
+ function init() {
1118
+ // init ABAP formats
1119
+ const sABAPDateFormat = Formatting.getABAPDateFormat();
1120
+ if (sABAPDateFormat !== undefined) {
1121
+ Formatting.setABAPDateFormat(sABAPDateFormat);
1122
+ }
1123
+ const sABAPNumberFormat = Formatting.getABAPNumberFormat();
1124
+ if (sABAPNumberFormat !== undefined) {
1125
+ Formatting.setABAPNumberFormat(sABAPNumberFormat);
1126
+ }
1127
+ const sABAPTimeFormat = Formatting.getABAPTimeFormat();
1128
+ if (sABAPTimeFormat !== undefined) {
1129
+ Formatting.setABAPTimeFormat(sABAPTimeFormat);
1130
+ }
1131
+ }
1132
+ init();
1133
+ export default Formatting;