Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/base/src/asset-registries/LocaleData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { fetchJsonOnce } from "../util/FetchHelper.js";
import { attachLanguageChange } from "../locale/languageChange.js";
import getLocale from "../locale/getLocale.js";
import { getFeature } from "../FeaturesRegistry.js";
import { DEFAULT_LOCALE, SUPPORTED_LOCALES } from "../generated/AssetParameters.js";
import { getEffectiveAssetPath } from "../util/EffectiveAssetPath.js";
Expand Down Expand Up @@ -116,6 +118,13 @@ const _registerMappingFunction = mappingFn => {
cldrMappingFn = mappingFn;
};

// When the language changes dynamically (the user calls setLanguage),
// re-fetch the required CDRD data.
attachLanguageChange(() => {
const locale = getLocale();
return fetchCldr(locale.getLanguage(), locale.getRegion(), locale.getScript());
});

export {
fetchCldr,
registerCldr,
Expand Down
24 changes: 17 additions & 7 deletions packages/main/test/pages/RTL.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<ui5-checkbox text="This checkbox however defines dir=ltr" dir="ltr"></ui5-checkbox>
</section>


<ui5-date-picker></ui5-date-picker>
<script>

// Utility function to change RTL and apply the changes
Expand All @@ -84,6 +84,18 @@
window['sap-ui-webcomponents-bundle'].applyDirection();
}

function setDirByLang(lang) {
if (lang === "he" || lang === "ar") {
setDir("rtl");
} else {
setDir("ltr");
}
}

function setLanguage(lang) {
return window['sap-ui-webcomponents-bundle'].configuration.setLanguage(lang);
}

document.getElementById("sw").addEventListener("click", function(e) {
if (e.target.checked) {
setDir("rtl");
Expand All @@ -94,12 +106,10 @@

document.getElementById("tb").addEventListener("selection-change", function(e) {
var lang = e.detail.selectedButton.textContent.toLowerCase();
if (lang === "he" || lang === "ar") {
setDir("rtl");
} else {
setDir("ltr");
}
window['sap-ui-webcomponents-bundle'].configuration.setLanguage(lang);

setLanguage(lang).then(function() {
setDirByLang(lang);
});
});
</script>

Expand Down