aboutsummaryrefslogtreecommitdiff
path: root/static
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-06-07 22:45:06 -0400
committerBobby <[email protected]>2023-06-07 22:45:06 -0400
commit2f3508ea23a9ce470fd6570235aa63e90e50df7f (patch)
treeda55a52fb4e953015b522377d21f0a4bcdfd58be /static
parent3b2f2278b14566e06209ffc4117e17221aedfe0a (diff)
downloadthatcomputerscientist-2f3508ea23a9ce470fd6570235aa63e90e50df7f.tar.xz
thatcomputerscientist-2f3508ea23a9ce470fd6570235aa63e90e50df7f.zip
Remove Middleware and Handle Translate Client Side
Diffstat (limited to 'static')
-rw-r--r--static/css/styles.css5
-rw-r--r--static/js/tl.js43
2 files changed, 48 insertions, 0 deletions
diff --git a/static/css/styles.css b/static/css/styles.css
index 061c7deb..491780c7 100644
--- a/static/css/styles.css
+++ b/static/css/styles.css
@@ -3,6 +3,7 @@
@import url('https://fonts.googleapis.com/css2?family=Mali:ital,wght@0,400;0,700;1,400;1,700&display=swap');
body {
+ position: unset !important;
width: 100%;
background: black;
font-size: 11px;
@@ -13,6 +14,10 @@ body {
box-sizing: border-box;
}
+.skiptranslate {
+ display: none !important;
+}
+
input,
textarea {
font-family: 'Mali', sans-serif !important;
diff --git a/static/js/tl.js b/static/js/tl.js
new file mode 100644
index 00000000..98bd9529
--- /dev/null
+++ b/static/js/tl.js
@@ -0,0 +1,43 @@
+// Google Translate (Only English and Japanese)
+function googleTranslateElementInit() {
+ new google.translate.TranslateElement(
+ {
+ pageLanguage: "en",
+ includedLanguages: "ja",
+ },
+ "google_translate_element"
+ );
+}
+
+var currentLang = document.cookie.replace(
+ /(?:(?:^|.*;\s*)lang\s*\=\s*([^;]*).*$)|^.*$/,
+ "$1"
+);
+
+console.log("currentLang: " + currentLang);
+
+if (currentLang == "ja") {
+ triggerTranslation("ja");
+} else {
+ triggerTranslation("en");
+}
+
+function triggerTranslation(language) {
+ var selectEl = document.querySelector("select.goog-te-combo");
+ if (!selectEl) {
+ setTimeout(function () {
+ triggerTranslation(language);
+ }, 100);
+ } else if (!selectEl.options || selectEl.options.length === 0) {
+ setTimeout(function () {
+ triggerTranslation(language);
+ }, 100);
+ } else {
+ console.log("triggering translation");
+ console.log(selectEl.options, selectEl.options.length); // HTMLOptionsCollection with options
+
+ // Continue with the logic for handling the available options
+ selectEl.value = language; // Change the value of the select element
+ selectEl.dispatchEvent(new Event("change")); // Trigger change event
+ }
+}