@ui5/webcomponents-localization 0.0.0-3236d56be → 0.0.0-33e059bcd

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 (235) hide show
  1. package/.eslintignore +2 -1
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +662 -0
  4. package/README.md +6 -6
  5. package/dist/.tsbuildinfo +1 -0
  6. package/{src/Assets-static.js → dist/Assets-static.d.ts} +0 -1
  7. package/dist/Assets-static.js +1 -0
  8. package/dist/Assets-static.js.map +1 -0
  9. package/dist/Assets.d.ts +1 -0
  10. package/dist/Assets.js +1 -0
  11. package/dist/Assets.js.map +1 -0
  12. package/dist/DateFormat.d.ts +6 -0
  13. package/dist/DateFormat.js +6 -2
  14. package/dist/DateFormat.js.map +1 -0
  15. package/dist/LocaleData.d.ts +6 -0
  16. package/dist/LocaleData.js +6 -2
  17. package/dist/LocaleData.js.map +1 -0
  18. package/dist/dates/CalendarDate.d.ts +43 -0
  19. package/dist/dates/CalendarDate.js +171 -207
  20. package/dist/dates/CalendarDate.js.map +1 -0
  21. package/dist/dates/ExtremeDates.d.ts +5 -0
  22. package/dist/dates/ExtremeDates.js +25 -35
  23. package/dist/dates/ExtremeDates.js.map +1 -0
  24. package/dist/dates/UI5Date.d.ts +6 -0
  25. package/dist/dates/UI5Date.js +7 -0
  26. package/dist/dates/UI5Date.js.map +1 -0
  27. package/dist/dates/UniversalDate.d.ts +47 -0
  28. package/dist/dates/UniversalDate.js +5 -0
  29. package/dist/dates/UniversalDate.js.map +1 -0
  30. package/dist/dates/calculateWeekNumber.d.ts +5 -0
  31. package/dist/dates/calculateWeekNumber.js +42 -48
  32. package/dist/dates/calculateWeekNumber.js.map +1 -0
  33. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  34. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  35. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  36. package/dist/dates/getDaysInMonth.d.ts +3 -0
  37. package/dist/dates/getDaysInMonth.js +10 -0
  38. package/dist/dates/getDaysInMonth.js.map +1 -0
  39. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  40. package/dist/dates/getRoundedTimestamp.js +10 -9
  41. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  42. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  43. package/dist/dates/getTodayUTCTimestamp.js +3 -3
  44. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  45. package/dist/dates/modifyDateBy.d.ts +14 -0
  46. package/dist/dates/modifyDateBy.js +42 -29
  47. package/dist/dates/modifyDateBy.js.map +1 -0
  48. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  49. package/dist/dates/transformDateToSecondaryType.js +18 -0
  50. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  51. package/dist/features/calendar/Buddhist.js +1 -0
  52. package/dist/features/calendar/Buddhist.js.map +1 -0
  53. package/dist/features/calendar/Gregorian.js +1 -0
  54. package/dist/features/calendar/Gregorian.js.map +1 -0
  55. package/dist/features/calendar/Islamic.js +1 -0
  56. package/dist/features/calendar/Islamic.js.map +1 -0
  57. package/dist/features/calendar/Japanese.js +1 -0
  58. package/dist/features/calendar/Japanese.js.map +1 -0
  59. package/dist/features/calendar/Persian.js +1 -0
  60. package/dist/features/calendar/Persian.js.map +1 -0
  61. package/dist/generated/assets/cldr/ar.json +5571 -5906
  62. package/dist/generated/assets/cldr/ar_EG.json +5571 -5906
  63. package/dist/generated/assets/cldr/ar_SA.json +5570 -5906
  64. package/dist/generated/assets/cldr/bg.json +4491 -4979
  65. package/dist/generated/assets/cldr/ca.json +4478 -4996
  66. package/dist/generated/assets/cldr/cs.json +5067 -5498
  67. package/dist/generated/assets/cldr/cy.json +5479 -5884
  68. package/dist/generated/assets/cldr/da.json +4371 -4888
  69. package/dist/generated/assets/cldr/de.json +4420 -4916
  70. package/dist/generated/assets/cldr/de_AT.json +4421 -4917
  71. package/dist/generated/assets/cldr/de_CH.json +4419 -4915
  72. package/dist/generated/assets/cldr/el.json +4309 -4883
  73. package/dist/generated/assets/cldr/el_CY.json +4309 -4883
  74. package/dist/generated/assets/cldr/en.json +4342 -4971
  75. package/dist/generated/assets/cldr/en_AU.json +4382 -4962
  76. package/dist/generated/assets/cldr/en_GB.json +4373 -4971
  77. package/dist/generated/assets/cldr/en_HK.json +4382 -4977
  78. package/dist/generated/assets/cldr/en_IE.json +4373 -4971
  79. package/dist/generated/assets/cldr/en_IN.json +4378 -4972
  80. package/dist/generated/assets/cldr/en_NZ.json +4373 -4971
  81. package/dist/generated/assets/cldr/en_PG.json +4374 -4972
  82. package/dist/generated/assets/cldr/en_SG.json +4378 -4973
  83. package/dist/generated/assets/cldr/en_ZA.json +4374 -4972
  84. package/dist/generated/assets/cldr/es.json +4584 -4912
  85. package/dist/generated/assets/cldr/es_AR.json +4587 -4914
  86. package/dist/generated/assets/cldr/es_BO.json +4586 -4913
  87. package/dist/generated/assets/cldr/es_CL.json +4479 -4914
  88. package/dist/generated/assets/cldr/es_CO.json +4479 -4913
  89. package/dist/generated/assets/cldr/es_MX.json +4588 -4915
  90. package/dist/generated/assets/cldr/es_PE.json +4370 -4913
  91. package/dist/generated/assets/cldr/es_UY.json +4372 -4915
  92. package/dist/generated/assets/cldr/es_VE.json +4371 -4914
  93. package/dist/generated/assets/cldr/et.json +4373 -4967
  94. package/dist/generated/assets/cldr/fa.json +4429 -4883
  95. package/dist/generated/assets/cldr/fi.json +4514 -5008
  96. package/dist/generated/assets/cldr/fr.json +4383 -4979
  97. package/dist/generated/assets/cldr/fr_BE.json +4383 -4979
  98. package/dist/generated/assets/cldr/fr_CA.json +4377 -4973
  99. package/dist/generated/assets/cldr/fr_CH.json +4401 -4997
  100. package/dist/generated/assets/cldr/fr_LU.json +4383 -4979
  101. package/dist/generated/assets/cldr/he.json +4980 -5378
  102. package/dist/generated/assets/cldr/hi.json +4345 -4829
  103. package/dist/generated/assets/cldr/hr.json +4640 -4919
  104. package/dist/generated/assets/cldr/hu.json +4415 -4856
  105. package/dist/generated/assets/cldr/id.json +4132 -4658
  106. package/dist/generated/assets/cldr/it.json +4355 -4950
  107. package/dist/generated/assets/cldr/it_CH.json +4355 -4950
  108. package/dist/generated/assets/cldr/ja.json +4251 -4830
  109. package/dist/generated/assets/cldr/kk.json +4503 -4725
  110. package/dist/generated/assets/cldr/ko.json +4210 -4738
  111. package/dist/generated/assets/cldr/lt.json +4939 -5481
  112. package/dist/generated/assets/cldr/lv.json +4651 -5112
  113. package/dist/generated/assets/cldr/ms.json +4093 -4515
  114. package/dist/generated/assets/cldr/nb.json +4403 -4977
  115. package/dist/generated/assets/cldr/nl.json +4542 -4884
  116. package/dist/generated/assets/cldr/nl_BE.json +4542 -4884
  117. package/dist/generated/assets/cldr/pl.json +4978 -5176
  118. package/dist/generated/assets/cldr/pt.json +4597 -4805
  119. package/dist/generated/assets/cldr/pt_PT.json +4648 -4940
  120. package/dist/generated/assets/cldr/ro.json +4633 -5090
  121. package/dist/generated/assets/cldr/ru.json +4947 -5407
  122. package/dist/generated/assets/cldr/ru_UA.json +4947 -5407
  123. package/dist/generated/assets/cldr/sk.json +4980 -5370
  124. package/dist/generated/assets/cldr/sl.json +4948 -5340
  125. package/dist/generated/assets/cldr/sr.json +4737 -5126
  126. package/dist/generated/assets/cldr/sr_Latn.json +4722 -5127
  127. package/dist/generated/assets/cldr/sv.json +4406 -5011
  128. package/dist/generated/assets/cldr/th.json +4234 -4797
  129. package/dist/generated/assets/cldr/tr.json +4451 -4979
  130. package/dist/generated/assets/cldr/uk.json +4908 -5353
  131. package/dist/generated/assets/cldr/vi.json +4094 -4673
  132. package/dist/generated/assets/cldr/zh_CN.json +4124 -4632
  133. package/dist/generated/assets/cldr/zh_HK.json +4132 -4640
  134. package/dist/generated/assets/cldr/zh_SG.json +4132 -4640
  135. package/dist/generated/assets/cldr/zh_TW.json +4155 -4728
  136. package/dist/generated/json-imports/LocaleData-static.d.ts +1 -0
  137. package/dist/generated/json-imports/LocaleData-static.js +9 -11
  138. package/dist/generated/json-imports/LocaleData-static.js.map +1 -0
  139. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  140. package/dist/generated/json-imports/LocaleData.js +86 -88
  141. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  142. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  143. package/dist/getCachedLocaleDataInstance.js +6 -9
  144. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  145. package/dist/locale/getLocaleData.d.ts +11 -0
  146. package/dist/locale/getLocaleData.js +13 -17
  147. package/dist/locale/getLocaleData.js.map +1 -0
  148. package/dist/sap/base/Event.js +59 -0
  149. package/dist/sap/base/Eventing.js +146 -0
  150. package/dist/sap/base/Log.js +2 -240
  151. package/dist/sap/base/assert.js +31 -5
  152. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  153. package/dist/sap/base/config.js +17 -0
  154. package/dist/sap/base/i18n/Formatting.js +1130 -0
  155. package/dist/sap/base/i18n/LanguageTag.js +173 -0
  156. package/dist/sap/base/i18n/Localization.d.ts +4 -0
  157. package/dist/sap/base/i18n/Localization.js +12 -0
  158. package/dist/sap/base/i18n/Localization.js.map +1 -0
  159. package/dist/sap/base/i18n/date/CalendarType.js +43 -0
  160. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +105 -0
  161. package/dist/sap/base/i18n/date/TimezoneUtils.js +319 -0
  162. package/dist/sap/base/strings/camelize.js +30 -0
  163. package/dist/sap/base/strings/formatMessage.js +88 -15
  164. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  165. package/dist/sap/base/util/LoaderExtensions.js +9 -12
  166. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  167. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  168. package/dist/sap/base/util/ObjectPath.js +4 -33
  169. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  170. package/dist/sap/base/util/Version.js +157 -0
  171. package/dist/sap/base/util/_merge.js +83 -26
  172. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  173. package/dist/sap/base/util/deepClone.js +102 -0
  174. package/dist/sap/base/util/deepEqual.js +75 -51
  175. package/dist/sap/base/util/extend.js +58 -7
  176. package/dist/sap/base/util/isEmptyObject.js +34 -0
  177. package/dist/sap/base/util/isPlainObject.js +35 -1
  178. package/dist/sap/base/util/now.js +24 -3
  179. package/dist/sap/base/util/resolveReference.js +157 -0
  180. package/dist/sap/base/util/uid.js +27 -0
  181. package/dist/sap/ui/base/DataType.js +657 -0
  182. package/dist/sap/ui/base/Interface.js +47 -1
  183. package/dist/sap/ui/base/Metadata.js +435 -171
  184. package/dist/sap/ui/base/Object.js +284 -48
  185. package/dist/sap/ui/core/CalendarType.js +24 -8
  186. package/dist/sap/ui/core/Configuration.d.ts +18 -0
  187. package/dist/sap/ui/core/Configuration.js +23 -0
  188. package/dist/sap/ui/core/Configuration.js.map +1 -0
  189. package/dist/sap/ui/core/Core.d.ts +27 -0
  190. package/dist/sap/ui/core/Core.js +7 -34
  191. package/dist/sap/ui/core/Core.js.map +1 -0
  192. package/dist/sap/ui/core/FormatSettings.d.ts +10 -0
  193. package/dist/sap/ui/core/FormatSettings.js +14 -0
  194. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  195. package/dist/sap/ui/core/Locale.js +190 -152
  196. package/dist/sap/ui/core/LocaleData.js +2665 -1228
  197. package/dist/sap/ui/core/Supportability.js +5 -0
  198. package/dist/sap/ui/core/Theming.js +539 -0
  199. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  200. package/dist/sap/ui/core/date/CalendarUtils.js +65 -0
  201. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  202. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  203. package/dist/sap/ui/core/date/Islamic.js +298 -185
  204. package/dist/sap/ui/core/date/Japanese.js +212 -117
  205. package/dist/sap/ui/core/date/Persian.js +324 -195
  206. package/dist/sap/ui/core/date/UI5Date.js +991 -0
  207. package/dist/sap/ui/core/date/UniversalDate.js +1251 -217
  208. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  209. package/dist/sap/ui/core/format/DateFormat.js +3139 -1965
  210. package/dist/sap/ui/core/format/TimezoneUtil.js +24 -83
  211. package/package-scripts.cjs +26 -0
  212. package/package.json +13 -6
  213. package/tsconfig.json +24 -0
  214. package/used-modules.txt +28 -2
  215. package/dist/sap/ui/Device.js +0 -5
  216. package/package-scripts.js +0 -35
  217. package/src/Assets.js +0 -2
  218. package/src/DateFormat.js +0 -3
  219. package/src/LocaleData.js +0 -3
  220. package/src/dates/CalendarDate.js +0 -229
  221. package/src/dates/ExtremeDates.js +0 -39
  222. package/src/dates/calculateWeekNumber.js +0 -51
  223. package/src/dates/getRoundedTimestamp.js +0 -14
  224. package/src/dates/getTodayUTCTimestamp.js +0 -9
  225. package/src/dates/modifyDateBy.js +0 -42
  226. package/src/getCachedLocaleDataInstance.js +0 -13
  227. package/src/locale/getLocaleData.js +0 -27
  228. package/src/sap/base/util/LoaderExtensions.js +0 -17
  229. package/src/sap/ui/core/Core.js +0 -40
  230. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  231. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  232. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  233. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  234. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  235. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -1,156 +1,194 @@
