@ui5/webcomponents-localization 1.3.0 → 1.5.0
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.
- package/CHANGELOG.md +24 -0
- package/README.md +5 -6
- package/dist/dates/CalendarDate.js +7 -1
- package/dist/generated/assets/cldr/en_AU.json +1 -1
- package/dist/sap/ui/core/Core.js +2 -0
- package/dist/sap/ui/core/Locale.js +10 -0
- package/dist/sap/ui/core/LocaleData.js +29 -3
- package/dist/sap/ui/core/date/UniversalDate.js +6 -0
- package/dist/sap/ui/core/format/DateFormat.js +362 -167
- package/dist/sap/ui/core/format/TimezoneUtil.js +83 -0
- package/package-scripts.js +1 -6
- package/package.json +5 -5
- package/src/dates/CalendarDate.js +7 -1
- package/src/sap/ui/core/Core.js +2 -0
- package/used-modules.txt +1 -0
- package/hash.txt +0 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,30 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.5.0](https://github.com/SAP/ui5-webcomponents/compare/v1.4.0...v1.5.0) (2022-07-03)
|
7
|
+
|
8
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
# [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
|
15
|
+
|
16
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
23
|
+
|
24
|
+
**Note:** Version bump only for package @ui5/webcomponents-localization
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
6
30
|
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
7
31
|
|
8
32
|
|
package/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-

|
2
2
|
|
3
3
|
# UI5 Web Components - Localization
|
4
4
|
|
5
|
-
[](https://travis-ci.org/SAP/ui5-webcomponents)
|
6
5
|
[](https://www.npmjs.com/package/@ui5/webcomponents)
|
7
6
|
|
8
7
|
Provides date/time and CLDR functionality for the purposes of building UI5 Web Components.
|
@@ -39,16 +38,16 @@ In order to be able to use Buddhist, Islamic, Japanese, or Persian calendar with
|
|
39
38
|
(by setting its `primaryCalendarType` property), you must import one or more of the modules above.
|
40
39
|
|
41
40
|
## Resources
|
42
|
-
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/
|
41
|
+
- [UI5 Web Components - README.md](https://github.com/SAP/ui5-webcomponents/blob/main/README.md)
|
43
42
|
- [UI5 Web Components - Home Page](https://sap.github.io/ui5-webcomponents)
|
44
43
|
- [UI5 Web Components - Playground and API Reference](https://sap.github.io/ui5-webcomponents/playground/)
|
45
44
|
|
46
45
|
## Support
|
47
|
-
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/
|
46
|
+
We welcome all comments, suggestions, questions, and bug reports. Please follow our [Support Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/SUPPORT.md#-content) on how to report an issue, or chat with us in the `#webcomponents` channel of the [OpenUI5 Community Slack](https://join-ui5-slack.herokuapp.com/).
|
48
47
|
|
49
48
|
## Contribute
|
50
|
-
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/
|
49
|
+
Please check our [Contribution Guidelines](https://github.com/SAP/ui5-webcomponents/blob/main/docs/6-contributing/02-conventions-and-guidelines.md).
|
51
50
|
|
52
51
|
## License
|
53
52
|
Copyright (c) 2019 SAP SE or an SAP affiliate company. All rights reserved.
|
54
|
-
This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/
|
53
|
+
This file is licensed under the Apache Software License, Version 2.0 except as noted otherwise in the [LICENSE](https://github.com/SAP/ui5-webcomponents/blob/main/LICENSE.txt) file.
|
@@ -177,7 +177,13 @@ class CalendarDate {
|
|
177
177
|
|
178
178
|
static fromTimestamp(iTimestamp, sCalendarType) {
|
179
179
|
const oCalDate = new CalendarDate(0, 0, 1);
|
180
|
-
|
180
|
+
let oUDate;
|
181
|
+
try {
|
182
|
+
oUDate = UniversalDate.getInstance(new Date(iTimestamp), sCalendarType);
|
183
|
+
} catch (e) {
|
184
|
+
oUDate = new Date(NaN); // UniversalDate.getInstance may now throw an Exception - keep the old behavior
|
185
|
+
}
|
186
|
+
oCalDate._oUDate = oUDate;
|
181
187
|
return oCalDate;
|
182
188
|
}
|
183
189
|
}
|
package/dist/sap/ui/core/Core.js
CHANGED
@@ -2,6 +2,7 @@ import { getLanguage } from "@ui5/webcomponents-base/dist/config/Language.js";
|
|
2
2
|
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js";
|
3
3
|
import getDesigntimePropertyAsArray from "@ui5/webcomponents-base/dist/util/getDesigntimePropertyAsArray.js";
|
4
4
|
import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale.js";
|
5
|
+
import TimezoneUtil from "./format/TimezoneUtil.js";
|
5
6
|
|
6
7
|
const emptyFn = () => {};
|
7
8
|
|
@@ -24,6 +25,7 @@ const Configuration = {
|
|
24
25
|
getSupportedLanguages: () => getDesigntimePropertyAsArray("$core-i18n-locales:,ar,bg,ca,cs,da,de,el,en,es,et,fi,fr,hi,hr,hu,it,iw,ja,ko,lt,lv,nl,no,pl,pt,ro,ru,sh,sk,sl,sv,th,tr,uk,vi,zh_CN,zh_TW$"),
|
25
26
|
getOriginInfo: emptyFn,
|
26
27
|
getFormatSettings: () => FormatSettings,
|
28
|
+
getTimezone: () => TimezoneUtil.getLocalTimezone(),
|
27
29
|
};
|
28
30
|
|
29
31
|
/**
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import BaseObject from '../base/Object.js';
|
2
2
|
import assert from '../../base/assert.js';
|
3
|
+
import CalendarType from './CalendarType.js';
|
3
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;
|
4
5
|
var Locale = BaseObject.extend('sap.ui.core.Locale', {
|
5
6
|
constructor: function (sLocaleId) {
|
@@ -83,6 +84,9 @@ var Locale = BaseObject.extend('sap.ui.core.Locale', {
|
|
83
84
|
return 'ZF';
|
84
85
|
}
|
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'];
|
86
90
|
}
|
87
91
|
});
|
88
92
|
function getPseudoLanguageTag(sPrivateUse) {
|
@@ -114,6 +118,12 @@ function getDesigntimePropertyAsArray(sValue) {
|
|
114
118
|
}
|
115
119
|
var A_RTL_LOCALES = getDesigntimePropertyAsArray('$cldr-rtl-locales:ar,fa,he$') || [];
|
116
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
|
+
};
|
117
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$');
|
118
128
|
Locale._impliesRTL = function (vLanguage) {
|
119
129
|
var oLocale = vLanguage instanceof Locale ? vLanguage : new Locale(vLanguage);
|
@@ -9,7 +9,9 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
9
9
|
constructor: function (oLocale) {
|
10
10
|
this.oLocale = oLocale;
|
11
11
|
BaseObject.apply(this);
|
12
|
-
|
12
|
+
var oDataLoaded = getData(oLocale);
|
13
|
+
this.mData = oDataLoaded.mData;
|
14
|
+
this.sCLDRLocaleId = oDataLoaded.sCLDRLocaleId;
|
13
15
|
},
|
14
16
|
_get: function () {
|
15
17
|
return this._getDeep(this.mData, arguments);
|
@@ -109,6 +111,20 @@ var LocaleData = BaseObject.extend('sap.ui.core.LocaleData', {
|
|
109
111
|
var sDateTimePattern = this.getDateTimePattern(sDateStyle, sCalendarType), sDatePattern = this.getDatePattern(sDateStyle, sCalendarType), sTimePattern = this.getTimePattern(sTimeStyle, sCalendarType);
|
110
112
|
return sDateTimePattern.replace('{0}', sTimePattern).replace('{1}', sDatePattern);
|
111
113
|
},
|
114
|
+
getCombinedDateTimeWithTimezonePattern: function (sDateStyle, sTimeStyle, sCalendarType) {
|
115
|
+
return this.applyTimezonePattern(this.getCombinedDateTimePattern(sDateStyle, sTimeStyle, sCalendarType));
|
116
|
+
},
|
117
|
+
applyTimezonePattern: function (sPattern) {
|
118
|
+
var aPatterns = [sPattern];
|
119
|
+
var aMissingTokens = [{
|
120
|
+
group: 'Timezone',
|
121
|
+
length: 2,
|
122
|
+
field: 'zone',
|
123
|
+
symbol: 'V'
|
124
|
+
}];
|
125
|
+
this._appendItems(aPatterns, aMissingTokens);
|
126
|
+
return aPatterns[0];
|
127
|
+
},
|
112
128
|
getCustomDateTimePattern: function (sSkeleton, sCalendarType) {
|
113
129
|
var oAvailableFormats = this._get(getCLDRCalendarName(sCalendarType), 'dateTimeFormats', 'availableFormats');
|
114
130
|
return this._getFormatPattern(sSkeleton, oAvailableFormats, sCalendarType);
|
@@ -1210,14 +1226,24 @@ function getData(oLocale) {
|
|
1210
1226
|
sLanguage = 'sr_Latn';
|
1211
1227
|
}
|
1212
1228
|
var sId = sLanguage + '_' + sRegion;
|
1229
|
+
var sCLDRLocaleId = sId;
|
1213
1230
|
if (sLanguage && sRegion) {
|
1214
1231
|
mData = getOrLoad(sId);
|
1215
1232
|
}
|
1216
1233
|
if (!mData && sLanguage) {
|
1217
1234
|
mData = getOrLoad(sLanguage);
|
1235
|
+
sCLDRLocaleId = sLanguage;
|
1236
|
+
}
|
1237
|
+
if (!mData) {
|
1238
|
+
mData = getOrLoad('en');
|
1239
|
+
sCLDRLocaleId = 'en';
|
1218
1240
|
}
|
1219
|
-
mLocaleDatas[sId] = mData
|
1220
|
-
|
1241
|
+
mLocaleDatas[sId] = mData;
|
1242
|
+
sCLDRLocaleId = sCLDRLocaleId.replace(/_/g, '-');
|
1243
|
+
return {
|
1244
|
+
mData: mData,
|
1245
|
+
sCLDRLocaleId: sCLDRLocaleId
|
1246
|
+
};
|
1221
1247
|
}
|
1222
1248
|
var CustomLocaleData = LocaleData.extend('sap.ui.core.CustomLocaleData', {
|
1223
1249
|
constructor: function (oLocale) {
|
@@ -42,6 +42,9 @@ UniversalDate.getInstance = function (oDate, sCalendarType) {
|
|
42
42
|
} else if (!oDate) {
|
43
43
|
oDate = new Date();
|
44
44
|
}
|
45
|
+
if (isNaN(oDate.getTime())) {
|
46
|
+
throw new Error('The given date object is invalid');
|
47
|
+
}
|
45
48
|
if (!sCalendarType) {
|
46
49
|
sCalendarType = Core.getConfiguration().getCalendarType();
|
47
50
|
}
|
@@ -202,6 +205,9 @@ UniversalDate.getFirstDateOfWeek = function (sCalendarType, iYear, iWeek) {
|
|
202
205
|
};
|
203
206
|
function getFirstDayOfFirstWeek(clDate, iYear) {
|
204
207
|
var oLocale = Core.getConfiguration().getFormatSettings().getFormatLocale(), oLocaleData = LocaleData.getInstance(oLocale), iMinDays = oLocaleData.getMinimalDaysInFirstWeek(), iFirstDayOfWeek = oLocaleData.getFirstDayOfWeek(), oFirstDay = new clDate(clDate.UTC(iYear, 0, 1)), iDayCount = 7;
|
208
|
+
if (isNaN(oFirstDay.getTime())) {
|
209
|
+
throw new Error('Could not determine the first day of the week, because the date ' + 'object is invalid');
|
210
|
+
}
|
205
211
|
while (oFirstDay.getUTCDay() !== iFirstDayOfWeek) {
|
206
212
|
oFirstDay.setUTCDate(oFirstDay.getUTCDate() - 1);
|
207
213
|
iDayCount--;
|