From d6ac16fcefadd23358ed1799524c21b6864079bc Mon Sep 17 00:00:00 2001 From: Madhavi1108 Date: Wed, 17 Jun 2026 11:59:50 +0530 Subject: [PATCH 1/2] feat: complete internationalization and fix language dropdown sync --- AI-chatbot/chatbot.py | 18 +++ Frontend/Analysis/analysis.html | 190 +++++++++++++----------- Frontend/i18n.js | 65 ++++++++ Frontend/index.html | 147 ++++++++++-------- Frontend/locales/en/translation.json | 136 +++++++++++++++++ Frontend/locales/es/translation.json | 136 +++++++++++++++++ Frontend/locales/fr/translation.json | 136 +++++++++++++++++ Frontend/locales/hi/translation.json | 136 +++++++++++++++++ Frontend/locales/kn/translation.json | 136 +++++++++++++++++ Frontend/locales/ml/translation.json | 136 +++++++++++++++++ Frontend/locales/mr/translation.json | 136 +++++++++++++++++ Frontend/locales/ta/translation.json | 136 +++++++++++++++++ Frontend/locales/te/translation.json | 136 +++++++++++++++++ backend/alertsystem.py | 214 +++++++++++++-------------- requirements.txt | 6 + retry_fr.py | 59 ++++++++ translate_frontend.py | 102 +++++++++++++ update_translations.py | 134 +++++++++++++++++ 18 files changed, 1898 insertions(+), 261 deletions(-) create mode 100644 Frontend/i18n.js create mode 100644 Frontend/locales/en/translation.json create mode 100644 Frontend/locales/es/translation.json create mode 100644 Frontend/locales/fr/translation.json create mode 100644 Frontend/locales/hi/translation.json create mode 100644 Frontend/locales/kn/translation.json create mode 100644 Frontend/locales/ml/translation.json create mode 100644 Frontend/locales/mr/translation.json create mode 100644 Frontend/locales/ta/translation.json create mode 100644 Frontend/locales/te/translation.json create mode 100644 requirements.txt create mode 100644 retry_fr.py create mode 100644 translate_frontend.py create mode 100644 update_translations.py diff --git a/AI-chatbot/chatbot.py b/AI-chatbot/chatbot.py index 1a6f1ca..253439d 100644 --- a/AI-chatbot/chatbot.py +++ b/AI-chatbot/chatbot.py @@ -461,6 +461,16 @@ def health_check(): def handle_chatbot_request(data): data = data or {} user_message = str(data.get("message", "")).strip() + lang = data.get("lang", "en") + + try: + if lang and lang != "en": + from deep_translator import GoogleTranslator + user_message = GoogleTranslator(source=lang, target='en').translate(user_message) + except Exception as e: + print("Chatbot translation error (input):", e) + pass + context = data.get('context') # will be None if no analysis has been run yet context_summary = "" @@ -540,6 +550,14 @@ def level(val): if response is None: response = generate_response(user_message, context_summary) + try: + if lang and lang != "en": + from deep_translator import GoogleTranslator + response = GoogleTranslator(source='en', target=lang).translate(response) + except Exception as e: + print("Chatbot translation error (response):", e) + pass + return { "success": True, "response": response diff --git a/Frontend/Analysis/analysis.html b/Frontend/Analysis/analysis.html index f1b0098..42c5a68 100644 --- a/Frontend/Analysis/analysis.html +++ b/Frontend/Analysis/analysis.html @@ -12,7 +12,11 @@ + + + + 🌍 Climate Shield - Live climate risk analysis + Live climate risk analysis +
+ +
-Analyze now +Analyze now
- Weather analysis workspace -

Check flood and heat risk for any location in seconds.

-

+ Weather analysis workspace +

Check flood and heat risk for any location in seconds.

+

Enter a city, state, and country to pull live weather data, summarize risk, and surface alerts in a clean, readable format.

- Live - Weather fetch + Live + Weather fetch
- Fast - Risk scoring + Fast + Risk scoring
- Clear - Alert feedback + Clear + Alert feedback
@@ -97,25 +114,25 @@

Check flood and heat risk for any location in seconds.

- Analysis workflow -

One focused workspace for live weather, risk summaries, and alerts.

-

+ Analysis workflow +

One focused workspace for live weather, risk summaries, and alerts.

+

Use the form below to generate the report. The results panel appears beneath it so the flow reads like a clean report.

- Live fetch - Backend weather response + Live fetch + Backend weather response
- Risk view - Flood and heat signals + Risk view + Flood and heat signals
- Alerts - Clear output for action + Alerts + Clear output for action
@@ -124,8 +141,8 @@

One focused workspace for live weather, risk summaries, and alerts.

-

Climate Risk Analyzer

-

Search a location to generate the live weather and risk summary.

+

Climate Risk Analyzer

+

Search a location to generate the live weather and risk summary.

@@ -133,10 +150,11 @@

Climate Risk Analyzer

Location parameter fields
- + Climate Risk Analyzer
- +
- +
@@ -162,19 +182,19 @@

Climate Risk Analyzer

- - -
-