diff --git a/apps/client/src/services/utils.ts b/apps/client/src/services/utils.ts index 3c83d3e86..0f17bdc79 100644 --- a/apps/client/src/services/utils.ts +++ b/apps/client/src/services/utils.ts @@ -869,6 +869,18 @@ export function getErrorMessage(e: unknown) { } } +/** + * Handles left or right placement of e.g. tooltips in case of right-to-left languages. If the current language is a RTL one, then left and right are swapped. Other directions are unaffected. + * @param placement a string optionally containing a "left" or "right" value. + * @returns a left/right value swapped if needed, or the same as input otherwise. + */ +export function handleRightToLeftPlacement(placement: T) { + if (!glob.isRtl) return placement; + if (placement === "left") return "right"; + if (placement === "right") return "left"; + return placement; +} + export default { reloadFrontendApp, restartDesktopApp, diff --git a/apps/client/src/widgets/buttons/abstract_button.ts b/apps/client/src/widgets/buttons/abstract_button.ts index 7e0923b41..308009fa6 100644 --- a/apps/client/src/widgets/buttons/abstract_button.ts +++ b/apps/client/src/widgets/buttons/abstract_button.ts @@ -1,5 +1,6 @@ import { Tooltip } from "bootstrap"; import NoteContextAwareWidget from "../note_context_aware_widget.js"; +import { handleRightToLeftPlacement } from "../../services/utils.js"; const TPL = /*html*/`