@@ -928,7 +994,7 @@ async function renderHistory(type) {
});
} catch (error) {
- container.innerHTML = `
`;
}
}
@@ -946,7 +1012,7 @@ function capitalize(str) {
function formatDate(dateStr) {
const date = new Date(dateStr);
- return date.toLocaleDateString() + ' ' + date.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'});
+ return date.toLocaleDateString(currentLang) + ' ' + date.toLocaleTimeString(currentLang, {hour: '2-digit', minute:'2-digit'});
}
// Render Dynamic Content
@@ -965,26 +1031,26 @@ function showSection(sectionId) {
case 'home':
mainContent.innerHTML = `
-
Daily Vibe Check 📊
+
${t('home_daily_vibe')}
@@ -996,15 +1062,15 @@ function showSection(sectionId) {
-
Quick Relief 🌿
+
${t('home_quick_relief')}
🌬️
- Breathe
+ ${t('home_breathe')}
🧘
- Relax
+ ${t('home_relax')}
@@ -1015,46 +1081,46 @@ function showSection(sectionId) {
case 'mood':
mainContent.innerHTML = `
-
How are you feeling?
+
${t('mood_title')}
😊
- Joy
+ ${t('mood_joy')}
😌
- Peace
+ ${t('mood_peace')}
⚡
- Energy
+ ${t('mood_energy')}
😰
- Anxiety
+ ${t('mood_anxiety')}
😢
- Sadness
+ ${t('mood_sadness')}
😠
- Anger
+ ${t('mood_anger')}
-
+
- Save Mood
+ ${t('mood_save')}
`;
@@ -1063,36 +1129,36 @@ function showSection(sectionId) {
case 'thoughts':
mainContent.innerHTML = `
-
Thought Record 🧠
+
${t('thought_title')}
- Situation (Who, what, where, when?)
+ ${t('thought_situation')}
- Automatic Thoughts (What went through your mind?)
+ ${t('thought_automatic')}
- Evidence For/Against
+ ${t('thought_evidence')}
- Alternative Thought
+ ${t('thought_alternative')}
- Save Record
+ ${t('thought_save')}
`;
@@ -1102,16 +1168,16 @@ function showSection(sectionId) {
case 'gratitude':
mainContent.innerHTML = `
`;
@@ -1120,29 +1186,28 @@ function showSection(sectionId) {
case 'progress':
mainContent.innerHTML = `
-
Your Progress 📈
+
${t('progress_title')}
-
Weekly Mood 📅
+
${t('progress_weekly')}
-
Recent History 📜
+
${t('progress_history')}
- Moods
- Thoughts
- Gratitude
+ ${t('history_tab_moods')}
+ ${t('history_tab_thoughts')}
+ ${t('history_tab_gratitude')}
-
-
Select a category to view history
+
${t('history_select_prompt')}
`;
@@ -1152,43 +1217,6 @@ function showSection(sectionId) {
}
}
-// Keep existing navigation and UI functions
-function showSection_OLD(sectionId) {
- document.querySelectorAll('.section').forEach(section => {
- section.classList.remove('active');
- });
-
- document.getElementById(sectionId).classList.add('active');
-
- document.querySelectorAll('.nav-item').forEach(item => {
- item.classList.remove('active');
- });
- event.target.closest('.nav-item').classList.add('active');
-
- if (sectionId === 'analytics') {
- loadAnalyticsData();
- }
-}
-
-function showSituationBuilder() {
- showSection('situation-builder');
- document.querySelectorAll('.nav-item').forEach(item => {
- item.classList.remove('active');
- });
-}
-
-function generateExercises() {
- showSection('exercises');
- document.querySelectorAll('.nav-item').forEach(item => {
- item.classList.remove('active');
- });
- document.querySelectorAll('.nav-item')[1].classList.add('active');
-}
-
-function startExercise(type) {
- alert(`Starting ${type} exercise... This would open the exercise interface.`);
-}
-
function quickRelax() {
// Launch the new Guided Grounding Experience
startGuidedRelaxation();
@@ -1198,53 +1226,58 @@ function quickRelax() {
let relaxationState = {
step: 0,
isActive: false,
- steps: [
+ steps: [] // Will be populated dynamically based on language
+};
+
+function getRelaxationSteps() {
+ return [
{
- title: "Sight",
- instruction: "Look around you.",
- sub: "Find 5 things you can see.",
+ title: t('guided_sight_title'),
+ instruction: t('guided_sight_instruction'),
+ sub: t('guided_sight_sub'),
count: 5,
icon: "👁️",
color: "#64B5F6"
},
{
- title: "Touch",
- instruction: "Feel the textures.",
- sub: "Find 4 things you can touch.",
+ title: t('guided_touch_title'),
+ instruction: t('guided_touch_instruction'),
+ sub: t('guided_touch_sub'),
count: 4,
icon: "✋",
color: "#81C784"
},
{
- title: "Sound",
- instruction: "Listen carefully.",
- sub: "Identify 3 sounds you hear.",
+ title: t('guided_sound_title'),
+ instruction: t('guided_sound_instruction'),
+ sub: t('guided_sound_sub'),
count: 3,
icon: "👂",
color: "#FFB74D"
},
{
- title: "Smell",
- instruction: "Breathe in deep.",
- sub: "Notice 2 things you can smell.",
+ title: t('guided_smell_title'),
+ instruction: t('guided_smell_instruction'),
+ sub: t('guided_smell_sub'),
count: 2,
icon: "👃",
color: "#BA68C8"
},
{
- title: "Taste",
- instruction: "Focus on your mouth.",
- sub: "Find 1 thing you can taste.",
+ title: t('guided_taste_title'),
+ instruction: t('guided_taste_instruction'),
+ sub: t('guided_taste_sub'),
count: 1,
icon: "👅",
color: "#E57373"
}
- ]
-};
+ ];
+}
function startGuidedRelaxation() {
relaxationState.step = 0;
relaxationState.isActive = true;
+ relaxationState.steps = getRelaxationSteps();
const overlay = document.createElement('div');
overlay.id = 'guided-relaxation-overlay';
@@ -1280,7 +1313,7 @@ function renderRelaxationStep() {
- I found one
+ ${t('guided_found_btn')}
`;
@@ -1320,13 +1353,13 @@ function finishGuidedRelaxation() {
if (overlay) {
overlay.innerHTML = `
🌟
-
You did great!
-
Feeling more grounded?
+
${t('guided_complete_title')}
+
${t('guided_complete_sub')}
- Complete
+ ${t('guided_complete_btn')}
`;
- speakText("You did great. Feeling more grounded?");
+ speakText(`${t('guided_complete_title')} ${t('guided_complete_sub')}`);
triggerSuccessPing();
}
}
@@ -1353,6 +1386,15 @@ function speakText(text) {
const utterance = new SpeechSynthesisUtterance(text);
utterance.rate = 0.9;
utterance.pitch = 1.0;
+
+ // Map language codes to TTS locales
+ const langMap = {
+ 'en': 'en-US',
+ 'ru': 'ru-RU',
+ 'he': 'he-IL'
+ };
+ utterance.lang = langMap[currentLang] || 'en-US';
+
window.speechSynthesis.speak(utterance);
}
}
@@ -1361,7 +1403,7 @@ function finishRelaxSession(btn) {
btn.closest('.exercise-modal').remove();
exerciseAPI.logSession('relaxation', 120).then(() => {
triggerSuccessPing();
- showSuccessMessage('Relaxation session logged! 🧘');
+ showToast(t('mood_saved_success')); // Reuse success message or create new
updateProgress();
});
}
@@ -1375,23 +1417,20 @@ function emergencyHelp() {
}
function startThoughtRecord() {
- document.getElementById('thought-record-exercise').style.display = 'block';
- document.getElementById('exercises').classList.add('blur-background');
+ showSection('thoughts');
}
function startMindfulness() {
- document.getElementById('mindfulness-exercise').style.display = 'block';
- document.getElementById('exercises').classList.add('blur-background');
+ // Implement or route
}
function startGratitude() {
- document.getElementById('gratitude-exercise').style.display = 'block';
- document.getElementById('exercises').classList.add('blur-background');
+ showSection('gratitude');
}
function closeExercise(exerciseId) {
document.getElementById(exerciseId).style.display = 'none';
- document.getElementById('exercises').classList.remove('blur-background');
+ showSection('home');
}
function addEmotionInput() {
@@ -1399,7 +1438,7 @@ function addEmotionInput() {
const newEmotionInput = document.createElement('div');
newEmotionInput.className = 'emotion-inputs';
newEmotionInput.innerHTML = `
-
+
50
×
@@ -1413,7 +1452,7 @@ function addGratitudeInput() {
const newInput = document.createElement('input');
newInput.type = 'text';
newInput.className = 'form-input gratitude-input';
- newInput.placeholder = 'Something you\'re grateful for...';
+ newInput.placeholder = t('gratitude_placeholder');
gratitudeContainer.appendChild(newInput);
}
@@ -1424,46 +1463,52 @@ let breathingState = {
timer: null
};
-const breathingTechniques = {
- balance: {
- name: 'Balance',
- label: 'Coherent Breathing',
- phases: [
- { name: 'inhale', duration: 5500, label: 'Breathe In', scale: 1.8 },
- { name: 'exhale', duration: 5500, label: 'Breathe Out', scale: 1.0 }
- ]
- },
- relax: {
- name: 'Relax',
- label: '4-7-8 Relief',
- phases: [
- { name: 'inhale', duration: 4000, label: 'Breathe In', scale: 1.8 },
- { name: 'hold', duration: 7000, label: 'Hold', scale: 1.8 },
- { name: 'exhale', duration: 8000, label: 'Breathe Out', scale: 1.0 }
- ]
- },
- focus: {
- name: 'Focus',
- label: 'Box Breathing',
- phases: [
- { name: 'inhale', duration: 4000, label: 'Breathe In', scale: 1.8 },
- { name: 'hold', duration: 4000, label: 'Hold', scale: 1.8 },
- { name: 'exhale', duration: 4000, label: 'Breathe Out', scale: 1.0 },
- { name: 'hold', duration: 4000, label: 'Hold', scale: 1.0 }
- ]
- }
-};
+function getBreathingTechniques() {
+ return {
+ balance: {
+ name: 'Balance',
+ label: t('breath_balance'),
+ phases: [
+ { name: 'inhale', duration: 5500, label: t('breath_in'), scale: 1.8 },
+ { name: 'exhale', duration: 5500, label: t('breath_out'), scale: 1.0 }
+ ]
+ },
+ relax: {
+ name: 'Relax',
+ label: t('breath_relax'),
+ phases: [
+ { name: 'inhale', duration: 4000, label: t('breath_in'), scale: 1.8 },
+ { name: 'hold', duration: 7000, label: t('breath_hold'), scale: 1.8 },
+ { name: 'exhale', duration: 8000, label: t('breath_out'), scale: 1.0 }
+ ]
+ },
+ focus: {
+ name: 'Focus',
+ label: t('breath_focus'),
+ phases: [
+ { name: 'inhale', duration: 4000, label: t('breath_in'), scale: 1.8 },
+ { name: 'hold', duration: 4000, label: t('breath_hold'), scale: 1.8 },
+ { name: 'exhale', duration: 4000, label: t('breath_out'), scale: 1.0 },
+ { name: 'hold', duration: 4000, label: t('breath_hold'), scale: 1.0 }
+ ]
+ }
+ };
+}
function startBreathing() {
// Create immersive overlay
const overlay = document.createElement('div');
overlay.id = 'smart-breathing-overlay';
overlay.className = 'breathing-overlay';
+
+ // Render techniques dynamically
+ const techniques = getBreathingTechniques();
+
overlay.innerHTML = `
- Balance
- Relax
- Focus
+ ${techniques.balance.label}
+ ${techniques.relax.label}
+ ${techniques.focus.label}
@@ -1472,8 +1517,8 @@ function startBreathing() {
-
Get Ready...
-
Sit comfortably
+
${t('breath_ready')}
+
${t('breath_sit')}
@@ -1489,11 +1534,13 @@ function startBreathing() {
function setBreathingTechnique(tech) {
breathingState.technique = tech;
+ const techniques = getBreathingTechniques();
// Update buttons
document.querySelectorAll('.technique-btn').forEach(btn => {
btn.classList.remove('active');
- if(btn.innerText.toLowerCase().includes(breathingTechniques[tech].name.toLowerCase())) {
+ // Match by label content
+ if(btn.textContent === techniques[tech].label) {
btn.classList.add('active');
}
});
@@ -1509,7 +1556,8 @@ function startSmartBreathingLoop() {
const loop = async () => {
if (!breathingState.isActive) return;
- const technique = breathingTechniques[breathingState.technique];
+ const techniques = getBreathingTechniques();
+ const technique = techniques[breathingState.technique];
const phase = technique.phases[currentPhaseIndex];
updateBreathingUI(phase.name, phase.label, phase.duration, phase.scale);
@@ -1574,7 +1622,7 @@ function closeSmartBreathing() {
// Log session
exerciseAPI.logSession('breathing', 60).then(() => {
triggerSuccessPing();
- showSuccessMessage('Breathing session complete! 🌬️');
+ showToast(t('breath_complete'));
updateProgress();
});
}
@@ -1598,4 +1646,25 @@ window.quickRelax = quickRelax;
window.startBreathing = breathingExercise; // Alias for startBreathing in HTML
window.showQuickActionMenu = showQuickActionMenu;
window.navigateTo = showSection; // Alias for navigateTo in HTML
-window.finishRelaxSession = finishRelaxSession;
\ No newline at end of file
+window.finishRelaxSession = finishRelaxSession;
+
+function showLanguageModal() {
+ const menu = document.createElement('div');
+ menu.className = 'exercise-modal';
+ menu.style.display = 'block';
+ menu.innerHTML = `
+
+
Language / שפה / Язык
+
+ English
+ Русский
+ עברית
+
+
+ ${t('close')}
+
+
+ `;
+ document.body.appendChild(menu);
+}
+window.showLanguageModal = showLanguageModal;
diff --git a/MindShift-Windows/src/index.html b/MindShift-Windows/src/index.html
index fd207c6..1d23cda 100644
--- a/MindShift-Windows/src/index.html
+++ b/MindShift-Windows/src/index.html
@@ -54,6 +54,9 @@
MindShift