@ui5/webcomponents-localization 1.22.0-rc.0 → 1.22.0-rc.2

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 (128) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/generated/assets/cldr/ar.json +102 -62
  4. package/dist/generated/assets/cldr/ar_EG.json +102 -62
  5. package/dist/generated/assets/cldr/ar_SA.json +102 -62
  6. package/dist/generated/assets/cldr/bg.json +364 -325
  7. package/dist/generated/assets/cldr/ca.json +491 -453
  8. package/dist/generated/assets/cldr/cs.json +431 -324
  9. package/dist/generated/assets/cldr/cy.json +608 -340
  10. package/dist/generated/assets/cldr/da.json +290 -227
  11. package/dist/generated/assets/cldr/de.json +348 -241
  12. package/dist/generated/assets/cldr/de_AT.json +348 -241
  13. package/dist/generated/assets/cldr/de_CH.json +347 -240
  14. package/dist/generated/assets/cldr/el.json +128 -100
  15. package/dist/generated/assets/cldr/el_CY.json +128 -100
  16. package/dist/generated/assets/cldr/en.json +538 -512
  17. package/dist/generated/assets/cldr/en_AU.json +583 -520
  18. package/dist/generated/assets/cldr/en_GB.json +485 -441
  19. package/dist/generated/assets/cldr/en_HK.json +519 -474
  20. package/dist/generated/assets/cldr/en_IE.json +485 -440
  21. package/dist/generated/assets/cldr/en_IN.json +465 -420
  22. package/dist/generated/assets/cldr/en_NZ.json +505 -460
  23. package/dist/generated/assets/cldr/en_PG.json +505 -460
  24. package/dist/generated/assets/cldr/en_SG.json +505 -460
  25. package/dist/generated/assets/cldr/en_ZA.json +485 -440
  26. package/dist/generated/assets/cldr/es.json +709 -456
  27. package/dist/generated/assets/cldr/es_AR.json +687 -434
  28. package/dist/generated/assets/cldr/es_BO.json +721 -468
  29. package/dist/generated/assets/cldr/es_CL.json +567 -422
  30. package/dist/generated/assets/cldr/es_CO.json +485 -339
  31. package/dist/generated/assets/cldr/es_MX.json +734 -481
  32. package/dist/generated/assets/cldr/es_PE.json +409 -372
  33. package/dist/generated/assets/cldr/es_UY.json +433 -396
  34. package/dist/generated/assets/cldr/es_VE.json +453 -416
  35. package/dist/generated/assets/cldr/et.json +340 -307
  36. package/dist/generated/assets/cldr/fa.json +96 -34
  37. package/dist/generated/assets/cldr/fi.json +359 -308
  38. package/dist/generated/assets/cldr/fr.json +347 -321
  39. package/dist/generated/assets/cldr/fr_BE.json +347 -321
  40. package/dist/generated/assets/cldr/fr_CA.json +458 -432
  41. package/dist/generated/assets/cldr/fr_CH.json +290 -264
  42. package/dist/generated/assets/cldr/fr_LU.json +347 -321
  43. package/dist/generated/assets/cldr/he.json +241 -130
  44. package/dist/generated/assets/cldr/hi.json +103 -53
  45. package/dist/generated/assets/cldr/hr.json +467 -410
  46. package/dist/generated/assets/cldr/hu.json +246 -195
  47. package/dist/generated/assets/cldr/id.json +478 -406
  48. package/dist/generated/assets/cldr/it.json +418 -362
  49. package/dist/generated/assets/cldr/it_CH.json +418 -362
  50. package/dist/generated/assets/cldr/ja.json +58 -18
  51. package/dist/generated/assets/cldr/kk.json +562 -398
  52. package/dist/generated/assets/cldr/ko.json +36 -15
  53. package/dist/generated/assets/cldr/lt.json +320 -231
  54. package/dist/generated/assets/cldr/lv.json +184 -120
  55. package/dist/generated/assets/cldr/ms.json +460 -388
  56. package/dist/generated/assets/cldr/nb.json +160 -92
  57. package/dist/generated/assets/cldr/nl.json +621 -373
  58. package/dist/generated/assets/cldr/nl_BE.json +621 -373
  59. package/dist/generated/assets/cldr/pl.json +590 -279
  60. package/dist/generated/assets/cldr/pt.json +696 -334
  61. package/dist/generated/assets/cldr/pt_PT.json +730 -454
  62. package/dist/generated/assets/cldr/ro.json +409 -339
  63. package/dist/generated/assets/cldr/ru.json +317 -279
  64. package/dist/generated/assets/cldr/ru_UA.json +312 -274
  65. package/dist/generated/assets/cldr/sk.json +454 -413
  66. package/dist/generated/assets/cldr/sl.json +118 -80
  67. package/dist/generated/assets/cldr/sr.json +294 -142
  68. package/dist/generated/assets/cldr/sr_Latn.json +972 -824
  69. package/dist/generated/assets/cldr/sv.json +382 -338
  70. package/dist/generated/assets/cldr/th.json +56 -36
  71. package/dist/generated/assets/cldr/tr.json +371 -320
  72. package/dist/generated/assets/cldr/uk.json +340 -290
  73. package/dist/generated/assets/cldr/vi.json +352 -328
  74. package/dist/generated/assets/cldr/zh_CN.json +34 -10
  75. package/dist/generated/assets/cldr/zh_HK.json +33 -9
  76. package/dist/generated/assets/cldr/zh_SG.json +33 -9
  77. package/dist/generated/assets/cldr/zh_TW.json +32 -8
  78. package/dist/sap/base/Event.js +59 -0
  79. package/dist/sap/base/Eventing.js +146 -0
  80. package/dist/sap/base/Log.js +2 -239
  81. package/dist/sap/base/assert.js +28 -1
  82. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  83. package/dist/sap/base/config.js +17 -0
  84. package/dist/sap/base/i18n/Formatting.js +1130 -0
  85. package/dist/sap/base/i18n/LanguageTag.js +168 -30
  86. package/dist/sap/base/i18n/date/CalendarType.js +36 -1
  87. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +76 -1
  88. package/dist/sap/base/i18n/date/TimezoneUtils.js +242 -12
  89. package/dist/sap/base/strings/camelize.js +30 -0
  90. package/dist/sap/base/strings/formatMessage.js +88 -15
  91. package/dist/sap/base/util/ObjectPath.js +95 -3
  92. package/dist/sap/base/util/Version.js +157 -0
  93. package/dist/sap/base/util/_merge.js +83 -26
  94. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  95. package/dist/sap/base/util/deepClone.js +102 -0
  96. package/dist/sap/base/util/deepEqual.js +75 -51
  97. package/dist/sap/base/util/extend.js +58 -7
  98. package/dist/sap/base/util/isEmptyObject.js +34 -0
  99. package/dist/sap/base/util/isPlainObject.js +35 -1
  100. package/dist/sap/base/util/now.js +24 -3
  101. package/dist/sap/base/util/resolveReference.js +157 -0
  102. package/dist/sap/base/util/uid.js +27 -0
  103. package/dist/sap/ui/base/DataType.js +657 -0
  104. package/dist/sap/ui/base/Interface.js +47 -1
  105. package/dist/sap/ui/base/Metadata.js +433 -180
  106. package/dist/sap/ui/base/Object.js +284 -48
  107. package/dist/sap/ui/core/CalendarType.js +23 -1
  108. package/dist/sap/ui/core/Locale.js +189 -57
  109. package/dist/sap/ui/core/LocaleData.js +2670 -1380
  110. package/dist/sap/ui/core/Supportability.js +5 -0
  111. package/dist/sap/ui/core/Theming.js +539 -0
  112. package/dist/sap/ui/core/date/Buddhist.js +162 -87
  113. package/dist/sap/ui/core/date/CalendarUtils.js +61 -21
  114. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +29 -1
  115. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  116. package/dist/sap/ui/core/date/Islamic.js +298 -185
  117. package/dist/sap/ui/core/date/Japanese.js +210 -115
  118. package/dist/sap/ui/core/date/Persian.js +324 -195
  119. package/dist/sap/ui/core/date/UI5Date.js +923 -237
  120. package/dist/sap/ui/core/date/UniversalDate.js +1238 -245
  121. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  122. package/dist/sap/ui/core/format/DateFormat.js +3163 -2145
  123. package/dist/sap/ui/core/format/TimezoneUtil.js +23 -1
  124. package/package-scripts.cjs +4 -10
  125. package/package.json +9 -5
  126. package/tsconfig.json +2 -1
  127. package/used-modules.txt +20 -1
  128. package/dist/sap/ui/Device.js +0 -5
