File tree 11 files changed +49
-20
lines changed
11 files changed +49
-20
lines changed Original file line number Diff line number Diff line change 1
1
import "../shims/Core-shim.js" ;
2
- import { getLanguage } from "../LocaleProvider .js" ;
2
+ import getLocale from "../locale/getLocale .js" ;
3
3
import { fetchJsonOnce } from "../util/FetchHelper.js" ;
4
4
import { normalizeLocale , nextFallbackLocale } from "../util/normalizeLocale.js" ;
5
5
@@ -48,7 +48,7 @@ const fetchI18nBundle = async packageName => {
48
48
return ;
49
49
}
50
50
51
- const language = getLanguage ( ) ;
51
+ const language = getLocale ( ) . getLanguage ( ) ;
52
52
53
53
let localeId = normalizeLocale ( language ) ;
54
54
while ( ! bundlesForPackage [ localeId ] ) {
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
import Locale from "./Locale.js" ;
2
- import detectNavigatorLanguage from "./util/detectNavigatorLanguage.js" ;
3
- import { getLanguage as getConfigLanguage } from "./config/Language.js" ;
2
+ import detectNavigatorLanguage from ".. /util/detectNavigatorLanguage.js" ;
3
+ import { getLanguage as getConfigLanguage } from ".. /config/Language.js" ;
4
4
5
5
const convertToLocaleOrNull = lang => {
6
6
try {
@@ -13,22 +13,19 @@ const convertToLocaleOrNull = lang => {
13
13
} ;
14
14
15
15
/**
16
- * Returns the locale based on the configured language Configuration#getLanguage
16
+ * Returns the locale based on the parameter or configured language Configuration#getLanguage
17
17
* If no language has been configured - a new locale based on browser language is returned
18
18
*/
19
- const getLocale = ( ) => {
19
+ const getLocale = lang => {
20
+ if ( lang ) {
21
+ return convertToLocaleOrNull ( lang ) ;
22
+ }
23
+
20
24
if ( getConfigLanguage ( ) ) {
21
25
return new Locale ( getConfigLanguage ( ) ) ;
22
26
}
23
27
24
28
return convertToLocaleOrNull ( detectNavigatorLanguage ( ) ) ;
25
29
} ;
26
30
27
- /**
28
- * Returns the language of #getLocale return value
29
- */
30
- const getLanguage = ( ) => {
31
- return getLocale ( ) . sLanguage ;
32
- } ;
33
-
34
- export { getLocale , getLanguage } ;
31
+ export default getLocale ;
Original file line number Diff line number Diff line change
1
+ import LocaleData from "@ui5/webcomponents-utils/dist/sap/ui/core/LocaleData.js" ;
2
+ import getLocale from "./getLocale.js" ;
3
+ import { fetchCldr } from "../asset-registries/LocaleData.js" ;
4
+
5
+ const instances = new Map ( ) ;
6
+
7
+ /**
8
+ * Fetches and returns а LocaleData object for the required locale
9
+ * For more information on this object's API, please see:
10
+ * https://ui5.sap.com/#/api/sap.ui.core.LocaleData
11
+ *
12
+ * @param lang - if left empty, will use the configured/current locale
13
+ * @returns {LocaleData }
14
+ */
15
+ const getLocaleData = async lang => {
16
+ const locale = getLocale ( lang ) ;
17
+ const localeLang = locale . getLanguage ( ) ;
18
+
19
+ if ( ! instances . has ( localeLang ) ) {
20
+ await fetchCldr ( locale . getLanguage ( ) , locale . getRegion ( ) , locale . getScript ( ) ) ;
21
+ instances . set ( localeLang , LocaleData . getInstance ( locale ) ) ;
22
+ }
23
+
24
+ return instances . get ( localeLang ) ;
25
+ } ;
26
+
27
+ export default getLocaleData ;
Original file line number Diff line number Diff line change 1
1
import { inject as injectCore } from "@ui5/webcomponents-utils/dist/sap/ui/core/Core.js" ;
2
- import { getLocale } from "../LocaleProvider .js" ;
2
+ import getLocale from "../locale/getLocale .js" ;
3
3
import { getLanguage } from "../config/Language.js" ;
4
4
import { getCalendarType } from "../config/CalendarType.js" ;
5
5
import getDesigntimePropertyAsArray from "../util/getDesigntimePropertyAsArray.js" ;
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ import "@ui5/webcomponents-base/dist/features/calendar/Persian.js";
12
12
// ESM bundle targets Edge + browsers with native support
13
13
import "@ui5/webcomponents-base/dist/features/browsersupport/Edge.js" ;
14
14
15
+ // CLDR
16
+ import getLocaleData from "@ui5/webcomponents-base/dist/locale/getLocaleData.js" ;
17
+
15
18
// Icons
16
19
import "@ui5/webcomponents-icons/dist/Assets.js" ;
17
20
@@ -69,6 +72,7 @@ import CustomListItem from "./dist/CustomListItem.js";
69
72
import GroupHeaderListItem from "./dist/GroupHeaderListItem.js" ;
70
73
71
74
75
+
72
76
// used in test pages
73
77
import RenderScheduler from "@ui5/webcomponents-base/dist/RenderScheduler.js" ;
74
78
window . RenderScheduler = RenderScheduler ;
@@ -93,4 +97,5 @@ window["sap-ui-webcomponents-bundle"] = {
93
97
getFirstDayOfWeek,
94
98
} ,
95
99
getIconNames,
100
+ getLocaleData,
96
101
} ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
3
3
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
4
4
import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js" ;
5
5
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js" ;
6
- import { getLocale } from "@ui5/webcomponents-base/dist/LocaleProvider .js" ;
6
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale .js" ;
7
7
import DateFormat from "@ui5/webcomponents-utils/dist/sap/ui/core/format/DateFormat.js" ;
8
8
import LocaleData from "@ui5/webcomponents-utils/dist/sap/ui/core/LocaleData.js" ;
9
9
import CalendarDate from "@ui5/webcomponents-base/dist/dates/CalendarDate.js" ;
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
3
3
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
4
4
import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js" ;
5
5
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js" ;
6
- import { getLocale } from "@ui5/webcomponents-base/dist/LocaleProvider .js" ;
6
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale .js" ;
7
7
import { getFeature } from "@ui5/webcomponents-base/dist/FeaturesRegistry.js" ;
8
8
import LocaleData from "@ui5/webcomponents-utils/dist/sap/ui/core/LocaleData.js" ;
9
9
import DateFormat from "@ui5/webcomponents-utils/dist/sap/ui/core/format/DateFormat.js" ;
Original file line number Diff line number Diff line change 1
1
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js" ;
2
2
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js" ;
3
3
import { fetchCldr } from "@ui5/webcomponents-base/dist/asset-registries/LocaleData.js" ;
4
- import { getLocale } from "@ui5/webcomponents-base/dist/LocaleProvider .js" ;
4
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale .js" ;
5
5
import { getFirstDayOfWeek } from "@ui5/webcomponents-base/dist/config/FormatSettings.js" ;
6
6
import DateFormat from "@ui5/webcomponents-utils/dist/sap/ui/core/format/DateFormat.js" ;
7
7
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js" ;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation
6
6
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
7
7
import { isSpace , isEnter } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js" ;
8
8
import LocaleData from "@ui5/webcomponents-utils/dist/sap/ui/core/LocaleData.js" ;
9
- import { getLocale } from "@ui5/webcomponents-base/dist/LocaleProvider .js" ;
9
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale .js" ;
10
10
import CalendarType from "@ui5/webcomponents-base/dist/dates/CalendarType.js" ;
11
11
import CalendarDate from "@ui5/webcomponents-base/dist/dates/CalendarDate.js" ;
12
12
import ItemNavigationBehavior from "@ui5/webcomponents-base/dist/types/ItemNavigationBehavior.js" ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import LocaleData from "@ui5/webcomponents-utils/dist/sap/ui/core/LocaleData.js"
4
4
import { getCalendarType } from "@ui5/webcomponents-base/dist/config/CalendarType.js" ;
5
5
import { isEnter , isSpace } from "@ui5/webcomponents-base/dist/events/PseudoEvents.js" ;
6
6
import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation.js" ;
7
- import { getLocale } from "@ui5/webcomponents-base/dist/LocaleProvider .js" ;
7
+ import getLocale from "@ui5/webcomponents-base/dist/locale/getLocale .js" ;
8
8
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js" ;
9
9
import DateFormat from "@ui5/webcomponents-utils/dist/sap/ui/core/format/DateFormat.js" ;
10
10
import CalendarType from "@ui5/webcomponents-base/dist/dates/CalendarType.js" ;
You can’t perform that action at this time.
0 commit comments