[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [pluggable-transports/snowflake-webext] 02/02: const for rtl langs + function to set lang direction
This is an automated email from the git hooks/post-receive script.
cohosh pushed a commit to branch main
in repository pluggable-transports/snowflake-webext.
commit 1fd388f2275652fffca86877466c1cd0eed5c096
Author: luciole <luciole@xxxxxxxxxxxx>
AuthorDate: Fri Nov 4 12:01:49 2022 +0100
const for rtl langs + function to set lang direction
---
static/index.js | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/static/index.js b/static/index.js
index 02f04a8..53cc192 100644
--- a/static/index.js
+++ b/static/index.js
@@ -1,4 +1,5 @@
/* global availableLangs */
+const RTL_LANGS = new Set(["ar", "fa", "he", "ur"]);
class Messages {
constructor(json) {
@@ -39,6 +40,14 @@ var getLang = function() {
return defaultLang;
};
+var set_lang_direction = function(l) {
+ if (RTL_LANGS.has(l)) {
+ document.documentElement.dir = "rtl";
+ } else {
+ document.documentElement.dir = "ltr";
+ }
+};
+
var fill = function(n, func) {
switch(n.nodeType) {
case 1: // Node.ELEMENT_NODE
@@ -65,11 +74,7 @@ fetch(`./_locales/${gotLang}/website.json`)
.then((json) => {
var language = document.getElementById('language-switcher');
var lang = `${gotLang}`;
- if (lang == "ar" || lang == "fa" || lang == "he" || lang == "ur") {
- document.documentElement.dir = "rtl";
- } else {
- document.documentElement.dir = "ltr";
- }
+ set_lang_direction(lang);
language.innerText = `${availableLangs.get(lang)} (${lang})`;
var messages = new Messages(json);
fill(document.body, (m) => {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits