Implemented locale initialization based on browser settings, added methods to determine locale from URL parameters and Accept-Language header, and updated app initialization to include locale setup.

This commit is contained in:
Torsten Schulz (local)
2025-11-16 13:18:45 +01:00
parent e869abde5d
commit 5288f21e52
12 changed files with 443 additions and 0 deletions

35
docroot/text_de_DE.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Willkommen auf unserer Website deine erste Adresse für Chat, Single-Chat und Bildaustausch</h2>
</header>
<section>
<h3>Warum wir?</h3>
<ol>
<li><strong>Chat:</strong> Tauche ein in unsere dynamischen Chaträume und unterhalte dich mit Menschen aus aller Welt egal ob du lockere Gespräche oder tiefere Verbindungen suchst.</li>
<li><strong>Single-Chat:</strong> Auf der Suche nach jemand Besonderem? Unser Single-Chat bietet dir eine Umgebung, in der Singles gezielt flirten und neue Kontakte knüpfen können.</li>
<li><strong>Bild-Austausch:</strong> Teile Erinnerungen, Momente und Erlebnisse ganz einfach mit unserer Funktion für den Bildaustausch sicher und komfortabel.</li>
<li><strong>Privatsphäre:</strong> Deine Privatsphäre steht an erster Stelle. Wir achten auf Vertraulichkeit und sichere Übertragung deiner Daten.</li>
<li><strong>Anonymität:</strong> Wenn du möchtest, bleibst du anonym ohne auf echte und ehrliche Begegnungen verzichten zu müssen.</li>
</ol>
</section>
<section>
<h3>Jetzt mitmachen!</h3>
<p>Bist du bereit für neue Begegnungen und spannende Gespräche? Melde dich an und werde Teil unserer Community!</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Schön, dass du da bist!</h2>
<p>Wir freuen uns, dass du Teil unserer Community wirst. Ehrlichkeit, Freundlichkeit und Respekt sind unsere wichtigsten Grundsätze.</p>
<p>Sei du selbst und gehe freundlich mit anderen um. Beleidigungen, Belästigungen oder unerlaubte Inhalte tolerieren wir nicht.</p>
<p>Bitte gib keine persönlichen Daten wie Telefonnummer, E-Mail-Adresse oder Wohnanschrift preis.</p>
<p>Lass uns gemeinsam dafür sorgen, dass dies ein sicherer und angenehmer Ort für alle ist. Viel Spaß im Chat!</p>
</main>
</message>
</messages>

35
docroot/text_en_GB.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Welcome to Our Website - Your Premier Destination for Chat, Single Chat, and Image Exchange</h2>
</header>
<section>
<h3>Why Choose Us?</h3>
<ol>
<li><strong>Chat:</strong> Dive into our dynamic chat rooms where you can converse with individuals from around the globe. Whether you're seeking casual conversations or meaningful connections, our chat feature offers a seamless and enjoyable experience.</li>
<li><strong>Single Chat:</strong> Searching for that special someone? Our single chat option provides a tailored environment for singles to mingle, flirt, and potentially find their perfect match. With advanced search filters and interactive features, meeting new people has never been easier.</li>
<li><strong>Image Exchange:</strong> Share memories, moments, and experiences effortlessly with our image exchange feature. Whether it's photos from your latest adventure or snapshots of your everyday life, our platform ensures secure and seamless image sharing.</li>
<li><strong>Privacy:</strong> Your privacy is our top priority. We understand the importance of confidentiality and ensure that all your interactions remain private and secure. With robust privacy settings and encryption protocols, you can chat and exchange images with peace of mind.</li>
<li><strong>Anonymous:</strong> Embrace anonymity with our platform. Whether you prefer to keep your identity discreet or simply enjoy the freedom of expression without constraints, our anonymous feature allows you to engage authentically while maintaining your privacy.</li>
</ol>
</section>
<section>
<h3>Join Us Today!</h3>
<p>Ready to embark on your journey of discovery and connection? Sign up now and experience the ultimate chat, single chat, and image exchange platform. Join our vibrant community and unlock endless possibilities today!</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Welcome aboard!</h2>
<p>We're thrilled to have you join our community. Here, honesty, friendliness, and respect are our guiding principles.</p>
<p>As you explore, remember to be yourself and treat others with kindness. We have zero tolerance for insults, harassment, or unauthorised content.</p>
<p>Please remember not to disclose personal information such as phone numbers, email addresses, residential addresses, etc.</p>
<p>Let's make this a welcoming space where everyone feels valued and safe. Welcome, and enjoy your time with us!</p>
</main>
</message>
</messages>

