@ui5/webcomponents-localization 0.0.0-0fcda382e → 0.0.0-10f3c0dc7

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 (275) hide show
  1. package/.eslintignore +2 -0
  2. package/.npsrc.json +3 -0
  3. package/CHANGELOG.md +2427 -0
  4. package/LICENSE.txt +201 -0
  5. package/README.md +38 -10
  6. package/dist/.tsbuildinfo +1 -0
  7. package/dist/Assets-fetch.d.ts +1 -0
  8. package/dist/Assets-fetch.js +3 -0
  9. package/dist/Assets-fetch.js.map +1 -0
  10. package/dist/Assets-node.d.ts +11 -0
  11. package/dist/Assets-node.js +12 -0
  12. package/dist/Assets-node.js.map +1 -0
  13. package/dist/Assets.d.ts +1 -0
  14. package/dist/Assets.js +1 -0
  15. package/dist/Assets.js.map +1 -0
  16. package/dist/CalendarUtils.d.ts +3 -0
  17. package/dist/CalendarUtils.js +6 -0
  18. package/dist/CalendarUtils.js.map +1 -0
  19. package/dist/DateFormat.d.ts +28 -0
  20. package/dist/DateFormat.js +22 -2
  21. package/dist/DateFormat.js.map +1 -0
  22. package/dist/Locale.d.ts +5 -0
  23. package/dist/Locale.js +7 -0
  24. package/dist/Locale.js.map +1 -0
  25. package/dist/LocaleData.d.ts +5 -0
  26. package/dist/LocaleData.js +6 -2
  27. package/dist/LocaleData.js.map +1 -0
  28. package/dist/NumberFormat.d.ts +5 -0
  29. package/dist/NumberFormat.js +7 -0
  30. package/dist/NumberFormat.js.map +1 -0
  31. package/dist/dates/CalendarDate.d.ts +42 -0
  32. package/dist/dates/CalendarDate.js +171 -181
  33. package/dist/dates/CalendarDate.js.map +1 -0
  34. package/dist/dates/ExtremeDates.d.ts +5 -0
  35. package/dist/dates/ExtremeDates.js +29 -0
  36. package/dist/dates/ExtremeDates.js.map +1 -0
  37. package/dist/dates/UI5Date.d.ts +5 -0
  38. package/dist/dates/UI5Date.js +7 -0
  39. package/dist/dates/UI5Date.js.map +1 -0
  40. package/dist/dates/UniversalDate.d.ts +47 -0
  41. package/dist/dates/UniversalDate.js +5 -0
  42. package/dist/dates/UniversalDate.js.map +1 -0
  43. package/dist/dates/convertMonthNumbersToMonthNames.d.ts +16 -0
  44. package/dist/dates/convertMonthNumbersToMonthNames.js +30 -0
  45. package/dist/dates/convertMonthNumbersToMonthNames.js.map +1 -0
  46. package/dist/dates/getDaysInMonth.d.ts +3 -0
  47. package/dist/dates/getDaysInMonth.js +10 -0
  48. package/dist/dates/getDaysInMonth.js.map +1 -0
  49. package/dist/dates/getRoundedTimestamp.d.ts +7 -0
  50. package/dist/dates/getRoundedTimestamp.js +15 -0
  51. package/dist/dates/getRoundedTimestamp.js.map +1 -0
  52. package/dist/dates/getTodayUTCTimestamp.d.ts +7 -0
  53. package/dist/dates/getTodayUTCTimestamp.js +9 -0
  54. package/dist/dates/getTodayUTCTimestamp.js.map +1 -0
  55. package/dist/dates/modifyDateBy.d.ts +14 -0
  56. package/dist/dates/modifyDateBy.js +55 -0
  57. package/dist/dates/modifyDateBy.js.map +1 -0
  58. package/dist/dates/transformDateToSecondaryType.d.ts +7 -0
  59. package/dist/dates/transformDateToSecondaryType.js +18 -0
  60. package/dist/dates/transformDateToSecondaryType.js.map +1 -0
  61. package/dist/features/calendar/Buddhist.js +1 -0
  62. package/dist/features/calendar/Buddhist.js.map +1 -0
  63. package/dist/features/calendar/Gregorian.js +1 -0
  64. package/dist/features/calendar/Gregorian.js.map +1 -0
  65. package/dist/features/calendar/Islamic.js +1 -0
  66. package/dist/features/calendar/Islamic.js.map +1 -0
  67. package/dist/features/calendar/Japanese.js +1 -0
  68. package/dist/features/calendar/Japanese.js.map +1 -0
  69. package/dist/features/calendar/Persian.js +1 -0
  70. package/dist/features/calendar/Persian.js.map +1 -0
  71. package/dist/generated/assets/cldr/Unicode-Data-Files-LICENSE.txt +39 -0
  72. package/dist/generated/assets/cldr/ar.json +2179 -728
  73. package/dist/generated/assets/cldr/ar_EG.json +2179 -728
  74. package/dist/generated/assets/cldr/ar_SA.json +2275 -825
  75. package/dist/generated/assets/cldr/bg.json +1924 -798
  76. package/dist/generated/assets/cldr/ca.json +2027 -816
  77. package/dist/generated/assets/cldr/cnr.json +6476 -0
  78. package/dist/generated/assets/cldr/cs.json +1865 -842
  79. package/dist/generated/assets/cldr/cy.json +6566 -0
  80. package/dist/generated/assets/cldr/da.json +1844 -682
  81. package/dist/generated/assets/cldr/de.json +1806 -546
  82. package/dist/generated/assets/cldr/de_AT.json +1797 -537
  83. package/dist/generated/assets/cldr/de_CH.json +1879 -611
  84. package/dist/generated/assets/cldr/el.json +1497 -383
  85. package/dist/generated/assets/cldr/el_CY.json +1497 -383
  86. package/dist/generated/assets/cldr/en.json +1990 -563
  87. package/dist/generated/assets/cldr/en_AU.json +2339 -763
  88. package/dist/generated/assets/cldr/en_GB.json +2170 -621
  89. package/dist/generated/assets/cldr/en_HK.json +2076 -628
  90. package/dist/generated/assets/cldr/en_IE.json +2038 -593
  91. package/dist/generated/assets/cldr/en_IN.json +2336 -704
  92. package/dist/generated/assets/cldr/en_NZ.json +2056 -611
  93. package/dist/generated/assets/cldr/en_PG.json +2049 -604
  94. package/dist/generated/assets/cldr/en_SG.json +2041 -593
  95. package/dist/generated/assets/cldr/en_ZA.json +2046 -599
  96. package/dist/generated/assets/cldr/es.json +2197 -881
  97. package/dist/generated/assets/cldr/es_AR.json +2167 -819
  98. package/dist/generated/assets/cldr/es_BO.json +2210 -863
  99. package/dist/generated/assets/cldr/es_CL.json +2087 -848
  100. package/dist/generated/assets/cldr/es_CO.json +1947 -707
  101. package/dist/generated/assets/cldr/es_MX.json +2446 -1091
  102. package/dist/generated/assets/cldr/es_PE.json +1912 -773
  103. package/dist/generated/assets/cldr/es_UY.json +1926 -795
  104. package/dist/generated/assets/cldr/es_VE.json +1920 -789
  105. package/dist/generated/assets/cldr/et.json +1761 -544
  106. package/dist/generated/assets/cldr/fa.json +1872 -566
  107. package/dist/generated/assets/cldr/fi.json +1959 -526
  108. package/dist/generated/assets/cldr/fr.json +1711 -460
  109. package/dist/generated/assets/cldr/fr_BE.json +1710 -459
  110. package/dist/generated/assets/cldr/fr_CA.json +2087 -814
  111. package/dist/generated/assets/cldr/fr_CH.json +1669 -418
  112. package/dist/generated/assets/cldr/fr_LU.json +1711 -460
  113. package/dist/generated/assets/cldr/he.json +2018 -1033
  114. package/dist/generated/assets/cldr/hi.json +1619 -348
  115. package/dist/generated/assets/cldr/hr.json +1855 -569
  116. package/dist/generated/assets/cldr/hu.json +1764 -551
  117. package/dist/generated/assets/cldr/id.json +1924 -601
  118. package/dist/generated/assets/cldr/it.json +1821 -666
  119. package/dist/generated/assets/cldr/it_CH.json +1827 -672
  120. package/dist/generated/assets/cldr/ja.json +1426 -109
  121. package/dist/generated/assets/cldr/kk.json +2251 -737
  122. package/dist/generated/assets/cldr/ko.json +1484 -196
  123. package/dist/generated/assets/cldr/lt.json +1714 -734
  124. package/dist/generated/assets/cldr/lv.json +1686 -682
  125. package/dist/generated/assets/cldr/mk.json +6177 -0
  126. package/dist/generated/assets/cldr/ms.json +1903 -595
  127. package/dist/generated/assets/cldr/nb.json +1548 -369
  128. package/dist/generated/assets/cldr/nl.json +1935 -511
  129. package/dist/generated/assets/cldr/nl_BE.json +1955 -531
  130. package/dist/generated/assets/cldr/pl.json +1873 -586
  131. package/dist/generated/assets/cldr/pt.json +2184 -753
  132. package/dist/generated/assets/cldr/pt_PT.json +2149 -778
  133. package/dist/generated/assets/cldr/ro.json +1847 -765
  134. package/dist/generated/assets/cldr/ru.json +2082 -755
  135. package/dist/generated/assets/cldr/ru_UA.json +2076 -749
  136. package/dist/generated/assets/cldr/sk.json +1860 -972
  137. package/dist/generated/assets/cldr/sl.json +1861 -920
  138. package/dist/generated/assets/cldr/sr.json +1829 -767
  139. package/dist/generated/assets/cldr/sr_Latn.json +6173 -0
  140. package/dist/generated/assets/cldr/sv.json +1789 -587
  141. package/dist/generated/assets/cldr/th.json +1704 -373
  142. package/dist/generated/assets/cldr/tr.json +1855 -587
  143. package/dist/generated/assets/cldr/uk.json +2166 -711
  144. package/dist/generated/assets/cldr/vi.json +2054 -709
  145. package/dist/generated/assets/cldr/zh_CN.json +1736 -397
  146. package/dist/generated/assets/cldr/zh_HK.json +1713 -374
  147. package/dist/generated/assets/cldr/zh_SG.json +1723 -384
  148. package/dist/generated/assets/cldr/zh_TW.json +1678 -371
  149. package/dist/generated/json-imports/LocaleData-fetch.d.ts +1 -0
  150. package/dist/generated/json-imports/LocaleData-fetch.js +93 -0
  151. package/dist/generated/json-imports/LocaleData-fetch.js.map +1 -0
  152. package/dist/generated/json-imports/LocaleData-node.d.ts +1 -0
  153. package/dist/generated/json-imports/LocaleData-node.js +93 -0
  154. package/dist/generated/json-imports/LocaleData-node.js.map +1 -0
  155. package/dist/generated/json-imports/LocaleData.d.ts +1 -0
  156. package/dist/generated/json-imports/LocaleData.js +92 -95
  157. package/dist/generated/json-imports/LocaleData.js.map +1 -0
  158. package/dist/getCachedLocaleDataInstance.d.ts +4 -0
  159. package/dist/getCachedLocaleDataInstance.js +12 -0
  160. package/dist/getCachedLocaleDataInstance.js.map +1 -0
  161. package/dist/locale/getLocaleData.d.ts +11 -0
  162. package/dist/locale/getLocaleData.js +15 -17
  163. package/dist/locale/getLocaleData.js.map +1 -0
  164. package/dist/sap/base/Event.js +59 -0
  165. package/dist/sap/base/Eventing.js +147 -0
  166. package/dist/sap/base/Log.js +2 -248
  167. package/dist/sap/base/assert.js +31 -9
  168. package/dist/sap/base/config/MemoryConfigurationProvider.js +20 -0
  169. package/dist/sap/base/config.js +17 -0
  170. package/dist/sap/base/future.js +12 -0
  171. package/dist/sap/base/i18n/Formatting.d.ts +13 -0
  172. package/dist/sap/base/i18n/Formatting.js +18 -0
  173. package/dist/sap/base/i18n/Formatting.js.map +1 -0
  174. package/dist/sap/base/i18n/LanguageTag.js +179 -0
  175. package/dist/sap/base/i18n/Localization.d.ts +7 -0
  176. package/dist/sap/base/i18n/Localization.js +17 -0
  177. package/dist/sap/base/i18n/Localization.js.map +1 -0
  178. package/dist/sap/base/i18n/ResourceBundle.js +20 -0
  179. package/dist/sap/base/i18n/date/CalendarType.js +44 -0
  180. package/dist/sap/base/i18n/date/CalendarWeekNumbering.js +106 -0
  181. package/dist/sap/base/i18n/date/TimezoneUtils.js +471 -0
  182. package/dist/sap/base/i18n/date/_EnumHelper.js +37 -0
  183. package/dist/sap/base/strings/camelize.js +30 -0
  184. package/dist/sap/base/strings/formatMessage.js +93 -15
  185. package/dist/sap/base/util/LoaderExtensions.d.ts +4 -0
  186. package/dist/sap/base/util/LoaderExtensions.js +11 -4
  187. package/dist/sap/base/util/LoaderExtensions.js.map +1 -0
  188. package/dist/sap/base/util/ObjectPath.d.ts +4 -0
  189. package/dist/sap/base/util/ObjectPath.js +4 -33
  190. package/dist/sap/base/util/ObjectPath.js.map +1 -0
  191. package/dist/sap/base/util/Properties.js +12 -0
  192. package/dist/sap/base/util/Version.js +163 -0
  193. package/dist/sap/base/util/_merge.js +83 -26
  194. package/dist/sap/base/util/array/uniqueSort.js +37 -15
  195. package/dist/sap/base/util/deepClone.js +102 -0
  196. package/dist/sap/base/util/deepEqual.js +75 -55
  197. package/dist/sap/base/util/deepExtend.js +60 -0
  198. package/dist/sap/base/util/extend.js +58 -7
  199. package/dist/sap/base/util/fetch.js +8 -0
  200. package/dist/sap/base/util/isEmptyObject.js +34 -0
  201. package/dist/sap/base/util/isPlainObject.js +35 -1
  202. package/dist/sap/base/util/merge.js +57 -0
  203. package/dist/sap/base/util/mixedFetch.js +3 -0
  204. package/dist/sap/base/util/now.js +22 -7
  205. package/dist/sap/base/util/resolveReference.js +3 -0
  206. package/dist/sap/base/util/uid.js +27 -0
  207. package/dist/sap/ui/Device.js +25 -3
  208. package/dist/sap/ui/Global.js +1 -0
  209. package/dist/sap/ui/VersionInfo.js +14 -0
  210. package/dist/sap/ui/base/DataType.js +708 -0
  211. package/dist/sap/ui/base/DesignTime.js +11 -0
  212. package/dist/sap/ui/base/EventProvider.js +21 -0
  213. package/dist/sap/ui/base/Interface.js +50 -6
  214. package/dist/sap/ui/base/Metadata.js +470 -173
  215. package/dist/sap/ui/base/Object.js +287 -27
  216. package/dist/sap/ui/base/OwnStatics.js +6 -0
  217. package/dist/sap/ui/base/SyncPromise.js +98 -0
  218. package/dist/sap/ui/core/AnimationMode.js +42 -0
  219. package/dist/sap/ui/core/CalendarType.js +24 -8
  220. package/dist/sap/ui/core/Configuration.d.ts +17 -0
  221. package/dist/sap/ui/core/Configuration.js +23 -0
  222. package/dist/sap/ui/core/Configuration.js.map +1 -0
  223. package/dist/sap/ui/core/ControlBehavior.js +11 -0
  224. package/dist/sap/ui/core/Core.d.ts +25 -0
  225. package/dist/sap/ui/core/Core.js +7 -32
  226. package/dist/sap/ui/core/Core.js.map +1 -0
  227. package/dist/sap/ui/core/FormatSettings.d.ts +9 -0
  228. package/dist/sap/ui/core/FormatSettings.js +12 -0
  229. package/dist/sap/ui/core/FormatSettings.js.map +1 -0
  230. package/dist/sap/ui/core/Lib.js +41 -0
  231. package/dist/sap/ui/core/Locale.js +190 -116
  232. package/dist/sap/ui/core/LocaleData.js +2837 -2683
  233. package/dist/sap/ui/core/Supportability.js +5 -0
  234. package/dist/sap/ui/core/Theming.js +39 -0
  235. package/dist/sap/ui/core/_UrlResolver.js +11 -0
  236. package/dist/sap/ui/core/date/Buddhist.js +162 -93
  237. package/dist/sap/ui/core/date/CalendarUtils.js +67 -0
  238. package/dist/sap/ui/core/date/CalendarWeekNumbering.js +30 -0
  239. package/dist/sap/ui/core/date/Gregorian.js +25 -10
  240. package/dist/sap/ui/core/date/Islamic.js +298 -185
  241. package/dist/sap/ui/core/date/Japanese.js +212 -117
  242. package/dist/sap/ui/core/date/Persian.js +324 -195
  243. package/dist/sap/ui/core/date/UI5Date.js +1039 -0
  244. package/dist/sap/ui/core/date/UniversalDate.js +1241 -217
  245. package/dist/sap/ui/core/date/_Calendars.js +10 -1
  246. package/dist/sap/ui/core/format/DateFormat.js +3160 -1781
  247. package/dist/sap/ui/core/format/FormatUtils.js +30 -0
  248. package/dist/sap/ui/core/format/NumberFormat.js +3164 -0
  249. package/dist/sap/ui/core/format/TimezoneUtil.js +93 -0
  250. package/dist/sap/ui/core/getCompatibilityVersion.js +7 -0
  251. package/dist/sap/ui/core/theming/ThemeHelper.js +14 -0
  252. package/dist/sap/ui/security/Security.js +12 -0
  253. package/dist/sap/ui/util/XMLHelper.js +11 -0
  254. package/dist/sap/ui/util/_URL.js +1 -0
  255. package/dist/ui5loader-autoconfig.js +1 -0
  256. package/package-scripts.cjs +35 -0
  257. package/package.json +27 -21
  258. package/tsconfig.json +24 -0
  259. package/used-modules.txt +33 -1
  260. package/dist/dates/calculateWeekNumber.js +0 -51
  261. package/package-scripts.js +0 -31
  262. package/src/Assets.js +0 -2
  263. package/src/DateFormat.js +0 -3
  264. package/src/LocaleData.js +0 -3
  265. package/src/dates/CalendarDate.js +0 -203
  266. package/src/dates/calculateWeekNumber.js +0 -51
  267. package/src/locale/getLocaleData.js +0 -27
  268. package/src/sap/base/util/LoaderExtensions.js +0 -7
  269. package/src/sap/ui/core/Core.js +0 -38
  270. /package/{config/.eslintrc.js → .eslintrc.cjs} +0 -0
  271. /package/{src/features/calendar/Buddhist.js → dist/features/calendar/Buddhist.d.ts} +0 -0
  272. /package/{src/features/calendar/Gregorian.js → dist/features/calendar/Gregorian.d.ts} +0 -0
  273. /package/{src/features/calendar/Islamic.js → dist/features/calendar/Islamic.d.ts} +0 -0
  274. /package/{src/features/calendar/Japanese.js → dist/features/calendar/Japanese.d.ts} +0 -0
  275. /package/{src/features/calendar/Persian.js → dist/features/calendar/Persian.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormatSettings.js","sourceRoot":"","sources":["../../../../src/sap/ui/core/FormatSettings.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kDAAkD,CAAC;AAEzE,MAAM,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;AAEzB;;GAEG;AACH,MAAM,cAAc,GAAG;IACtB,eAAe,EAAE,SAAS;IAC1B,mBAAmB,EAAE,OAAO;IAC5B,mBAAmB,EAAE,OAAO;CAC5B,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import getLocale from \"@ui5/webcomponents-base/dist/locale/getLocale.js\";\n\nconst emptyFn = () => {};\n\n/**\n * OpenUI5 FormatSettings shim\n */\nconst FormatSettings = {\n\tgetFormatLocale: getLocale,\n\tgetLegacyDateFormat: emptyFn,\n\tgetCustomLocaleData: emptyFn,\n};\n\nexport default FormatSettings;\n"]}
