rtl-ltr-layout-control
Flip sidebar left/right based on RTL locale.
Files2
View on GitHubSKILL.mdskills/rtl-ltr-layout-control/SKILL.md
GitHubRTL/LTR Layout Control for OpenAmer Desktop
Description
Provides a central mechanism to dynamically flip the main sidebar placement based on the current locale (RTL vs LTR). The sidebar automatically moves to the right when an RTL language (e.g., Hebráisch) is active, while remaining on the left for LTR languages (Deutsch, English, etc.). This ensures consistent user experience across all 187 supported languages without manual configuration.
Trigger
Use when you need to change the sidebar placement based on the current language direction, or when adding new RTL language support.
Steps
Detect RTL status
const isRtl = getRuntimeI18nLocale() !== undefined && isRtlLocale(getRuntimeI18nLocale());isRtlLocalechecks the locale againstRTL_LOCALES(e.g.,['ar','he','fa','ur','dv','ps','yi','ug','ks','sd']).
Compute target placement
const targetFlipped = isRtl ? true : $panesFlipped.get();- If RTL, set
targetFlipped = true; otherwise keep the currenttargetFlippedvalue.
- If RTL, set
Update
$panesFlippedstore$panesFlipped.set(targetFlipped);- This ensures the layout tree subscription reacts and the sidebar flips correctly.
Ensure sidebar toggle respects flipped state
ModifytoggleSidebar(or the relevant UI hook) to read$isSidebarFlipped(derived from$panesFlipped) before applying the state change.Validate
- Switch language to Hebráisch → sidebar should move to the right.
- Switch back to Deutsch → sidebar returns to the left.
- Verify that existing layout presets (e.g.,
quad,focus) still respect the flipped state.
Pitfalls
- RTL locale detection: Ensure
RTL_LOCALESincludes all languages that require right‑hand sidebar placement. Adding a new language requires updating this set. - Store synchronization: The
$panesFlippedstore must be updated after the locale change takes effect; otherwise the sidebar may flip based on stale data. - Sidebar toggle logic: If the toggle logic directly manipulates
$sidebarOpenwithout considering$isSidebarFlipped, the sidebar may appear to stay on the wrong side. Adjust the toggle to read$isSidebarFlippedbefore applying the state change. - Layout presets: Some layout presets (e.g.,
quad,focus) may override pane placement. Verify thatmirrorLayoutTreeandsetSplitWeightsrespect$panesFlipped.
References
src/store/layout.ts–$panesFlippedstore and subscription logic.src/i18n/context.tsx–getRuntimeI18nLocaleandRTL_LOCALESdefinition.src/components/pane-shell/tree/store.ts–mirrorLayoutTreeandsetSplitWeightsutilities.src/components/pane-shell/tree/model.ts–splitandmirrorTreeHorizontaloperations.references/rtl-ltr-layout-control.md– detailed implementation notes, pitfalls, and testing checklist.