Skip to content

Commit

Permalink
Support RTL
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jan 10, 2025
1 parent 3daa3d7 commit f577d45
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 5 deletions.
22 changes: 22 additions & 0 deletions common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,25 @@ export function collectAncestors(tabs) {
}
return ancestorsOf;
}

const RTL_LANGUAGES = new Set([
'ar',
'he',
'fa',
'ur',
'ps',
'sd',
'ckb',
'prs',
'rhg',
]);

export function isRTL() {
const lang = (
navigator.language ||
navigator.userLanguage ||
//(new Intl.DateTimeFormat()).resolvedOptions().locale ||
''
).split('-')[0];
return RTL_LANGUAGES.has(lang);
}
4 changes: 3 additions & 1 deletion options/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

import {
log,
configs
configs,
isRTL,
} from '/common/common.js';
import * as Permissions from '/common/permissions.js';
import Options from '/extlib/Options.js';
Expand All @@ -32,6 +33,7 @@ function onConfigChanged(key) {

configs.$addObserver(onConfigChanged);
window.addEventListener('DOMContentLoaded', async () => {
document.documentElement.classList.toggle('rtl', isRTL());
await configs.$loaded;

gFormatRows = document.querySelector('#copyToClipboardFormatsRows');
Expand Down
4 changes: 4 additions & 0 deletions options/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
opacity: 0;
}

:root.rtl {
direction: rtl;
}

p, ul {
margin: 0 0 0.5em 0;
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion submodules/webextensions-lib-configs
2 changes: 1 addition & 1 deletion submodules/webextensions-lib-l10n
2 changes: 1 addition & 1 deletion submodules/webextensions-lib-options

0 comments on commit f577d45

Please sign in to comment.