feat(i18n/rtl): apply right to left direction at root level

This commit is contained in:
Elian Doran 2025-10-08 12:08:39 +03:00
parent 034ac59c9a
commit adff36cf22
No known key found for this signature in database

View File

@ -3,6 +3,7 @@ import FlexContainer from "./flex_container.js";
import options from "../../services/options.js";
import type BasicWidget from "../basic_widget.js";
import utils from "../../services/utils.js";
import { LOCALES } from "@triliumnext/commons";
/**
* The root container is the top-most widget/container, from which the entire layout derives.
@ -32,6 +33,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
this.#setMotion(options.is("motionEnabled"));
this.#setShadows(options.is("shadowsEnabled"));
this.#setBackdropEffects(options.is("backdropEffectsEnabled"));
this.#setRightToLeft(options.get("locale"));
return super.render();
}
@ -68,6 +70,11 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
#setBackdropEffects(enabled: boolean) {
document.body.classList.toggle("backdrop-effects-disabled", !enabled);
}
#setRightToLeft(locale: string) {
const correspondingLocale = LOCALES.find(l => l.id === locale);
document.body.dir = correspondingLocale?.rtl ? "rtl" : "ltr";
}
}
function getViewportHeight() {