35
docroot/text_en_US.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Welcome to Our Website - Your Premier Destination for Chat, Single Chat, and Image Exchange</h2>
</header>
<section>
<h3>Why Choose Us?</h3>
<ol>
<li><strong>Chat:</strong> Dive into our dynamic chat rooms where you can converse with individuals from around the globe. Whether you're seeking casual conversations or meaningful connections, our chat feature offers a seamless and enjoyable experience.</li>
<li><strong>Single Chat:</strong> Searching for that special someone? Our single chat option provides a tailored environment for singles to mingle, flirt, and potentially find their perfect match. With advanced search filters and interactive features, meeting new people has never been easier.</li>
<li><strong>Image Exchange:</strong> Share memories, moments, and experiences effortlessly with our image exchange feature. Whether it's photos from your latest adventure or snapshots of your everyday life, our platform ensures secure and seamless image sharing.</li>
<li><strong>Privacy:</strong> Your privacy is our top priority. We understand the importance of confidentiality and ensure that all your interactions remain private and secure. With robust privacy settings and encryption protocols, you can chat and exchange images with peace of mind.</li>
<li><strong>Anonymous:</strong> Embrace anonymity with our platform. Whether you prefer to keep your identity discreet or simply enjoy the freedom of expression without constraints, our anonymous feature allows you to engage authentically while maintaining your privacy.</li>
</ol>
</section>
<section>
<h3>Join Us Today!</h3>
<p>Ready to embark on your journey of discovery and connection? Sign up now and experience the ultimate chat, single chat, and image exchange platform. Join our vibrant community and unlock endless possibilities today!</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Welcome aboard!</h2>
<p>We're thrilled to have you join our community. Here, honesty, friendliness, and respect are our guiding principles.</p>
<p>As you explore, remember to be yourself and treat others with kindness. We have zero tolerance for insults, harassment, or unauthorized content.</p>
<p>Please remember not to disclose personal information such as phone numbers, email addresses, residential addresses, etc.</p>
<p>Let's make this a welcoming space where everyone feels valued and safe. Welcome, and enjoy your time with us!</p>
</main>
</message>
</messages>

35
docroot/text_es_ES.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Bienvenido a nuestro sitio web: tu destino principal para chat, chat para solteros e intercambio de imágenes</h2>
</header>
<section>
<h3>¿Por qué elegirnos?</h3>
<ol>
<li><strong>Chat:</strong> Entra en nuestras salas de chat y conversa con personas de todo el mundo, ya sea para charlas informales o para conexiones más profundas.</li>
<li><strong>Chat para solteros:</strong> ¿Buscas a alguien especial? Nuestro chat para solteros te ofrece un entorno ideal para conocer gente nueva y coquetear.</li>
<li><strong>Intercambio de imágenes:</strong> Comparte tus recuerdos y momentos favoritos de forma sencilla y segura gracias a nuestra función de intercambio de imágenes.</li>
<li><strong>Privacidad:</strong> Tu privacidad es nuestra prioridad. Protegemos tus datos y mantenemos tus conversaciones seguras.</li>
<li><strong>Anonimato:</strong> Si lo prefieres, puedes permanecer en el anonimato sin renunciar a conversaciones auténticas.</li>
</ol>
</section>
<section>
<h3>¡Únete hoy!</h3>
<p>¿Listo para conocer gente nueva y descubrir nuevas conversaciones? Regístrate ahora y forma parte de nuestra comunidad.</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>¡Bienvenido a bordo!</h2>
<p>Nos alegra que te unas a nuestra comunidad. La honestidad, la amabilidad y el respeto son nuestros principios básicos.</p>
<p>Sé tú mismo y trata a los demás con respeto. No toleramos insultos, acoso ni contenido inapropiado.</p>
<p>Por favor, no compartas datos personales como números de teléfono, direcciones de correo electrónico o direcciones postales.</p>
<p>Hagamos de este un lugar seguro y agradable para todos. ¡Disfruta del chat!</p>
</main>
</message>
</messages>

