From 758367ba697ab02cb481c65af8c6d5599fceeb33 Mon Sep 17 00:00:00 2001 From: om Date: Sun, 9 Oct 2022 22:13:21 +0200 Subject: [PATCH 1/2] Detect language based on URL If the outer website is english/danish, the chatapp will use the same language. --- img/chatapp.svg | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/img/chatapp.svg b/img/chatapp.svg index 3c04f47..e7fa152 100644 --- a/img/chatapp.svg +++ b/img/chatapp.svg @@ -68,7 +68,14 @@ const typing_speed = 50; var conversation_count = 0; var current_dialog = null; + var current_language = "da"; +if(location.protocol.startsWith('http')) { // avoid X-origin errors + if(parent.location.href.match(/\ben\b/)) { + current_language = 'en'; + } +} // else: Just stick to danish + var current_dialog_fn = null; /// SVG 1.1 doesn't do proper text splitting into several lines. From 2d13672ddeef188a012e0ba27a7b09b9acc05380 Mon Sep 17 00:00:00 2001 From: om Date: Mon, 10 Oct 2022 07:30:58 +0200 Subject: [PATCH 2/2] Use URLSearchParams for more robust lang selection --- da/index.html | 2 +- en/index.html | 2 +- img/chatapp.svg | 7 +------ 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/da/index.html b/da/index.html index 1a5d9c8..5dc37f0 100644 --- a/da/index.html +++ b/da/index.html @@ -31,7 +31,7 @@ vil være mistænkte for børnemisbrug.
- +

Lær mere om ChatControllen og hvorfor det er en dårlig idé, i vores interaktive ChatControl film ude til venstre.

diff --git a/en/index.html b/en/index.html index d7bf81a..eb3b206 100644 --- a/en/index.html +++ b/en/index.html @@ -32,7 +32,7 @@ will be treated as suspects for child abuse.

- +

Learn more about Chat Control and why it is a bad idea by watching our interactive film on the left. diff --git a/img/chatapp.svg b/img/chatapp.svg index e7fa152..ad287f3 100644 --- a/img/chatapp.svg +++ b/img/chatapp.svg @@ -69,12 +69,7 @@ const typing_speed = 50; var conversation_count = 0; var current_dialog = null; -var current_language = "da"; -if(location.protocol.startsWith('http')) { // avoid X-origin errors - if(parent.location.href.match(/\ben\b/)) { - current_language = 'en'; - } -} // else: Just stick to danish +var current_language = new URLSearchParams(location.search).get('lang') ?? 'da'; var current_dialog_fn = null;