1
- import BaseObject from '../base/Object.js';
2
- import assert from '../../base/assert.js';
3
- import CalendarType from './CalendarType.js';
4
- var rLocale = /^((?:[A-Z]{2,3}(?:-[A-Z]{3}){0,3})|[A-Z]{4}|[A-Z]{5,8})(?:-([A-Z]{4}))?(?:-([A-Z]{2}|[0-9]{3}))?((?:-[0-9A-Z]{5,8}|-[0-9][0-9A-Z]{3})*)((?:-[0-9A-WYZ](?:-[0-9A-Z]{2,8})+)*)(?:-(X(?:-[0-9A-Z]{1,8})+))?$/i;
5
- var Locale = BaseObject.extend('sap.ui.core.Locale', {
6
- constructor: function (sLocaleId) {
7
- BaseObject.apply(this);
8
- var aResult = rLocale.exec(sLocaleId.replace(/_/g, '-'));
9
- if (aResult === null) {
10
- throw new TypeError('The given language \'' + sLocaleId + '\' does not adhere to BCP-47.');
11
- }
12
- this.sLocaleId = sLocaleId;
13
- this.sLanguage = aResult[1] || null;
14
- this.sScript = aResult[2] || null;
15
- this.sRegion = aResult[3] || null;
16
- this.sVariant = aResult[4] && aResult[4].slice(1) || null;
17
- this.sExtension = aResult[5] && aResult[5].slice(1) || null;
18
- this.sPrivateUse = aResult[6] || null;
19
- if (this.sLanguage) {
20
- this.sLanguage = this.sLanguage.toLowerCase();
21
- }
22
- if (this.sScript) {
23
- this.sScript = this.sScript.toLowerCase().replace(/^[a-z]/, function ($) {
24
- return $.toUpperCase();
25
- });
26
- }
27
- if (this.sRegion) {
28
- this.sRegion = this.sRegion.toUpperCase();
29
- }
30
- },
31
- getLanguage: function () {
32
- return this.sLanguage;
33
- },
34
- getScript: function () {
35
- return this.sScript;
36
- },
37
- getRegion: function () {
38
- return this.sRegion;
39
- },
40
- getVariant: function () {
41
- return this.sVariant;
42
- },
43
- getVariantSubtags: function () {
44
- return this.sVariant ? this.sVariant.split('-') : [];
45
- },
46
- getExtension: function () {
47
- return this.sExtension;
48
- },
49
- getExtensionSubtags: function () {
50
- return this.sExtension ? this.sExtension.slice(2).split('-') : [];
51
- },
52
- getPrivateUse: function () {
53
- return this.sPrivateUse;
54
- },
55
- getPrivateUseSubtags: function () {
56
- return this.sPrivateUse ? this.sPrivateUse.slice(2).split('-') : [];
57
- },
58
- hasPrivateUseSubtag: function (sSubtag) {
59
- assert(sSubtag && sSubtag.match(/^[0-9A-Z]{1,8}$/i), 'subtag must be a valid BCP47 private use tag');
60
- return this.getPrivateUseSubtags().indexOf(sSubtag) >= 0;
61
- },
62
- toString: function () {
63
- return join(this.sLanguage, this.sScript, this.sRegion, this.sVariant, this.sExtension, this.sPrivateUse);
64
- },
65
- toLanguageTag: function () {
66
- var sLanguage = this.getModernLanguage();
67
- var sScript = this.sScript;
68
- if (sLanguage === 'sr' && sScript === 'Latn') {
69
- sLanguage = 'sh';
70
- sScript = null;
71
- }
72
- return join(sLanguage, sScript, this.sRegion, this.sVariant, this.sExtension, this.sPrivateUse);
73
- },
74
- getModernLanguage: function () {
75
- return M_ISO639_OLD_TO_NEW[this.sLanguage] || this.sLanguage;
76
- },
77
- getSAPLogonLanguage: function () {
78
- var sLanguage = this.sLanguage || '';
79
- if (sLanguage.indexOf('-') >= 0) {
80
- sLanguage = sLanguage.slice(0, sLanguage.indexOf('-'));
81
- }
82
- sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
83
- if (sLanguage === 'zh' && !this.sScript && this.sRegion === 'TW') {
84
- return 'ZF';
85
- }
86
- return M_LOCALE_TO_ABAP_LANGUAGE[join(sLanguage, this.sScript)] || M_LOCALE_TO_ABAP_LANGUAGE[join(sLanguage, this.sRegion)] || M_LOCALE_TO_ABAP_LANGUAGE[getPseudoLanguageTag(this.sPrivateUse)] || sLanguage.toUpperCase();
87
- },
88
- getPreferredCalendarType: function () {
89
- return Locale._mPreferredCalendar[this.getLanguage() + '-' + this.getRegion()] || Locale._mPreferredCalendar[this.getLanguage()] || Locale._mPreferredCalendar['default'];
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;
90
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
+ }
91
186
  });