@@ -1,64 +1,300 @@
1
- import Metadata from './Metadata.js';
2
- import Log from '../../base/Log.js';
3
- var BaseObject = Metadata.createClass('sap.ui.base.Object', {
4
- constructor: function () {
5
- if (!(this instanceof BaseObject)) {
6
- throw Error('Cannot instantiate object: "new" is missing!');
7
- }
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
+ /**
7
+ * SAPUI5 base classes
8
+ *
9
+ * @namespace
10
+ * @name sap.ui.base
11
+ * @public
12
+ */
13
+ // Provides class sap.ui.base.Object
14
+ import Metadata from "./Metadata.js";
15
+ import Log from "../../base/Log.js";
16
+ /**
17
+ * Constructor for an <code>sap.ui.base.Object</code>.
18
+ *
19
+ * Subclasses of this class should always call the constructor of their base class.
20
+ *
21
+ * @class Base class for all SAPUI5 Objects.
22
+ * @abstract
23
+ * @author Malte Wedel
24
+ * @version 1.120.3
25
+ * @public
26
+ * @alias sap.ui.base.Object
27
+ * @throws {Error} When an instance of the class or its subclasses is created without the <code>new</code> operator.
28
+ */
29
+ var BaseObject = Metadata.createClass("sap.ui.base.Object", {
30
+ constructor: function () {
31
+ // complain if 'this' is not an instance of a subclass
32
+ if (!(this instanceof BaseObject)) {
33
+ throw Error("Cannot instantiate object: \"new\" is missing!");
8
34
  }
35
+ }
9
36
  });
10
- BaseObject.prototype.destroy = function () {
11
- };
37
+
38
+ /**
39
+ * Destructor method for objects.
40
+ * @public
41
+ */
42
+ BaseObject.prototype.destroy = function () {};
43
+
44
+ /**
45
+ * Returns the public facade of this object.
46
+ *
47
+ * By default, the public facade is implemented as an instance of {@link sap.ui.base.Interface},
48
+ * exposing the <code>publicMethods</code> as defined in the metadata of the class of this object.
49
+ *
50
+ * See the documentation of the {@link #.extend extend} method for an explanation of <code>publicMethods</code>.
51
+ *
52
+ * The facade is created on the first call of <code>getInterface</code> and reused for all later calls.
53
+ *
54
+ * @public
55
+ * @returns {sap.ui.base.Object} A facade for this object, with at least the public methods of the class of this.
56
+ */
12
57
  BaseObject.prototype.getInterface = function () {
13
- var oInterface = new BaseObject._Interface(this, this.getMetadata().getAllPublicMethods());
14
- this.getInterface = function () {
15
- return oInterface;
16
- };
58
+ // New implementation that avoids the overhead of a dedicated member for the interface
59
+ // initially, an Object instance has no associated Interface and the getInterface
60
+ // method is defined only in the prototype. So the code here will be executed.
61
+ // It creates an interface (basically the same code as in the old implementation)
62
+ var oInterface = new BaseObject._Interface(this, this.getMetadata().getAllPublicMethods());
63
+ // Now this Object instance gets a new, private implementation of getInterface
64
+ // that returns the newly created oInterface. Future calls of getInterface on the
65
+ // same Object therefore will return the already created interface
66
+ this.getInterface = function () {
17
67
  return oInterface;
68
+ };
69
+ // as the first caller doesn't benefit from the new method implementation we have to
70
+ // return the created interface as well.
71
+ return oInterface;
18
72
  };
73
+
74
+ /**
75
+ * Returns the metadata for the class that this object belongs to.
76
+ *
77
+ * This method is only defined when metadata has been declared by using {@link sap.ui.base.Object.defineClass}
78
+ * or {@link sap.ui.base.Object.extend}.
79
+ *
80
+ * @return {sap.ui.base.Metadata} metadata for the class of the object
81
+ * @name sap.ui.base.Object#getMetadata
82
+ * @function
83
+ * @public
84
+ */
85
+
86
+ /**
87
+ * The structure of the "metadata" object which is passed when inheriting from sap.ui.base.Object using its static "extend" method.
88
+ * See {@link sap.ui.base.Object.extend} for details on its usage.
89
+ *
90
+ * @typedef {object} sap.ui.base.Object.MetadataOptions
91
+ *
92
+ * @property {string[]} [interfaces] set of names of implemented interfaces (defaults to no interfaces)
93
+ * @property {boolean} [abstract=false] flag that marks the class as abstract (purely informational, defaults to false)
94
+ * @property {boolean} [final=false] flag that marks the class as final (defaults to false)
95
+ * @property {boolean} [deprecated=false] flag that marks the class as deprecated (defaults to false). May lead to an additional warning
96
+ * log message at runtime when the object is still used. For the documentation, also add a <code>@deprecated</code> tag in the JSDoc,
97
+ * describing since when it is deprecated and what any alternatives are.
98
+ *
99
+ * @public
100
+ */
101
+
102
+ /**
103
+ * Creates a subclass of class sap.ui.base.Object with name <code>sClassName</code>
104
+ * and enriches it with the information contained in <code>oClassInfo</code>.
105
+ *
106
+ * <code>oClassInfo</code> might contain three kinds of information:
107
+ * <ul>
108
+ * <li><code>metadata:</code> an (optional) object literal with metadata about the class like implemented interfaces,
109
+ * see {@link sap.ui.base.Object.MetadataOptions MetadataOptions} for details.
110
+ * The information in the object literal will be wrapped by an instance of {@link sap.ui.base.Metadata Metadata}.
111
+ * Subclasses of sap.ui.base.Object can enrich the set of supported metadata (e.g. see {@link sap.ui.core.Element.extend}).
112
+ * </li>
113
+ *
114
+ * <li><code>constructor:</code> a function that serves as a constructor function for the new class.
115
+ * If no constructor function is given, the framework creates a default implementation that delegates all
116
+ * its arguments to the constructor function of the base class.
117
+ * </li>
118
+ *
119
+ * <li><i>any-other-name:</i> any other property in the <code>oClassInfo</code> is copied into the prototype
120
+ * object of the newly created class. Callers can thereby add methods or properties to all instances of the
121
+ * class. But be aware that the given values are shared between all instances of the class. Usually, it doesn't
122
+ * make sense to use primitive values here other than to declare public constants.
123
+ *
124
+ * If such a property has a function as its value, and if the property name does not start with an underscore
125
+ * or with the prefix "on", the property name will be automatically added to the list of public methods of the
126
+ * class (see property <code>publicMethods</code> in the <code>metadata</code> section). If a method's name
127
+ * matches that pattern, but is not meant to be public, it shouldn't be included in the class info object,
128
+ * but be assigned to the prototype instead.
129
+ * </li>
130
+ *
131
+ * </ul>
132
+ *
133
+ * The prototype object of the newly created class uses the same prototype as instances of the base class
134
+ * (prototype chaining).
135
+ *
136
+ * A metadata object is always created, even if there is no <code>metadata</code> entry in the <code>oClassInfo</code>
137
+ * object. A getter for the metadata is always attached to the prototype and to the class (constructor function)
138
+ * itself.
139
+ *
140
+ * Last but not least, with the third argument <code>FNMetaImpl</code> the constructor of a metadata class
141
+ * can be specified. Instances of that class will be used to represent metadata for the newly created class
142
+ * and for any subclass created from it. Typically, only frameworks will use this parameter to enrich the
143
+ * metadata for a new class hierarchy they introduce (e.g. {@link sap.ui.core.Element.extend Element}).
144
+ *
145
+ * @param {string} sClassName name of the class to be created
146
+ * @param {object} [oClassInfo] structured object with information about the class
147
+ * @param {function} [FNMetaImpl] constructor function for the metadata object. If not given, it defaults to sap.ui.base.Metadata.
148
+ * @return {function} the created class / constructor function
149
+ * @public
150
+ * @static
151
+ * @name sap.ui.base.Object.extend
152
+ * @function
153
+ * @since 1.3.1
154
+ */
155
+
156
+ /**
157
+ * Creates metadata for a given class and attaches it to the constructor and prototype of that class.
158
+ *
159
+ * After creation, metadata can be retrieved with getMetadata().
160
+ *
161
+ * The static info can at least contain the following entries:
162
+ * <ul>
163
+ * <li>baseType: {string} fully qualified name of a base class or empty</li>
164
+ * <li>publicMethods: {string} an array of method names that will be visible in the interface proxy returned by {@link #getInterface}</li>
165
+ * </ul>
166
+ *
167
+ * @param {string} sClassName name of an (already declared) constructor function
168
+ * @param {object} oStaticInfo static info used to create the metadata object
169
+ * @param {string} oStaticInfo.baseType qualified name of a base class
170
+ * @param {string[]} oStaticInfo.publicMethods array of names of public methods
171
+ * @param {function} [FNMetaImpl] constructor function for the metadata object. If not given, it defaults to sap.ui.base.Metadata.
172
+ *
173
+ * @return {sap.ui.base.Metadata} the created metadata object
174
+ * @public
175
+ * @static
176
+ * @deprecated Since 1.3.1. Use the static <code>extend</code> method of the desired base class (e.g. {@link sap.ui.base.Object.extend})
177
+ */
19
178
  BaseObject.defineClass = function (sClassName, oStaticInfo, FNMetaImpl) {
20
- var oMetadata = new (FNMetaImpl || Metadata)(sClassName, oStaticInfo);
21
- var fnClass = oMetadata.getClass();
22
- fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
23
- return oMetadata;
24
- };
25
- if (!oMetadata.isFinal()) {
26
- fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
27
- return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
28
- };
29
- }
30
- Log.debug('defined class \'' + sClassName + '\'' + (oMetadata.getParent() ? ' as subclass of ' + oMetadata.getParent().getName() : ''));
179
+ // create Metadata object
180
+ var oMetadata = new (FNMetaImpl || Metadata)(sClassName, oStaticInfo);
181
+ var fnClass = oMetadata.getClass();
182
+ fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
31
183
  return oMetadata;
184
+ };
185
+ // enrich function
186
+ if (!oMetadata.isFinal()) {
187
+ fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
188
+ return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
189
+ };
190
+ }
191
+ Log.debug("defined class '" + sClassName + "'" + (oMetadata.getParent() ? " as subclass of " + oMetadata.getParent().getName() : ""));
192
+ return oMetadata;
32
193
  };
