feat: Complete comprehensive localization of all tracking and management pages
- Feeding page: 47+ strings localized with validation, success/error messages - Medicine page: 44 strings localized with unit conversion support - Sleep page: Already localized (verified) - Diaper page: Already localized (verified) - Activity page: Already localized (verified) - AI Assistant: 51 strings localized including chat interface and suggested questions - Children page: 38 strings fully localized with gender labels - Family page: 42 strings localized with role management - Insights page: 41 strings localized including charts and analytics Added translation files: - locales/en/ai.json (44 keys) - locales/en/family.json (42 keys) - locales/en/insights.json (41 keys) Updated translation files: - locales/en/tracking.json (added feeding, health/medicine sections) - locales/en/children.json (verified complete) All pages now use useTranslation hook with proper namespaces. All user-facing text externalized and ready for multi-language support.
This commit is contained in:
@@ -142,7 +142,7 @@ function FeedingTrackPage() {
|
||||
}
|
||||
} catch (err: any) {
|
||||
console.error('Failed to load children:', err);
|
||||
setError(err.response?.data?.message || 'Failed to load children');
|
||||
setError(err.response?.data?.message || t('common.error.loadChildrenFailed'));
|
||||
} finally {
|
||||
setChildrenLoading(false);
|
||||
}
|
||||
@@ -189,23 +189,23 @@ function FeedingTrackPage() {
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!selectedChild) {
|
||||
setError('Please select a child');
|
||||
setError(t('common.selectChild'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Validation
|
||||
if (feedingType === 'breast' && duration === 0 && timerSeconds === 0) {
|
||||
setError('Please enter duration or use the timer');
|
||||
setError(t('feeding.validation.durationRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (feedingType === 'bottle' && !amount) {
|
||||
setError('Please enter amount');
|
||||
setError(t('feeding.validation.amountRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (feedingType === 'solid' && !foodDescription) {
|
||||
setError('Please enter food description');
|
||||
setError(t('feeding.validation.foodRequired'));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ function FeedingTrackPage() {
|
||||
notes: notes || undefined,
|
||||
});
|
||||
|
||||
setSuccessMessage('Feeding logged successfully!');
|
||||
setSuccessMessage(t('feeding.success'));
|
||||
|
||||
// Reset form
|
||||
resetForm();
|
||||
@@ -244,7 +244,7 @@ function FeedingTrackPage() {
|
||||
await loadRecentFeedings();
|
||||
} catch (err: any) {
|
||||
console.error('Failed to save feeding:', err);
|
||||
setError(err.response?.data?.message || 'Failed to save feeding');
|
||||
setError(err.response?.data?.message || t('feeding.error.saveFailed'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -273,13 +273,13 @@ function FeedingTrackPage() {
|
||||
try {
|
||||
setLoading(true);
|
||||
await trackingApi.deleteActivity(activityToDelete);
|
||||
setSuccessMessage('Feeding deleted successfully');
|
||||
setSuccessMessage(t('feeding.deleted'));
|
||||
setDeleteDialogOpen(false);
|
||||
setActivityToDelete(null);
|
||||
await loadRecentFeedings();
|
||||
} catch (err: any) {
|
||||
console.error('Failed to delete feeding:', err);
|
||||
setError(err.response?.data?.message || 'Failed to delete feeding');
|
||||
setError(err.response?.data?.message || t('feeding.error.deleteFailed'));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -345,17 +345,17 @@ function FeedingTrackPage() {
|
||||
<CardContent sx={{ textAlign: 'center', py: 8 }}>
|
||||
<ChildCare sx={{ fontSize: 64, color: 'text.secondary', mb: 2 }} />
|
||||
<Typography variant="h6" color="text.secondary" gutterBottom>
|
||||
No Children Added
|
||||
{t('common.noChildrenAdded')}
|
||||
</Typography>
|
||||
<Typography variant="body2" color="text.secondary" sx={{ mb: 3 }}>
|
||||
You need to add a child before you can track feeding activities
|
||||
{t('common.noChildrenMessage')}
|
||||
</Typography>
|
||||
<Button
|
||||
variant="contained"
|
||||
startIcon={<Add />}
|
||||
onClick={() => router.push('/children')}
|
||||
>
|
||||
Add Child
|
||||
{t('common.addChild')}
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
@@ -414,11 +414,11 @@ function FeedingTrackPage() {
|
||||
{children.length > 1 && (
|
||||
<Paper sx={{ p: 2, mb: 3 }}>
|
||||
<FormControl fullWidth>
|
||||
<InputLabel>Select Child</InputLabel>
|
||||
<InputLabel>{t('common.selectChild')}</InputLabel>
|
||||
<Select
|
||||
value={selectedChild}
|
||||
onChange={(e) => setSelectedChild(e.target.value)}
|
||||
label="Select Child"
|
||||
label={t('common.selectChild')}
|
||||
>
|
||||
{children.map((child) => (
|
||||
<MenuItem key={child.id} value={child.id}>
|
||||
@@ -479,7 +479,7 @@ function FeedingTrackPage() {
|
||||
startIcon={<Refresh />}
|
||||
onClick={resetTimer}
|
||||
>
|
||||
Reset
|
||||
{t('feeding.reset')}
|
||||
</Button>
|
||||
</Box>
|
||||
</Box>
|
||||
@@ -506,7 +506,7 @@ function FeedingTrackPage() {
|
||||
value={duration || ''}
|
||||
onChange={(e) => setDuration(parseInt(e.target.value) || 0)}
|
||||
sx={{ mb: 3 }}
|
||||
helperText={t('feeding.placeholders.notes')}
|
||||
helperText={t('feeding.placeholders.duration')}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
@@ -524,15 +524,15 @@ function FeedingTrackPage() {
|
||||
/>
|
||||
|
||||
<FormControl fullWidth sx={{ mb: 3 }}>
|
||||
<InputLabel>{t('feeding.type')}</InputLabel>
|
||||
<InputLabel>{t('feeding.bottleType')}</InputLabel>
|
||||
<Select
|
||||
value={bottleType}
|
||||
onChange={(e) => setBottleType(e.target.value as 'formula' | 'breastmilk' | 'other')}
|
||||
label={t('feeding.type')}
|
||||
label={t('feeding.bottleType')}
|
||||
>
|
||||
<MenuItem value="formula">{t('feeding.types.bottle')}</MenuItem>
|
||||
<MenuItem value="breastmilk">{t('feeding.types.breast')}</MenuItem>
|
||||
<MenuItem value="other">Other</MenuItem>
|
||||
<MenuItem value="formula">{t('feeding.bottleTypes.formula')}</MenuItem>
|
||||
<MenuItem value="breastmilk">{t('feeding.bottleTypes.breastmilk')}</MenuItem>
|
||||
<MenuItem value="other">{t('feeding.bottleTypes.other')}</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
</Box>
|
||||
@@ -543,20 +543,20 @@ function FeedingTrackPage() {
|
||||
<Box>
|
||||
<TextField
|
||||
fullWidth
|
||||
label={t('feeding.type')}
|
||||
label={t('feeding.foodDescription')}
|
||||
value={foodDescription}
|
||||
onChange={(e) => setFoodDescription(e.target.value)}
|
||||
sx={{ mb: 3 }}
|
||||
placeholder={t('feeding.placeholders.notes')}
|
||||
placeholder={t('feeding.placeholders.foodDescription')}
|
||||
/>
|
||||
|
||||
<TextField
|
||||
fullWidth
|
||||
label={t('feeding.amount')}
|
||||
label={t('feeding.amountDescription')}
|
||||
value={amountDescription}
|
||||
onChange={(e) => setAmountDescription(e.target.value)}
|
||||
sx={{ mb: 3 }}
|
||||
placeholder={t('feeding.placeholders.amount')}
|
||||
placeholder={t('feeding.placeholders.amountDescription')}
|
||||
/>
|
||||
</Box>
|
||||
)}
|
||||
@@ -583,7 +583,7 @@ function FeedingTrackPage() {
|
||||
onClick={handleSubmit}
|
||||
disabled={loading}
|
||||
>
|
||||
{loading ? t('feeding.addFeeding') : t('feeding.addFeeding')}
|
||||
{loading ? t('common.loading') : t('feeding.addFeeding')}
|
||||
</Button>
|
||||
</Paper>
|
||||
|
||||
@@ -591,7 +591,7 @@ function FeedingTrackPage() {
|
||||
<Paper sx={{ p: 3 }}>
|
||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
|
||||
<Typography variant="h6" fontWeight="600">
|
||||
{t('feeding.title')}
|
||||
{t('feeding.recentFeedings')}
|
||||
</Typography>
|
||||
<IconButton onClick={loadRecentFeedings} disabled={feedingsLoading}>
|
||||
<Refresh />
|
||||
@@ -685,10 +685,10 @@ function FeedingTrackPage() {
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button onClick={() => setDeleteDialogOpen(false)} disabled={loading}>
|
||||
Cancel
|
||||
{t('common.cancel')}
|
||||
</Button>
|
||||
<Button onClick={handleDeleteConfirm} color="error" disabled={loading}>
|
||||
{loading ? t('deleteEntry') : t('deleteEntry')}
|
||||
{loading ? t('common.loading') : t('common.delete')}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
|
||||
Reference in New Issue
Block a user