92
- function getPseudoLanguageTag(sPrivateUse) {
93
- if (sPrivateUse) {
94
- var m = /-(saptrc|sappsd|saprigi)(?:-|$)/i.exec(sPrivateUse);
95
- return m && 'en-US-x-' + m[1].toLowerCase();
96
- }
97
- }
98
- var M_ISO639_OLD_TO_NEW = {
99
- 'iw': 'he',
100
- 'ji': 'yi'
101
- };
102
- var M_ABAP_LANGUAGE_TO_LOCALE = {
103
- 'ZH': 'zh-Hans',
104
- 'ZF': 'zh-Hant',
105
- 'SH': 'sr-Latn',
106
- '6N': 'en-GB',
107
- '1P': 'pt-PT',
108
- '1X': 'es-MX',
109
- '3F': 'fr-CA',
110
- '1Q': 'en-US-x-saptrc',
111
- '2Q': 'en-US-x-sappsd',
112
- '3Q': 'en-US-x-saprigi'
113
- };
114
- var M_LOCALE_TO_ABAP_LANGUAGE = inverse(M_ABAP_LANGUAGE_TO_LOCALE);
115
- function getDesigntimePropertyAsArray(sValue) {
116
- var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
117
- return m && m[2] ? m[2].split(/,/) : null;
118
- }
119
- var A_RTL_LOCALES = getDesigntimePropertyAsArray('$cldr-rtl-locales:ar,fa,he$') || [];
120
- Locale._cldrLocales = getDesigntimePropertyAsArray('$cldr-locales:ar,ar_EG,ar_SA,bg,ca,cy,cs,da,de,de_AT,de_CH,el,el_CY,en,en_AU,en_GB,en_HK,en_IE,en_IN,en_NZ,en_PG,en_SG,en_ZA,es,es_AR,es_BO,es_CL,es_CO,es_MX,es_PE,es_UY,es_VE,et,fa,fi,fr,fr_BE,fr_CA,fr_CH,fr_LU,he,hi,hr,hu,id,it,it_CH,ja,kk,ko,lt,lv,ms,nb,nl,nl_BE,pl,pt,pt_PT,ro,ru,ru_UA,sk,sl,sr,sr_Latn,sv,th,tr,uk,vi,zh_CN,zh_HK,zh_SG,zh_TW$');
121
- Locale._mPreferredCalendar = {
122
- 'ar-SA': CalendarType.Islamic,
123
- 'fa': CalendarType.Persian,
124
- 'th': CalendarType.Buddhist,
125
- 'default': CalendarType.Gregorian
126
- };
127
- Locale._coreI18nLocales = getDesigntimePropertyAsArray('$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,en_GB,es,es_MX,et,fi,fr,hi,hr,hu,it,iw,ja,kk,ko,lt,lv,ms,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$');
128
- Locale._impliesRTL = function (vLanguage) {
129
- var oLocale = vLanguage instanceof Locale ? vLanguage : new Locale(vLanguage);
130
- var sLanguage = oLocale.getLanguage() || '';
131
- sLanguage = sLanguage && M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
132
- var sRegion = oLocale.getRegion() || '';
133
- if (sRegion && A_RTL_LOCALES.indexOf(sLanguage + '_' + sRegion) >= 0) {
134
- return true;
135
- }
136
- return A_RTL_LOCALES.indexOf(sLanguage) >= 0;
137
- };
138
- Locale.fromSAPLogonLanguage = function (sSAPLogonLanguage) {
139
- if (sSAPLogonLanguage && typeof sSAPLogonLanguage === 'string') {
140
- sSAPLogonLanguage = M_ABAP_LANGUAGE_TO_LOCALE[sSAPLogonLanguage.toUpperCase()] || sSAPLogonLanguage;
141
- try {
142
- return new Locale(sSAPLogonLanguage);
143
- } catch (e) {
144
- }
145
- }
187
+ Locale._getCoreLocale = function (oLocale) {
188
+ if (oLocale instanceof LanguageTag) {
189
+ oLocale = mCache[oLocale.toString()] || new Locale(oLocale);
190
+ mCache[oLocale.toString()] = oLocale;
191
+ }
192
+ return oLocale;
146
193
  };
147
- function join() {
148
- return Array.prototype.filter.call(arguments, Boolean).join('-');
149
- }
150
- function inverse(obj) {
151
- return Object.keys(obj).reduce(function (inv, key) {
152
- inv[obj[key]] = key;
153
- return inv;
154
- }, {});
155
- }
156
194
  export default Locale;