feat: implement comprehensive i18n system with German and English support
- Created type-safe i18n system with TranslationKeys interface - Added German (de) and English (en) translations with 160+ keys - Implemented I18nContext provider and useI18n hook - Added LanguageSwitcher component for language selection - Refactored all major components to use translations: * Home page, StatsDashboard, DramOfTheDay * BottleGrid, EditBottleForm, CameraCapture * BuddyList, SessionList, TastingNoteForm * StatusSwitcher and bottle management features - Implemented locale-aware currency formatting (EUR) - Implemented locale-aware date formatting - Added localStorage persistence for language preference - Added automatic browser language detection - Organized translations into 8 main categories - System is extensible for additional languages
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { updateBottleStatus } from '@/services/update-bottle-status';
|
||||
import { Loader2, Package, Play, CheckCircle, FlaskConical } from 'lucide-react';
|
||||
import { useI18n } from '@/i18n/I18nContext';
|
||||
|
||||
interface StatusSwitcherProps {
|
||||
bottleId: string;
|
||||
@@ -10,6 +11,7 @@ interface StatusSwitcherProps {
|
||||
}
|
||||
|
||||
export default function StatusSwitcher({ bottleId, currentStatus }: StatusSwitcherProps) {
|
||||
const { t } = useI18n();
|
||||
const [status, setStatus] = useState(currentStatus);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
@@ -22,26 +24,26 @@ export default function StatusSwitcher({ bottleId, currentStatus }: StatusSwitch
|
||||
if (result.success) {
|
||||
setStatus(newStatus);
|
||||
} else {
|
||||
alert(result.error || 'Fehler beim Aktualisieren des Status');
|
||||
alert(result.error || t('common.error'));
|
||||
}
|
||||
} catch (err) {
|
||||
alert('Ein unerwarteter Fehler ist aufgetreten');
|
||||
alert(t('common.error'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const options = [
|
||||
{ id: 'sealed', label: 'Versiegelt', icon: Package, color: 'hover:bg-blue-500' },
|
||||
{ id: 'open', label: 'Offen', icon: Play, color: 'hover:bg-amber-500' },
|
||||
{ id: 'sampled', label: 'Sampled', icon: FlaskConical, color: 'hover:bg-purple-500' },
|
||||
{ id: 'empty', label: 'Leer', icon: CheckCircle, color: 'hover:bg-zinc-500' },
|
||||
{ id: 'sealed', label: t('bottle.status.sealed'), icon: Package, color: 'hover:bg-blue-500' },
|
||||
{ id: 'open', label: t('bottle.status.open'), icon: Play, color: 'hover:bg-amber-500' },
|
||||
{ id: 'sampled', label: t('bottle.status.sampled'), icon: FlaskConical, color: 'hover:bg-purple-500' },
|
||||
{ id: 'empty', label: t('bottle.status.empty'), icon: CheckCircle, color: 'hover:bg-zinc-500' },
|
||||
] as const;
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center justify-between">
|
||||
<label className="text-[11px] font-black text-zinc-400 uppercase tracking-widest">Flaschenstatus</label>
|
||||
<label className="text-[11px] font-black text-zinc-400 uppercase tracking-widest">{t('bottle.bottleStatus')}</label>
|
||||
{loading && <Loader2 className="animate-spin text-amber-600" size={14} />}
|
||||
</div>
|
||||
<div className="grid grid-cols-4 gap-2 p-1 bg-zinc-100 dark:bg-zinc-900/50 rounded-2xl border border-zinc-200/50 dark:border-zinc-800/50">
|
||||
|
||||
Reference in New Issue
Block a user