194
+
195
+ /**
196
+ * Checks whether this object is an instance of the named type.
197
+ *
198
+ * This check is solely based on the type names as declared in the class metadata.
199
+ * It compares the given <code>vTypeName</code> with the name of the class of this object,
200
+ * with the names of any base class of that class and with the names of all interfaces
201
+ * implemented by any of the aforementioned classes.
202
+ *
203
+ * Instead of a single type name, an array of type names can be given and the method
204
+ * will check if this object is an instance of any of the listed types (logical or).
205
+ *
206
+ * Should the UI5 class system in future implement additional means of associating classes
207
+ * with type names (e.g. by introducing mixins), then this method might detect matches
208
+ * for those names as well.
209
+ *
210
+ * @example
211
+ * myObject.isA("sap.ui.core.Control"); // true if myObject is an instance of sap.ui.core.Control
212
+ * myObject.isA(["sap.ui.core.Control", "sap.ui.core.Fragment"]); // true if myObject is an instance of sap.ui.core.Control or sap.ui.core.Fragment
213
+ *
214
+ * @param {string|string[]} vTypeName Type or types to check for
215
+ * @returns {boolean} Whether this object is an instance of the given type or of any of the given types
216
+ * @public
217
+ * @since 1.56
218
+ */
33
219
  BaseObject.prototype.isA = function (vTypeName) {
34
- return this.getMetadata().isA(vTypeName);
220
+ return this.getMetadata().isA(vTypeName);
35
221
  };
