8000 adds rtl for admin ui by edewit · Pull Request #30965 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Uh oh!

There was an error while loading. Please reload this page.

Merged
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
19 changes: 19 additions & 0 deletions js/apps/admin-ui/src/context/whoami/WhoAmI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the preferred locale is already known when index.ftl is rendered, so you could also handle this at the template level.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not true atm, we could introduce it in the template though, but why would that be better?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are right, we only have this for the account console, but not the admin console. The benefit would be that it would be present on initial render, so the browser knows everything about the locale right away.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but it's almost instant as this will get triggered once the user is logged in

}
}
}

Expand Down
0