35
docroot/text_fr_FR.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Bienvenue sur notre site votre destination privilégiée pour le chat, le chat privé et léchange dimages</h2>
</header>
<section>
<h3>Pourquoi nous choisir ?</h3>
<ol>
<li><strong>Chat :</strong> Rejoignez nos salons de discussion et parlez avec des personnes du monde entier, que vous recherchiez une conversation détendue ou des échanges plus profonds.</li>
<li><strong>Chat pour célibataires :</strong> À la recherche de quelquun de spécial ? Notre chat pour célibataires offre un environnement idéal pour flirter et faire de nouvelles rencontres.</li>
<li><strong>Échange dimages :</strong> Partagez facilement vos souvenirs et moments importants grâce à notre fonction déchange dimages, de manière sûre et fluide.</li>
<li><strong>Confidentialité :</strong> Votre vie privée est notre priorité. Nous protégeons vos données et sécurisons vos échanges.</li>
<li><strong>Anonymat :</strong> Restez anonyme si vous le souhaitez, tout en profitant déchanges authentiques et sincères.</li>
</ol>
</section>
<section>
<h3>Rejoignez-nous dès aujourdhui !</h3>
<p>Prêt à découvrir de nouvelles personnes et de nouvelles conversations ? Inscrivez-vous maintenant et rejoignez notre communauté dynamique !</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Bienvenue à bord !</h2>
<p>Nous sommes ravis de vous accueillir dans notre communauté. Honnêteté, bienveillance et respect sont nos valeurs essentielles.</p>
<p>Soyez vous-même et traitez les autres avec gentillesse. Nous nacceptons aucune insulte, aucun harcèlement ni contenu inapproprié.</p>
<p>Merci de ne pas divulguer dinformations personnelles comme votre numéro de téléphone, votre adresse e-mail ou votre adresse postale.</p>
<p>Créons ensemble un espace sûr et agréable pour tous. Profitez bien de votre expérience parmi nous !</p>
</main>
</message>
</messages>

35
docroot/text_it_IT.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Benvenuto sul nostro sito la tua destinazione principale per chat, chat per single e condivisione di immagini</h2>
</header>
<section>
<h3>Perché scegliere noi?</h3>
<ol>
<li><strong>Chat:</strong> Entra nelle nostre stanze di chat e parla con persone da tutto il mondo, che tu voglia conversazioni leggere o incontri più profondi.</li>
<li><strong>Chat per single:</strong> Cerchi qualcuno di speciale? La nostra chat per single offre lambiente ideale per fare nuove conoscenze e flirtare.</li>
<li><strong>Condivisione di immagini:</strong> Condividi ricordi e momenti importanti in modo semplice e sicuro grazie alla nostra funzione di scambio immagini.</li>
<li><strong>Privacy:</strong> La tua privacy è la nostra priorità. Proteggiamo i tuoi dati e le tue conversazioni.</li>
<li><strong>Anonimato:</strong> Se lo desideri, puoi rimanere anonimo senza rinunciare a conversazioni autentiche.</li>
</ol>
</section>
<section>
<h3>Unisciti a noi oggi!</h3>
<p>Pronto a conoscere nuove persone e nuove conversazioni? Registrati ora ed entra a far parte della nostra community.</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Benvenuto a bordo!</h2>
<p>Siamo felici che tu entri a far parte della nostra community. Onestà, gentilezza e rispetto sono i nostri principi fondamentali.</p>
<p>Sii te stesso e tratta gli altri con rispetto. Non tolleriamo insulti, molestie o contenuti non autorizzati.</p>
<p>Per favore, non condividere dati personali come numeri di telefono, indirizzi e-mail o indirizzi di casa.</p>
<p>Creiamo insieme uno spazio sicuro e piacevole per tutti. Buon divertimento in chat!</p>
</main>
</message>
</messages>

