From b215e64cf434e5264b9d9a824b129835b74fbad0 Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 23 Jul 2024 14:05:11 +0200 Subject: [PATCH] adds rtl for admin ui (#30965) part of: #29974 Signed-off-by: Erik Jan de Wit --- .../admin-ui/src/context/whoami/WhoAmI.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/js/apps/admin-ui/src/context/whoami/WhoAmI.tsx b/js/apps/admin-ui/src/context/whoami/WhoAmI.tsx index 7dac7b999d..17f33782c4 100644 --- a/js/apps/admin-ui/src/context/whoami/WhoAmI.tsx +++ b/js/apps/admin-ui/src/context/whoami/WhoAmI.tsx @@ -11,6 +11,22 @@ import { DEFAULT_LOCALE, i18n } from "../../i18n/i18n"; import { useFetch } from "../../utils/useFetch"; import { useRealm } from "../realm-context/RealmContext"; +// can be replaced with https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTextInfo +const RTL_LOCALES = [ + "ar", + "dv", + "fa", + "ha", + "he", + "iw", + "ji", + "ps", + "sd", + "ug", + "ur", + "yi", +]; + export class WhoAmI { #me?: WhoAmIRepresentation; @@ -22,6 +38,9 @@ export class WhoAmI { console.warn("Error(s) loading locale", this.#me?.locale, error); } }); + if (RTL_LOCALES.includes(this.#me.locale)) { + document.getElementsByTagName("html")[0].setAttribute("dir", "rtl"); + } } }