diff --git a/src/components/modals/binaural/binaural.tsx b/src/components/modals/binaural/binaural.tsx index 70512b4..ced84e2 100644 --- a/src/components/modals/binaural/binaural.tsx +++ b/src/components/modals/binaural/binaural.tsx @@ -1,5 +1,5 @@ import { useEffect, useState, useRef, useCallback } from 'react'; - +import { useTranslation } from 'react-i18next'; import { Modal } from '@/components/modal'; import { Slider } from '@/components/slider'; @@ -14,15 +14,46 @@ interface Preset { baseFrequency: number; beatFrequency: number; name: string; + translationKey: string; } const presets: Preset[] = [ - { baseFrequency: 100, beatFrequency: 2, name: 'Delta (Deep Sleep) 2 Hz' }, - { baseFrequency: 100, beatFrequency: 5, name: 'Theta (Meditation) 5 Hz' }, - { baseFrequency: 100, beatFrequency: 10, name: 'Alpha (Relaxation) 10 Hz' }, - { baseFrequency: 100, beatFrequency: 20, name: 'Beta (Focus) 20 Hz' }, - { baseFrequency: 100, beatFrequency: 40, name: 'Gamma (Cognition) 40 Hz' }, - { baseFrequency: 440, beatFrequency: 10, name: 'Custom' }, + { + baseFrequency: 100, + beatFrequency: 2, + name: 'Delta (Deep Sleep) 2 Hz', + translationKey: 'modals.generators.presets.delta', + }, + { + baseFrequency: 100, + beatFrequency: 5, + name: 'Theta (Meditation) 5 Hz', + translationKey: 'modals.generators.presets.theta', + }, + { + baseFrequency: 100, + beatFrequency: 10, + name: 'Alpha (Relaxation) 10 Hz', + translationKey: 'modals.generators.presets.alpha', + }, + { + baseFrequency: 100, + beatFrequency: 20, + name: 'Beta (Focus) 20 Hz', + translationKey: 'modals.generators.presets.beta', + }, + { + baseFrequency: 100, + beatFrequency: 40, + name: 'Gamma (Cognition) 40 Hz', + translationKey: 'modals.generators.presets.gamma', + }, + { + baseFrequency: 440, + beatFrequency: 10, + name: 'Custom', + translationKey: 'modals.generators.presets.custom', + }, ]; function computeBinauralBeatOscillatorFrequencies( @@ -36,6 +67,7 @@ function computeBinauralBeatOscillatorFrequencies( } export function BinauralModal({ onClose, show }: BinauralProps) { + const { t } = useTranslation(); const [baseFrequency, setBaseFrequency] = useState(440); // Default to A4 note const [beatFrequency, setBeatFrequency] = useState(10); // Default to 10 Hz difference const [volume, setVolume] = useState(0.5); // Default volume at 50% @@ -145,15 +177,14 @@ export function BinauralModal({ onClose, show }: BinauralProps) { }, [selectedPreset]); const handlePresetChange = (e: React.ChangeEvent) => { - const selected = e.target.value; - setSelectedPreset(selected); + const selectedName = e.target.value; + setSelectedPreset(selectedName); - if (selected === 'Custom') { - // Allow user to input custom frequencies + if (selectedName === 'Custom') { return; } - const preset = presets.find(p => p.name === selected); + const preset = presets.find(p => p.name === selectedName); if (preset) { setBaseFrequency(preset.baseFrequency); setBeatFrequency(preset.beatFrequency); @@ -163,17 +194,17 @@ export function BinauralModal({ onClose, show }: BinauralProps) { return (
-

Binaural Beat

-

Binaural beat generator.

+

{t('modals.binaural.title')}

+

{t('modals.binaural.description')}