35
docroot/text_ja_JP.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>ようこそ当サイトへ ― チャット、シングルチャット、画像共有のためのあなたのベストスポットです</h2>
</header>
<section>
<h3>なぜ私たち?</h3>
<ol>
<li><strong>チャット:</strong> 世界中の人とつながるチャットルームで、気軽なおしゃべりから深い会話まで楽しめます。</li>
<li><strong>シングルチャット:</strong> 特別な誰かを探していますか? シングルチャットは、新しい出会いやフレンドリーな交流に最適な場です。</li>
<li><strong>画像共有:</strong> 大切な思い出や日常の瞬間を、簡単かつ安全に画像として共有できます。</li>
<li><strong>プライバシー:</strong> あなたのプライバシーは最優先事項です。会話やデータは丁寧に保護されます。</li>
<li><strong>匿名性:</strong> 必要であれば匿名のまま利用でき、自分らしく安心して交流できます。</li>
</ol>
</section>
<section>
<h3>今すぐ参加しよう!</h3>
<p>新しい出会いや会話を楽しみたい方は、ぜひ今すぐ登録してコミュニティの一員になってください。</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>ようこそ!</h2>
<p>私たちのコミュニティに参加していただき、とてもうれしく思います。正直さ、思いやり、そして敬意が私たちの大切なポリシーです。</p>
<p>自分らしく振る舞い、相手に対しても丁寧な態度を心がけてください。侮辱やハラスメント、不適切なコンテンツは一切許可されません。</p>
<p>電話番号、メールアドレス、自宅住所などの個人情報は決して公開しないでください。</p>
<p>ここを誰にとっても安心して楽しめる場所にしていきましょう。どうぞごゆっくりお楽しみください!</p>
</main>
</message>
</messages>

35
docroot/text_th_TH.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>ยินดีต้อนรับสู่เว็บไซต์ของเรา จุดหมายอันดับหนึ่งสำหรับแชท แชทสำหรับคนโสด และการแบ่งปันรูปภาพ</h2>
</header>
<section>
<h3>ทำไมต้องเรา?</h3>
<ol>
<li><strong>แชท:</strong> เข้าร่วมแชทกับผู้คนจากทั่วโลก จะคุยเล่นสบาย ๆ หรือพูดคุยกันลึก ๆ ก็ได้ตามต้องการ</li>
<li><strong>แชทสำหรับคนโสด:</strong> กำลังมองหาคนพิเศษอยู่หรือเปล่า? แชทสำหรับคนโสดของเราเป็นที่ที่เหมาะสำหรับการทำความรู้จักและจีบกันแบบเป็นกันเอง</li>
<li><strong>แบ่งปันรูปภาพ:</strong> แชร์ความทรงจำและช่วงเวลาสำคัญของคุณได้อย่างง่ายดาย ผ่านฟังก์ชันแบ่งปันรูปภาพที่ปลอดภัย</li>
<li><strong>ความเป็นส่วนตัว:</strong> เราให้ความสำคัญกับความเป็นส่วนตัวของคุณ และปกป้องข้อมูลและบทสนทนาของคุณอย่างดีที่สุด</li>
<li><strong>ไม่เปิดเผยตัวตน:</strong> หากต้องการ คุณสามารถใช้งานแบบไม่เปิดเผยตัวตนได้ พร้อมทั้งยังคงความจริงใจในการพูดคุย</li>
</ol>
</section>
<section>
<h3>มาเป็นส่วนหนึ่งกับเราวันนี้!</h3>
<p>พร้อมที่จะพบปะผู้คนใหม่ ๆ และสนทนาที่น่าสนใจแล้วหรือยัง? สมัครตอนนี้และเข้าร่วมชุมชนของเราได้เลย!</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>ยินดีต้อนรับ!</h2>
<p>เราดีใจมากที่คุณเข้าร่วมชุมชนของเรา ความซื่อสัตย์ ความเป็นมิตร และความเคารพคือหลักสำคัญของเรา</p>
<p>ขอให้คุณเป็นตัวของตัวเอง และปฏิบัติต่อผู้อื่นด้วยความสุภาพ ไม่อนุญาตให้มีการดูถูก ลวนลาม หรือเนื้อหาที่ไม่เหมาะสม</p>
<p>โปรดหลีกเลี่ยงการเปิดเผยข้อมูลส่วนบุคคล เช่น หมายเลขโทรศัพท์ อีเมล หรือที่อยู่บ้าน</p>
<p>มาร่วมกันสร้างพื้นที่ที่ปลอดภัยและน่าอยู่สำหรับทุกคน ขอให้คุณสนุกกับการแชท!</p>
</main>
</message>
</messages>

