Complete translation implementation for admin interface

- Fixed all hardcoded strings in admin components to use t() function
- Updated BrandingPage.tsx to use translations for watermark settings
- Updated EventsListPage.tsx to use translations for status labels
- Added missing translation keys to both en.json and de.json
- Fixed translations for:
  - System settings (general, storage, categories tabs)
  - Branding page (watermark settings, positions, opacity)
  - Email configuration and templates
  - Event list view (status labels, filters, actions)
  - Event detail view (all sections properly translated)
- Added comprehensive German translations for all new keys
- Ensured consistent translation usage across all admin pages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
This commit is contained in:
2025-07-08 17:41:02 +02:00
co-authored by Claude
parent d594d00227
commit 1bc9b547c7
11 changed files with 491 additions and 356 deletions
+69 -67
View File
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { useParams, useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import {
ArrowLeft,
ExternalLink,
@@ -33,6 +34,7 @@ export const EventDetailsPage: React.FC = () => {
const { id } = useParams<{ id: string }>();
const navigate = useNavigate();
const queryClient = useQueryClient();
const { t } = useTranslation();
// Validate ID parameter
React.useEffect(() => {
@@ -98,11 +100,11 @@ export const EventDetailsPage: React.FC = () => {
mutationFn: (data: any) => eventsService.updateEvent(parseInt(id!), data),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['admin-event', id] });
toast.success('Event updated successfully');
toast.success(t('toast.eventUpdated'));
setIsEditing(false);
},
onError: () => {
toast.error('Failed to update event');
toast.error(t('toast.saveError'));
},
});
@@ -111,10 +113,10 @@ export const EventDetailsPage: React.FC = () => {
mutationFn: () => eventsService.archiveEvent(parseInt(id!)),
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['admin-event', id] });
toast.success('Event archived successfully');
toast.success(t('toast.eventArchived'));
},
onError: () => {
toast.error('Failed to archive event');
toast.error(t('errors.somethingWentWrong'));
},
});
@@ -125,17 +127,17 @@ export const EventDetailsPage: React.FC = () => {
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['admin-event', id] });
toast.success('Expiration extended successfully');
toast.success(t('toast.saveSuccess'));
},
onError: () => {
toast.error('Failed to extend expiration');
toast.error(t('toast.saveError'));
},
});
if (eventLoading || !event) {
return (
<div className="flex items-center justify-center min-h-[400px]">
<Loading size="lg" text="Loading event details..." />
<Loading size="lg" text={t('events.loadingEventDetails')} />
</div>
);
}
@@ -166,9 +168,9 @@ export const EventDetailsPage: React.FC = () => {
await navigator.clipboard.writeText(event.share_link);
setCopiedLink(true);
setTimeout(() => setCopiedLink(false), 2000);
toast.success('Link copied to clipboard');
toast.success(t('toast.linkCopied'));
} catch (err) {
toast.error('Failed to copy link');
toast.error(t('errors.somethingWentWrong'));
}
};
@@ -183,7 +185,7 @@ export const EventDetailsPage: React.FC = () => {
onClick={() => navigate('/admin/events')}
className="mb-4"
>
Back to Events
{t('events.backToEvents')}
</Button>
<div className="flex items-start justify-between">
@@ -198,7 +200,7 @@ export const EventDetailsPage: React.FC = () => {
{event.is_archived && (
<span className="text-neutral-500 flex items-center">
<Archive className="w-4 h-4 mr-1" />
Archived
{t('events.archived')}
</span>
)}
</div>
@@ -215,7 +217,7 @@ export const EventDetailsPage: React.FC = () => {
leftIcon={<X className="w-4 h-4" />}
onClick={() => setIsEditing(false)}
>
Cancel
{t('common.cancel')}
</Button>
<Button
variant="primary"
@@ -224,7 +226,7 @@ export const EventDetailsPage: React.FC = () => {
onClick={handleSaveEdit}
isLoading={updateMutation.isPending}
>
Save Changes
{t('events.saveChanges')}
</Button>
</>
) : (
@@ -234,7 +236,7 @@ export const EventDetailsPage: React.FC = () => {
leftIcon={<Edit2 className="w-4 h-4" />}
onClick={handleStartEdit}
>
Edit
{t('common.edit')}
</Button>
)}
</>
@@ -247,7 +249,7 @@ export const EventDetailsPage: React.FC = () => {
className="inline-flex items-center gap-2 px-3 py-1.5 text-sm font-medium text-primary-600 hover:text-primary-700 border border-primary-600 rounded-lg hover:bg-primary-50 transition-colors"
>
<ExternalLink className="w-4 h-4" />
View Gallery
{t('events.viewGallery')}
</a>
)}
</div>
@@ -262,14 +264,14 @@ export const EventDetailsPage: React.FC = () => {
<div className="flex-1">
<p className={`font-medium ${isExpired ? 'text-red-900' : 'text-orange-900'}`}>
{isExpired
? 'This event has expired'
: `This event expires in ${daysUntilExpiration} ${daysUntilExpiration === 1 ? 'day' : 'days'}`
? t('events.eventExpiredMessage')
: t('events.eventExpiresIn', { days: daysUntilExpiration })
}
</p>
<p className={`text-sm mt-1 ${isExpired ? 'text-red-700' : 'text-orange-700'}`}>
{isExpired
? 'Guests can no longer access the gallery. Consider archiving this event.'
: 'Warning emails have been sent to the host.'}
? t('events.guestsCannotAccessGallery')
: t('events.warningEmailsHaveBeenSent')}
</p>
</div>
{!isExpired && (
@@ -277,12 +279,12 @@ export const EventDetailsPage: React.FC = () => {
variant="outline"
size="sm"
onClick={() => {
if (confirm('Extend expiration by 7 days?')) {
if (confirm(t('events.extendExpiration', { days: 7 }) + '?')) {
extendMutation.mutate(7);
}
}}
>
Extend 7 Days
{t('events.extendSevenDays')}
</Button>
)}
</div>
@@ -300,7 +302,7 @@ export const EventDetailsPage: React.FC = () => {
: 'border-transparent text-neutral-500 hover:text-neutral-700 hover:border-neutral-300'
}`}
>
Overview
{t('events.overview')}
</button>
<button
onClick={() => setActiveTab('photos')}
@@ -311,7 +313,7 @@ export const EventDetailsPage: React.FC = () => {
}`}
>
<Image className="w-4 h-4" />
Photos
{t('events.photos')}
{event.photo_count && event.photo_count > 0 && (
<span className="ml-1 px-2 py-0.5 text-xs font-medium bg-neutral-100 text-neutral-700 rounded-full">
{event.photo_count}
@@ -326,7 +328,7 @@ export const EventDetailsPage: React.FC = () => {
: 'border-transparent text-neutral-500 hover:text-neutral-700 hover:border-neutral-300'
}`}
>
Categories
{t('events.categories')}
</button>
</nav>
</div>
@@ -338,26 +340,26 @@ export const EventDetailsPage: React.FC = () => {
<div className="lg:col-span-2 space-y-6">
{/* Event Information */}
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Event Information</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.eventInformation')}</h2>
{isEditing ? (
<div className="space-y-4">
<div>
<label className="block text-sm font-medium text-neutral-700 mb-1">
Welcome Message
{t('events.welcomeMessageLabel')}
</label>
<textarea
value={editForm.welcome_message}
onChange={(e) => setEditForm(prev => ({ ...prev, welcome_message: e.target.value }))}
className="w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-primary-500 focus:border-primary-500"
rows={3}
placeholder="Add a welcome message for guests..."
placeholder={t('events.welcomeMessage')}
/>
</div>
<div>
<label className="block text-sm font-medium text-neutral-700 mb-1">
Expiration Date
{t('events.expirationDate')}
</label>
<Input
type="date"
@@ -370,39 +372,39 @@ export const EventDetailsPage: React.FC = () => {
) : (
<dl className="space-y-4">
<div>
<dt className="text-sm font-medium text-neutral-500">Welcome Message</dt>
<dt className="text-sm font-medium text-neutral-500">{t('events.welcomeMessageLabel')}</dt>
<dd className="mt-1 text-sm text-neutral-900">
{event.welcome_message || <span className="text-neutral-400">No welcome message set</span>}
{event.welcome_message || <span className="text-neutral-400">{t('events.noWelcomeMessageSet')}</span>}
</dd>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<dt className="text-sm font-medium text-neutral-500">Host Email</dt>
<dt className="text-sm font-medium text-neutral-500">{t('events.hostEmail')}</dt>
<dd className="mt-1 text-sm text-neutral-900">{event.host_email}</dd>
</div>
<div>
<dt className="text-sm font-medium text-neutral-500">Admin Email</dt>
<dt className="text-sm font-medium text-neutral-500">{t('events.adminEmail')}</dt>
<dd className="mt-1 text-sm text-neutral-900">{event.admin_email}</dd>
</div>
</div>
<div className="grid grid-cols-2 gap-4">
<div>
<dt className="text-sm font-medium text-neutral-500">Created</dt>
<dt className="text-sm font-medium text-neutral-500">{t('events.createdOn')}</dt>
<dd className="mt-1 text-sm text-neutral-900">
{format(parseISO(event.created_at), 'MMM d, yyyy')}
</dd>
</div>
<div>
<dt className="text-sm font-medium text-neutral-500">Expires</dt>
<dt className="text-sm font-medium text-neutral-500">{t('events.expires')}</dt>
<dd className="mt-1 text-sm text-neutral-900">
{format(parseISO(event.expires_at), 'MMM d, yyyy')}
{!event.is_archived && daysUntilExpiration > 0 && (
<span className="text-neutral-500 ml-1">
({daysUntilExpiration} {daysUntilExpiration === 1 ? 'day' : 'days'} left)
{t('events.daysLeft', { days: daysUntilExpiration })}
</span>
)}
</dd>
@@ -414,7 +416,7 @@ export const EventDetailsPage: React.FC = () => {
{/* Share Link */}
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Share Link</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.shareLink')}</h2>
<div className="flex items-center gap-2">
<input
@@ -429,12 +431,12 @@ export const EventDetailsPage: React.FC = () => {
leftIcon={copiedLink ? <CheckCircle className="w-4 h-4" /> : <Copy className="w-4 h-4" />}
onClick={handleCopyLink}
>
{copiedLink ? 'Copied!' : 'Copy'}
{copiedLink ? t('events.copied') : t('events.copy')}
</Button>
</div>
<p className="text-sm text-neutral-600 mt-2">
Share this link with guests. They'll need the password to access the gallery.
{t('events.shareWithGuests')}
</p>
{!event.is_archived && (
@@ -446,7 +448,7 @@ export const EventDetailsPage: React.FC = () => {
onClick={() => setShowPasswordReset(true)}
className="w-full justify-center"
>
Reset Gallery Password
{t('events.resetGalleryPassword')}
</Button>
</div>
)}
@@ -454,23 +456,23 @@ export const EventDetailsPage: React.FC = () => {
{/* Photo Statistics */}
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Photo Statistics</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.photoStatistics')}</h2>
<div className="space-y-3">
<div className="flex items-center justify-between py-2 px-3 bg-neutral-50 rounded-lg">
<span className="text-sm text-neutral-600">Total Photos</span>
<span className="text-sm text-neutral-600">{t('events.totalPhotos')}</span>
<span className="text-sm font-medium">{event.photo_count || 0}</span>
</div>
<div className="flex items-center justify-between py-2 px-3 bg-neutral-50 rounded-lg">
<span className="text-sm text-neutral-600">Total Size</span>
<span className="text-sm text-neutral-600">{t('events.totalSize')}</span>
<span className="text-sm font-medium">
{event.total_size ? `${(event.total_size / (1024 * 1024)).toFixed(1)} MB` : '0 MB'}
</span>
</div>
<div className="flex items-center justify-between py-2 px-3 bg-neutral-50 rounded-lg">
<span className="text-sm text-neutral-600">Categories</span>
<span className="text-sm text-neutral-600">{t('events.categories')}</span>
<span className="text-sm font-medium">{categories.length}</span>
</div>
</div>
@@ -483,7 +485,7 @@ export const EventDetailsPage: React.FC = () => {
onClick={() => setActiveTab('photos')}
className="w-full justify-center"
>
Manage Photos
{t('events.managePhotos')}
</Button>
</div>
</Card>
@@ -491,25 +493,25 @@ export const EventDetailsPage: React.FC = () => {
{/* Actions */}
{!event.is_archived && (
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Actions</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.actions')}</h2>
<div className="space-y-3">
<Button
variant="outline"
leftIcon={<Archive className="w-4 h-4" />}
onClick={() => {
if (confirm('Are you sure you want to archive this event? This action cannot be undone.')) {
if (confirm(t('events.archiveConfirm'))) {
archiveMutation.mutate();
}
}}
isLoading={archiveMutation.isPending}
className="w-full justify-center"
>
Archive Event
{t('events.archiveEvent')}
</Button>
<p className="text-xs text-neutral-500 text-center">
Archiving will create a ZIP file of all photos and remove the gallery from public access.
{t('events.archivingInfo')}
</p>
</div>
</Card>
@@ -519,38 +521,38 @@ export const EventDetailsPage: React.FC = () => {
{/* Right Column - Statistics */}
<div className="space-y-6">
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Statistics</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.statistics')}</h2>
{stats ? (
<div className="space-y-4">
<div className="text-center p-4 bg-neutral-50 rounded-lg">
<p className="text-3xl font-bold text-neutral-900">{stats.total_photos}</p>
<p className="text-sm text-neutral-500">Total Photos</p>
<p className="text-sm text-neutral-500">{t('events.totalPhotos')}</p>
</div>
<div className="grid grid-cols-2 gap-3">
<div className="text-center p-3 bg-blue-50 rounded-lg">
<Eye className="w-5 h-5 text-blue-600 mx-auto mb-1" />
<p className="text-xl font-semibold text-neutral-900">{stats.total_views}</p>
<p className="text-xs text-neutral-500">Views</p>
<p className="text-xs text-neutral-500">{t('events.views')}</p>
</div>
<div className="text-center p-3 bg-purple-50 rounded-lg">
<Download className="w-5 h-5 text-purple-600 mx-auto mb-1" />
<p className="text-xl font-semibold text-neutral-900">{stats.total_downloads}</p>
<p className="text-xs text-neutral-500">Downloads</p>
<p className="text-xs text-neutral-500">{t('events.downloads')}</p>
</div>
</div>
<div className="text-center p-3 bg-green-50 rounded-lg">
<Users className="w-5 h-5 text-green-600 mx-auto mb-1" />
<p className="text-xl font-semibold text-neutral-900">{stats.unique_visitors}</p>
<p className="text-xs text-neutral-500">Unique Visitors</p>
<p className="text-xs text-neutral-500">{t('events.uniqueVisitors')}</p>
</div>
</div>
) : (
<div className="text-center py-8 text-neutral-500">
<p>No statistics available yet</p>
<p>{t('events.statisticsNotAvailable')}</p>
</div>
)}
</Card>
@@ -558,11 +560,11 @@ export const EventDetailsPage: React.FC = () => {
{/* Archive Status */}
{event.is_archived && (
<Card padding="md">
<h2 className="text-lg font-semibold text-neutral-900 mb-4">Archive Status</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-4">{t('events.archiveStatusTitle')}</h2>
<div className="space-y-3">
<div>
<p className="text-sm font-medium text-neutral-500">Archived On</p>
<p className="text-sm font-medium text-neutral-500">{t('events.archivedOn')}</p>
<p className="text-sm text-neutral-900">
{event.archived_at && format(parseISO(event.archived_at), 'MMM d, yyyy h:mm a')}
</p>
@@ -575,16 +577,16 @@ export const EventDetailsPage: React.FC = () => {
leftIcon={<Download className="w-4 h-4" />}
onClick={async () => {
try {
toast.info(`Downloading ${event.event_name} archive...`);
toast.info(t('events.downloadingArchive', { name: event.event_name }));
await archiveService.downloadArchive(Number(id), `${event.slug}-archive.zip`);
toast.success('Download started');
toast.success(t('events.downloadStarted'));
} catch (error) {
toast.error('Failed to download archive');
toast.error(t('events.failedToDownloadArchive'));
}
}}
className="w-full justify-center"
>
Download Archive
{t('events.downloadArchive')}
</Button>
)}
</div>
@@ -601,7 +603,7 @@ export const EventDetailsPage: React.FC = () => {
{showPhotoUpload && (
<Card padding="md" className="mb-6">
<div className="flex items-center justify-between mb-4">
<h2 className="text-lg font-semibold text-neutral-900">Upload Photos</h2>
<h2 className="text-lg font-semibold text-neutral-900">{t('events.uploadPhotos')}</h2>
<Button
variant="ghost"
size="sm"
@@ -615,7 +617,7 @@ export const EventDetailsPage: React.FC = () => {
onUploadComplete={() => {
queryClient.invalidateQueries({ queryKey: ['admin-event', id] });
queryClient.invalidateQueries({ queryKey: ['admin-event-photos', id] });
toast.success('Photos uploaded successfully');
toast.success(t('toast.uploadSuccess'));
setShowPhotoUpload(false);
refetchPhotos();
}}
@@ -644,7 +646,7 @@ export const EventDetailsPage: React.FC = () => {
leftIcon={<Upload className="w-4 h-4" />}
onClick={() => setShowPhotoUpload(true)}
>
Upload Photos
{t('events.uploadPhotos')}
</Button>
</div>
)}
@@ -652,7 +654,7 @@ export const EventDetailsPage: React.FC = () => {
{/* Photo Grid */}
{photosLoading ? (
<div className="flex items-center justify-center py-12">
<Loading size="lg" text="Loading photos..." />
<Loading size="lg" text={t('events.loadingPhotos')} />
</div>
) : (
<AdminPhotoGrid
@@ -689,9 +691,9 @@ export const EventDetailsPage: React.FC = () => {
<div>
<Card padding="md">
<div className="mb-6">
<h2 className="text-lg font-semibold text-neutral-900 mb-2">Photo Categories</h2>
<h2 className="text-lg font-semibold text-neutral-900 mb-2">{t('events.photoCategories')}</h2>
<p className="text-sm text-neutral-600">
Organize your photos into categories. Categories help guests navigate and find specific types of photos.
{t('events.organizingPhotosInfo')}
</p>
</div>
@@ -701,7 +703,7 @@ export const EventDetailsPage: React.FC = () => {
<div className="mt-6 p-4 bg-blue-50 rounded-lg">
<p className="text-sm text-blue-800">
<strong>Tip:</strong> Categories are specific to each event. You can create custom categories like "Ceremony", "Reception", "Portraits", etc.
{t('events.categoriesTip')}
</p>
</div>
</Card>