222
+
223
+ /**
224
+ * Checks whether the given object is an instance of the named type.
225
+ * This function is a short-hand convenience for {@link sap.ui.base.Object#isA}.
226
+ *
227
+ * Please see the API documentation of {@link sap.ui.base.Object#isA} for more details.
228
+ *
229
+ * @param {any} oObject Object which will be checked whether it is an instance of the given type
230
+ * @param {string|string[]} vTypeName Type or types to check for
231
+ * @returns {boolean} Whether the given object is an instance of the given type or of any of the given types
232
+ * @public
233
+ * @since 1.56
234
+ * @static
235
+ * @deprecated Since 1.120, please use {@link sap.ui.base.Object.isObjectA}.
236
+ */
36
237
  BaseObject.isA = function (oObject, vTypeName) {
37
- return oObject instanceof BaseObject && oObject.isA(vTypeName);
238
+ return oObject instanceof BaseObject && oObject.isA(vTypeName);
38
239
  };
240
+
241
+ /**
242
+ * Checks whether the given object is an instance of the named type.
243
+ * This function is a short-hand convenience for {@link sap.ui.base.Object#isA}.
244
+ *
245
+ * Please see the API documentation of {@link sap.ui.base.Object#isA} for more details.
246
+ *
247
+ * @param {any} oObject Object which will be checked whether it is an instance of the given type
248
+ * @param {string|string[]} vTypeName Type or types to check for
249
+ * @returns {boolean} Whether the given object is an instance of the given type or of any of the given types
250
+ * @public
251
+ * @since 1.120
252
+ * @static
253
+ */
254
+ BaseObject.isObjectA = function (oObject, vTypeName) {
255
+ return oObject instanceof BaseObject && oObject.isA(vTypeName);
256
+ };
257
+
258
+ /**
259
+ * @param {sap.ui.base.Object} [oObject] Object for which a facade should be created
260
+ * @param {string[]} [aMethods=[]] Names of the methods, that should be available in the new facade
261
+ * @param {boolean} [_bReturnFacade=false] If true, the return value of a function call is this created Interface instance instead of the BaseObject interface
262
+ * @private
263
+ * @static
264
+ */
39
265
  BaseObject._Interface = function (oObject, aMethods, _bReturnFacade) {
40
- if (!oObject) {
41
- return oObject;
42
- }
43
- function fCreateDelegator(oObject, sMethodName) {
44
- return function () {
45
- var tmp = oObject[sMethodName].apply(oObject, arguments);
46
- if (_bReturnFacade) {
47
- return this;
48
- } else {
49
- return tmp instanceof BaseObject ? tmp.getInterface() : tmp;
50
- }
51
- };
52
- }
53
- if (!aMethods) {
54
- return {};
55
- }
56
- var sMethodName;
57
- for (var i = 0, ml = aMethods.length; i < ml; i++) {
58
- sMethodName = aMethods[i];
59
- if (!oObject[sMethodName] || typeof oObject[sMethodName] === 'function') {
60
- this[sMethodName] = fCreateDelegator(oObject, sMethodName);
61
- }
266
+ // if object is null or undefined, return itself
267
+ if (!oObject) {
268
+ return oObject;
269
+ }
270
+ function fCreateDelegator(oObject, sMethodName) {
271
+ return function () {
272
+ // return oObject[sMethodName].apply(oObject, arguments);
273
+ var tmp = oObject[sMethodName].apply(oObject, arguments);
274
+ // to avoid to hide the implementation behind the interface you need
275
+ // to override the getInterface function in the object or create the interface with bFacade = true
276
+ if (_bReturnFacade) {
277
+ return this;
278
+ } else {
279
+ return tmp instanceof BaseObject ? tmp.getInterface() : tmp;
280
+ }
281
+ };
282
+ }
283
+
284
+ // if there are no methods return
285
+ if (!aMethods) {
286
+ return {};
287
+ }
288
+ var sMethodName;
289
+
290
+ // create functions for all delegated methods
291
+ // PERFOPT: 'cache' length of aMethods to reduce # of resolutions
292
+ for (var i = 0, ml = aMethods.length; i < ml; i++) {
293
+ sMethodName = aMethods[i];
294
+ //!oObject[sMethodName] for 'lazy' loading interface methods ;-)
295
+ if (!oObject[sMethodName] || typeof oObject[sMethodName] === "function") {
296
+ this[sMethodName] = fCreateDelegator(oObject, sMethodName);
62
297
  }
298
+ }
63
299
  };
64
300
  export default BaseObject;
@@ -1,2 +1,24 @@
1
- import CalendarType from '../../base/i18n/date/CalendarType.js';
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
+ // Provides type sap.ui.core.CalendarType.
7
+ import DataType from "../base/DataType.js";
8
+ import CalendarType from "../../base/i18n/date/CalendarType.js";
9
+ /**
10
+ * The types of <code>Calendar</code>.
11
+ *
12
+ * @enum {string}
13
+ * @name sap.ui.core.CalendarType
14
+ * @public
15
+ * @deprecated As of Version 1.120. Please use {@link module:sap/base/18n/date/CalendarType} instead.
16
+ * @borrows module:sap/base/i18n/date/CalendarType.Gregorian as Gregorian
17
+ * @borrows module:sap/base/i18n/date/CalendarType.Islamic as Islamic
18
+ * @borrows module:sap/base/i18n/date/CalendarType.Japanese as Japanese
19
+ * @borrows module:sap/base/i18n/date/CalendarType.Persian as Persian
20
+ * @borrows module:sap/base/i18n/date/CalendarType.Buddhist as Buddhist
21
+ */
22
+
23
+ DataType.registerEnum("sap.ui.core.CalendarType", CalendarType);
2
24
  export default CalendarType;
@@ -1,62 +1,194 @@
1
- import assert from '../../base/assert.js';
2
- import BaseObject from '../base/Object.js';
3
- import Localization from '../../base/i18n/Localization.js';
4
- import LanguageTag from '../../base/i18n/LanguageTag.js';
5
- var Locale = BaseObject.extend('sap.ui.core.Locale', {
6
- constructor: function (vLocale) {
7
- BaseObject.apply(this);
8
- if (vLocale instanceof LanguageTag) {
9
- this.oLanguageTag = vLocale;
10
- this.sLocaleId = this.oLanguageTag.toString();
11
- } else {
12
- this.oLanguageTag = new LanguageTag(vLocale);
13
- this.sLocaleId = vLocale;
14
- }
15
- Object.assign(this, this.oLanguageTag);
16
- this.sLanguage = this.language;
17
- },
18
- getLanguage: function () {
19
- return this.language;
20
- },
21
- getScript: function () {
22
- return this.script;
23
- },
24
- getRegion: function () {
25
- return this.region;
26
- },
27
- getVariant: function () {
28
- return this.variant;
29
- },
30
- getVariantSubtags: function () {
31
- return this.variantSubtags;
32
- },
33
- getExtension: function () {
34
- return this.extension;
35
- },
36
- getExtensionSubtags: function () {
37
- return this.extensionSubtags;
38
- },
39
- getPrivateUse: function () {
40
- return this.privateUse;
41
- },
42
- getPrivateUseSubtags: function () {
43
- return this.privateUseSubtags;
44
- },
45
- hasPrivateUseSubtag: function (sSubtag) {
46
- assert(sSubtag && sSubtag.match(/^[0-9A-Z]{1,8}$/i), 'subtag must be a valid BCP47 private use tag');
47
- return this.privateUseSubtags.indexOf(sSubtag) >= 0;
48
- },
49
- toString: function () {
50
- return this.oLanguageTag.toString();
51
- },
52
- getSAPLogonLanguage: function () {
53
- return Localization._getSAPLogonLanguage(this);
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
+ //Provides the locale object sap.ui.core.Locale
7
+ import assert from "../../base/assert.js";
8
+ import BaseObject from "../base/Object.js";
9
+ import Localization from "../../base/i18n/Localization.js";
10
+ import LanguageTag from "../../base/i18n/LanguageTag.js";
11
+ var mCache = Object.create(null);
12
+
13
+ /**
14
+ * Creates an instance of the Locale.
15
+ *
16
+ * @class Locale represents a locale setting, consisting of a language, script, region, variants, extensions and private use section.
17
+ *
18
+ * @param {string} sLocale the locale identifier, in format en-US or en_US.
19
+ *
20
+ * @extends sap.ui.base.Object
21
+ * @author SAP SE
22
+ * @version 1.120.3
23
+ * @public
24
+ * @alias sap.ui.core.Locale
25
+ */
26
+ var Locale = BaseObject.extend("sap.ui.core.Locale", /** @lends sap.ui.core.Locale.prototype */{
27
+ constructor: function (vLocale) {
28
+ BaseObject.apply(this);
29
+ if (vLocale instanceof LanguageTag) {
30
+ this.oLanguageTag = vLocale;
31
+ this.sLocaleId = this.oLanguageTag.toString();
32
+ } else {
33
+ this.oLanguageTag = new LanguageTag(vLocale);
34
+ this.sLocaleId = vLocale;
54
35
  }
36
+ Object.assign(this, this.oLanguageTag);
37
+ this.sLanguage = this.language;
38
+ },
39
+ /**
40
+ * Get the locale language.
41
+ *
42
+ * Note that the case might differ from the original script tag
43
+ * (Lower case is enforced as recommended by BCP47/ISO639).
44
+ *
45
+ * @returns {string} the language code
46
+ * @public
47
+ */
48
+ getLanguage: function () {
49
+ return this.language;
50
+ },
51
+ /**
52
+ * Get the locale script or <code>null</code> if none was specified.
53
+ *
54
+ * Note that the case might differ from the original language tag
55
+ * (Upper case first letter and lower case reminder enforced as
56
+ * recommended by BCP47/ISO15924)
57
+ *
58
+ * @returns {string|null} the script code or <code>null</code>
59
+ * @public
60
+ */
61
+ getScript: function () {
62
+ return this.script;
63
+ },
64
+ /**
65
+ * Get the locale region or <code>null</code> if none was specified.
66
+ *
67
+ * Note that the case might differ from the original script tag
68
+ * (Upper case is enforced as recommended by BCP47/ISO3166-1).
69
+ *
70
+ * @returns {string} the ISO3166-1 region code (2-letter or 3-digits)
71
+ * @public
72
+ */
73
+ getRegion: function () {
74
+ return this.region;
75
+ },
76
+ /**
77
+ * Get the locale variants as a single string or <code>null</code>.
78
+ *
79
+ * Multiple variants are separated by a dash '-'.
80
+ *
81
+ * @returns {string|null} the variant or <code>null</code>
82
+ * @public
83
+ */
84
+ getVariant: function () {
85
+ return this.variant;
86
+ },
87
+ /**
88
+ * Get the locale variants as an array of individual variants.
89
+ *
90
+ * The separating dashes are not part of the result.
91
+ * If there is no variant section in the locale tag, an empty array is returned.
92
+ *
93
+ * @returns {string[]} the individual variant sections
94
+ * @public
95
+ */
96
+ getVariantSubtags: function () {
97
+ return this.variantSubtags;
98
+ },
99
+ /**
100
+ * Get the locale extension as a single string or <code>null</code>.
101
+ *
102
+ * The extension always consists of a singleton character (not 'x'),
103
+ * a dash '-' and one or more extension token, each separated
104
+ * again with a dash.
105
+ *
106
+ * Use {@link #getExtensions} to get the individual extension tokens as an array.
107
+ *
108
+ * @returns {string|null} the extension or <code>null</code>
109
+ * @public
110
+ */
111
+ getExtension: function () {
112
+ return this.extension;
113
+ },
114
+ /**
115
+ * Get the locale extensions as an array of tokens.
116
+ *
117
+ * The leading singleton and the separating dashes are not part of the result.
118
+ * If there is no extensions section in the locale tag, an empty array is returned.
119
+ *
120
+ * @returns {string[]} the individual extension sections
121
+ * @public
122
+ */
123
+ getExtensionSubtags: function () {
124
+ return this.extensionSubtags;
125
+ },
126
+ /**
127
+ * Get the locale private use section or <code>null</code>.
128
+ *
129
+ * @returns {string} the private use section
130
+ * @public
131
+ */
132
+ getPrivateUse: function () {
133
+ return this.privateUse;
134
+ },
135
+ /**
136
+ * Get the locale private use section as an array of tokens.
137
+ *
138
+ * The leading singleton and the separating dashes are not part of the result.
139
+ * If there is no private use section in the locale tag, an empty array is returned.
140
+ *
141
+ * @returns {string[]} the tokens of the private use section
142
+ * @public
143
+ */
144
+ getPrivateUseSubtags: function () {
145
+ return this.privateUseSubtags;
146
+ },
147
+ /**
148
+ * Check if a subtag is provided
149
+ *
150
+ * @param {string} sSubtag The subtag to check
151
+ * @returns {boolean} Wether the subtag is provided or not
152
+ */
153
+ hasPrivateUseSubtag: function (sSubtag) {
154
+ assert(sSubtag && sSubtag.match(/^[0-9A-Z]{1,8}$/i), "subtag must be a valid BCP47 private use tag");
155
+ return this.privateUseSubtags.indexOf(sSubtag) >= 0;
156
+ },
157
+ toString: function () {
158
+ return this.oLanguageTag.toString();
159
+ },
160
+ /**
161
+ * Best guess to get a proper SAP Logon Language for this locale.
162
+ *
163
+ * Conversions taken into account:
164
+ * <ul>
165
+ * <li>use the language part only</li>
166
+ * <li>convert old ISO639 codes to newer ones (e.g. 'iw' to 'he')</li>
167
+ * <li>for Chinese, map 'Traditional Chinese' or region 'TW' to SAP proprietary code 'zf'</li>
168
+ * <li>map private extensions x-saptrc, x-sappsd and saprigi to SAP pseudo languages '1Q', '2Q' and '3Q'</li>
169
+ * <li>remove ext. language sub tags</li>
170
+ * <li>convert to uppercase</li>
171
+ * </ul>
172
+ *
173
+ * Note that the conversion also returns a result for languages that are not
174
+ * supported by the default set of SAP languages. This method has no knowledge
175
+ * about the concrete languages of any given backend system.
176
+ *
177
+ * @returns {string} a language code that should
178
+ * @public
179
+ * @since 1.17.0
180
+ * @deprecated As of 1.44, use {@link sap.ui.core.Configuration#getSAPLogonLanguage} instead
181
+ * as that class allows to configure an SAP Logon language.
182
+ */
183
+ getSAPLogonLanguage: function () {
184
+ return Localization._getSAPLogonLanguage(this);
185
+ }
55
186
  });
56
187
  Locale._getCoreLocale = function (oLocale) {
57
- if (oLocale instanceof LanguageTag) {
58
- oLocale = new Locale(oLocale);
59
- }
60
- return oLocale;
188
+ if (oLocale instanceof LanguageTag) {
189
+ oLocale = mCache[oLocale.toString()] || new Locale(oLocale);
190
+ mCache[oLocale.toString()] = oLocale;
191
+ }
192
+ return oLocale;
61
193
  };
62
194
  export default Locale;