@@ -0,0 +1,41 @@
1
+ var libs = {};
2
+ var Lib = {
3
+ init: function (cfg) {
4
+ var name = cfg && cfg.name;
5
+ if (name && !libs[name]) {
6
+ libs[name] = {
7
+ name: name,
8
+ getName: function () {
9
+ return name;
10
+ },
11
+ isSettingsEnhanced: function () {
12
+ return false;
13
+ },
14
+ getResourceBundle: function () {
15
+ return {
16
+ getText: function () {
17
+ return "";
18
+ }
19
+ };
20
+ },
21
+ _loadResourceBundle: function () {
22
+ return Promise.resolve();
23
+ }
24
+ };
25
+ }
26
+ return libs[name];
27
+ },
28
+ get: function (name) {
29
+ return libs[name];
30
+ },
31
+ all: function () {
32
+ return Object.assign({}, libs);
33
+ },
34
+ load: function () {
35
+ return Promise.resolve();
36
+ },
37
+ _get: function (name) {
38
+ return libs[name];
39
+ }
40
+ };
41
+ export default Lib;
@@ -1,120 +1,194 @@
1
- import BaseObject from '../base/Object.js';
2
- import assert from '../../base/assert.js';
3
- 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;
4
- var Locale = BaseObject.extend('sap.ui.core.Locale', {
5
- constructor: function (sLocaleId) {
6
- BaseObject.apply(this);
7
- var aResult = rLocale.exec(sLocaleId.replace(/_/g, '-'));
8
- if (aResult === null) {
9
- throw 'The given language \'' + sLocaleId + '\' does not adhere to BCP-47.';
10
- }
11
- this.sLocaleId = sLocaleId;
12
- this.sLanguage = aResult[1] || null;
13
- this.sScript = aResult[2] || null;
14
- this.sRegion = aResult[3] || null;
15
- this.sVariant = aResult[4] && aResult[4].slice(1) || null;
16
- this.sExtension = aResult[5] && aResult[5].slice(1) || null;
17
- this.sPrivateUse = aResult[6] || null;
18
- if (this.sLanguage) {
19
- this.sLanguage = this.sLanguage.toLowerCase();
20
- }
21
- if (this.sScript) {
22
- this.sScript = this.sScript.toLowerCase().replace(/^[a-z]/, function ($) {
23
- return $.toUpperCase();
24
- });
25
- }
26
- if (this.sRegion) {
27
- this.sRegion = this.sRegion.toUpperCase();
28
- }
29
- },
30
- getLanguage: function () {
31
- return this.sLanguage;
32
- },
33
- getScript: function () {
34
- return this.sScript;
35
- },
36
- getRegion: function () {
37
- return this.sRegion;
38
- },
39
- getVariant: function () {
40
- return this.sVariant;
41
- },
42
- getVariantSubtags: function () {
43
- return this.sVariant ? this.sVariant.split('-') : [];
44
- },
45
- getExtension: function () {
46
- return this.sExtension;
47
- },
48
- getExtensionSubtags: function () {
49
- return this.sExtension ? this.sExtension.slice(2).split('-') : [];
50
- },
51
- getPrivateUse: function () {
52
- return this.sPrivateUse;
53
- },
54
- getPrivateUseSubtags: function () {
55
- return this.sPrivateUse ? this.sPrivateUse.slice(2).split('-') : [];
56
- },
57
- hasPrivateUseSubtag: function (sSubtag) {
58
- assert(sSubtag && sSubtag.match(/^[0-9A-Z]{1,8}$/i), 'subtag must be a valid BCP47 private use tag');
59
- return this.getPrivateUseSubtags().indexOf(sSubtag) >= 0;
60
- },
61
- toString: function () {
62
- var r = [this.sLanguage];
63
- if (this.sScript) {
64
- r.push(this.sScript);
65
- }
66
- if (this.sRegion) {
67
- r.push(this.sRegion);
68
- }
69
- if (this.sVariant) {
70
- r.push(this.sVariant);
71
- }
72
- if (this.sExtension) {
73
- r.push(this.sExtension);
74
- }
75
- if (this.sPrivateUse) {
76
- r.push(this.sPrivateUse);
77
- }
78
- return r.join('-');
79
- },
80
- getSAPLogonLanguage: function () {
81
- var sLanguage = this.sLanguage || '', m;
82
- if (sLanguage.indexOf('-') >= 0) {
83
- sLanguage = sLanguage.slice(0, sLanguage.indexOf('-'));
84
- }
85
- sLanguage = M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
86
- if (sLanguage === 'zh') {
87
- if (this.sScript === 'Hant' || !this.sScript && this.sRegion === 'TW') {
88
- sLanguage = 'zf';
89
- }
90
- }
91
- if (this.sPrivateUse && (m = /-(saptrc|sappsd)(?:-|$)/i.exec(this.sPrivateUse))) {
92
- sLanguage = m[1].toLowerCase() === 'saptrc' ? '1Q' : '2Q';
93
- }
94
- return sLanguage.toUpperCase();
1
+ /*!
2
+ * OpenUI5
3
+ * (c) Copyright 2026 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.146.0
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;
95
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 hyphen '-'.
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 hyphens 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 hyphen '-' and one or more extension token, each separated
104
+ * again with a hyphen.
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 hyphens 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 hyphens 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 module:sap/base/i18n/Localization.getSAPLogonLanguage} instead
181
+ * as that class allows to configure an SAP Logon language.
182
+ */
183
+ getSAPLogonLanguage: function () {
184
+ return Localization._getSAPLogonLanguage(this);
185
+ }
96
186
  });
97
- var M_ISO639_OLD_TO_NEW = {
98
- 'iw': 'he',
99
- 'ji': 'yi',
100
- 'in': 'id',
101
- 'sh': 'sr'
102
- };
103
- function getDesigntimePropertyAsArray(sValue) {
104
- var m = /\$([-a-z0-9A-Z._]+)(?::([^$]*))?\$/.exec(sValue);
105
- return m && m[2] ? m[2].split(/,/) : null;
106
- }
107
- var A_RTL_LOCALES = getDesigntimePropertyAsArray('$cldr-rtl-locales:ar,fa,he$') || [];
108
- Locale._cldrLocales = getDesigntimePropertyAsArray('$cldr-locales:ar,ar_EG,ar_SA,bg,br,ca,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,nn,pl,pt,pt_PT,ro,ru,ru_UA,sk,sl,sr,sv,th,tr,uk,vi,zh_CN,zh_HK,zh_SG,zh_TW$');
109
- Locale._coreI18nLocales = getDesigntimePropertyAsArray('$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,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$');
110
- Locale._impliesRTL = function (vLanguage) {
111
- var oLocale = vLanguage instanceof Locale ? vLanguage : new Locale(vLanguage);
112
- var sLanguage = oLocale.getLanguage() || '';
113
- sLanguage = sLanguage && M_ISO639_OLD_TO_NEW[sLanguage] || sLanguage;
114
- var sRegion = oLocale.getRegion() || '';
115
- if (sRegion && A_RTL_LOCALES.indexOf(sLanguage + '_' + sRegion) >= 0) {
116
- return true;
117
- }
118
- return A_RTL_LOCALES.indexOf(sLanguage) >= 0;
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;
119
193
  };
120
194
  export default Locale;