@ui5/webcomponents-localization 1.2.6 → 1.4.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 +13 -2
- 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,7 +3,7 @@
|
|
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
|
-
|
6
|
+
# [1.4.0](https://github.com/SAP/ui5-webcomponents/compare/v1.3.1...v1.4.0) (2022-05-25)
|
7
7
|
|
8
8
|
**Note:** Version bump only for package @ui5/webcomponents-localization
|
9
9
|
|
@@ -11,7 +11,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
11
11
|
|
12
12
|
|
13
13
|
|
14
|
-
## [1.
|
14
|
+
## [1.3.1](https://github.com/SAP/ui5-webcomponents/compare/v1.3.0...v1.3.1) (2022-04-27)
|
15
15
|
|
16
16
|
**Note:** Version bump only for package @ui5/webcomponents-localization
|
17
17
|
|
@@ -19,6 +19,17 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
19
19
|
|
20
20
|
|
21
21
|
|
22
|
+
# [1.3.0](https://github.com/SAP/ui5-webcomponents/compare/v1.2.4...v1.3.0) (2022-04-19)
|
23
|
+
|
24
|
+
|
25
|
+
### Bug Fixes
|
26
|
+
|
27
|
+
* **localization:** fix js error if "sh" locale set ([#4905](https://github.com/SAP/ui5-webcomponents/issues/4905)) ([979bca2](https://github.com/SAP/ui5-webcomponents/commit/979bca2)), closes [#4904](https://github.com/SAP/ui5-webcomponents/issues/4904)
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
22
33
|
## [1.2.4](https://github.com/SAP/ui5-webcomponents/compare/v1.2.3...v1.2.4) (2022-03-30)
|
23
34
|
|
24
35
|
**Note:** Version bump only for package @ui5/webcomponents-localization
|
@@ -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--;
|