Skip to content

Commit 20e6416

Browse files
committed
Support RTL
1 parent be1df58 commit 20e6416

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

webextensions/common/common.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,24 @@ function nextFrame() {
4040
});
4141
}
4242

43+
const RTL_LANGUAGES = new Set([
44+
'ar',
45+
'he',
46+
'fa',
47+
'ur',
48+
'ps',
49+
'sd',
50+
'ckb',
51+
'prs',
52+
'rhg',
53+
]);
54+
55+
function isRTL() {
56+
const lang = (
57+
navigator.language ||
58+
navigator.userLanguage ||
59+
//(new Intl.DateTimeFormat()).resolvedOptions().locale ||
60+
''
61+
).split('-')[0];
62+
return RTL_LANGUAGES.has(lang);
63+
}

webextensions/options/init.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function actionCheckboxes(params) {
7171
}
7272

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

webextensions/options/options.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
opacity: 0;
1212
}
1313

14+
:root.rtl {
15+
direction: rtl;
16+
}
17+
1418
p, ul {
1519
margin: 0 0 0.5em 0;
1620
padding: 0;

0 commit comments

Comments
 (0)