35
docroot/text_tl_PH.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>Maligayang pagdating sa aming website ang iyong pangunahing destinasyon para sa chat, single chat, at palitan ng mga larawan</h2>
</header>
<section>
<h3>Bakit kami?</h3>
<ol>
<li><strong>Chat:</strong> Sumali sa aming mga chat room at makipag-usap sa mga tao mula sa ibat ibang panig ng mundo, para sa magagaan na usapan o mas malalalim na koneksyon.</li>
<li><strong>Single chat:</strong> Naghahanap ka ba ng isang espesyal na tao? Ang aming single chat ay nagbibigay ng magandang lugar para makipagkilala at mag-flirt.</li>
<li><strong>Palitan ng larawan:</strong> Madaling magbahagi ng mga alaala at mahahalagang sandali gamit ang aming ligtas na image exchange.</li>
<li><strong>Privacy:</strong> Mahalaga sa amin ang iyong privacy. Pinoprotektahan namin ang iyong data at mga pag-uusap.</li>
<li><strong>Pagiging anonymous:</strong> Maaari kang manatiling anonymous kung gusto mo, habang nananatiling totoo at tapat ang iyong mga usapan.</li>
</ol>
</section>
<section>
<h3>Sumali na ngayon!</h3>
<p>Handa ka na bang makilala ang mga bagong tao at bagong kwento? Mag-sign up na at sumali sa aming komunidad.</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>Maligayang pagdating!</h2>
<p>Natutuwa kaming naging bahagi ka ng aming komunidad. Katapatan, kabaitan, at respeto ang aming pangunahing mga prinsipyo.</p>
<p>Maging totoo sa iyong sarili at tratuhin ang iba nang may paggalang. Hindi namin tinatanggap ang pambabastos, pangha-harass, o hindi naaangkop na nilalaman.</p>
<p>Pakiusap, huwag magbahagi ng personal na impormasyon tulad ng numero ng telepono, email address, o tirahan.</p>
<p>Gawin nating ligtas at kaaya-ayang lugar ito para sa lahat. Enjoy sa pakikipag-chat!</p>
</main>
</message>
</messages>

35
docroot/text_zh_CN.xml Normal file
View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<messages>
<message id="welcome">
<main>
<header>
<h2>欢迎来到我们的网站——您进行聊天、单人聊天和图片分享的首选平台</h2>
</header>
<section>
<h3>为什么选择我们?</h3>
<ol>
<li><strong>聊天:</strong> 加入我们的聊天室,与来自世界各地的人实时交流,无论是轻松聊天还是深入沟通。</li>
<li><strong>单人聊天:</strong> 正在寻找特别的那个人吗?我们的单人聊天为你提供认识新朋友和互动的理想环境。</li>
<li><strong>图片分享:</strong> 通过安全便捷的图片分享功能,与他人分享你的回忆和精彩瞬间。</li>
<li><strong>隐私保护:</strong> 我们非常重视你的隐私,并尽力保护你的数据和对话安全。</li>
<li><strong>匿名性:</strong> 如果你愿意,可以保持匿名,同时依然享受真实而真诚的交流。</li>
</ol>
</section>
<section>
<h3>立即加入我们!</h3>
<p>准备好开始新的社交体验了吗?现在就注册,加入我们充满活力的社区吧!</p>
</section>
</main>
</message>
<message id="introduction">
<main>
<h2>欢迎加入!</h2>
<p>我们非常高兴你能加入我们的社区。诚实、友善和尊重是我们最重要的原则。</p>
<p>做真实的自己,并以礼貌和尊重的态度对待他人。我们绝不容忍侮辱、骚扰或不适当的内容。</p>
<p>请不要公开你的个人信息,例如电话号码、电子邮箱地址或家庭住址。</p>
<p>让我们一起打造一个安全、友好、让每个人都能放松和享受的聊天空间。祝你玩得开心!</p>
</main>
</message>
</messages>

View File

@@ -41,12 +41,14 @@
#include <Wt/WCheckBox.h> #include <Wt/WCheckBox.h>
#include <Wt/WTimer.h> #include <Wt/WTimer.h>
#include <Wt/WResource.h> #include <Wt/WResource.h>
#include <Wt/WLocale.h>
App::App(const Wt::WEnvironment &env, Broadcast &server): App::App(const Wt::WEnvironment &env, Broadcast &server):
Wt::WApplication(env), Wt::WApplication(env),
env_(env), env_(env),
server_(server), server_(server),
updateLocationSignal_(this, "updateLocationSignal") { updateLocationSignal_(this, "updateLocationSignal") {
initLocale();
initApp(); initApp();
updateLocation(); updateLocation();
enableUpdates(true); enableUpdates(true);
@@ -66,6 +68,95 @@ void App::setMetaTags() {
addMetaHeader(Wt::MetaHeaderType::Meta, "google-adsense-account", "ca-pub-1104166651501135"); addMetaHeader(Wt::MetaHeaderType::Meta, "google-adsense-account", "ca-pub-1104166651501135");
} }
void App::initLocale() {
auto locale = determineLocaleFromBrowser();
setLocale(locale);
}
Wt::WLocale App::determineLocaleFromBrowser() const {
auto makeLocale = [](const std::string &code) -> Wt::WLocale {
return Wt::WLocale(code);
};
auto mapLanguageTag = [&makeLocale](std::string tag) -> std::string {
// trim
auto begin = tag.find_first_not_of(" \t");
auto end = tag.find_last_not_of(" \t");
if (begin == std::string::npos) {
return "";
}
tag = tag.substr(begin, end - begin + 1);
// nur Sprach-/Regionscode ohne q-Wert
auto semicolonPos = tag.find(';');
if (semicolonPos != std::string::npos) {
tag = tag.substr(0, semicolonPos);
}
std::string lower = tag;
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
// Sprache und Region trennen
std::string lang = lower;
std::string region;
auto dashPos = lower.find('-');
if (dashPos != std::string::npos) {
lang = lower.substr(0, dashPos);
region = lower.substr(dashPos + 1);
}
if (lang == "en") {
if (region == "us") {
return "en_US";
}
// Standard: britisches Englisch
return "en_GB";
} else if (lang == "de") {
return "de_DE";
} else if (lang == "fr") {
return "fr_FR";
} else if (lang == "es") {
return "es_ES";
} else if (lang == "it") {
return "it_IT";
} else if (lang == "tl" || lang == "fil") {
return "tl_PH";
} else if (lang == "ja") {
return "ja_JP";
} else if (lang == "zh") {
return "zh_CN";
} else if (lang == "th") {
return "th_TH";
}
return "";
};
// 1. Expliziter URL-Parameter ?lang=... hat Vorrang (z.B. de, de-DE, en, en-US, fr, es, it, tl, ja, zh, th)
if (const auto *langParam = env_.getParameter("lang")) {
auto localeName = mapLanguageTag(langParam->toUTF8());
if (!localeName.empty()) {
return makeLocale(localeName);
}
}
// 2. Sonst Accept-Language Header des Browsers auswerten
std::string accept = env_.headerValue("Accept-Language");
if (!accept.empty()) {
std::stringstream ss(accept);
std::string part;
while (std::getline(ss, part, ',')) {
auto localeName = mapLanguageTag(part);
if (!localeName.empty()) {
return makeLocale(localeName);
}
}
}
// Fallback: britisches Englisch
return makeLocale("en_GB");
}
void App::initApp() { void App::initApp() {
setMetaTags(); setMetaTags();
setTitle("YP Direct Chat"); setTitle("YP Direct Chat");

View File

@@ -99,6 +99,8 @@ private:
Wt::WTimer *timeoutRemainingTimer_; Wt::WTimer *timeoutRemainingTimer_;
bool isLoggedInAsAdmin {false}; bool isLoggedInAsAdmin {false};
void setMetaTags(); void setMetaTags();
void initLocale();
Wt::WLocale determineLocaleFromBrowser() const;
void initApp(); void initApp();
void reSetUser(); void reSetUser();
Wt::WVBoxLayout *createVerticalLayout(); Wt::WVBoxLayout *createVerticalLayout();