diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f1c9a76..be2ba2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Changed +- Expanded French translations across the diary, foods, goals, statistics and wellness screens, including desktop panels and dynamic metric labels. - **API tokens for every user** ([#245](https://github.com/TraceApps/nutritrace/pull/245)). Anyone signed in can create and revoke their own API tokens in Settings > API Tokens, so connecting your own MCP client no longer needs an admin account. Webhooks stay admin-only. Thanks @tarzan77cz. ### Fixed diff --git a/public/offline.html b/public/offline.html index aecede52..c110f5c7 100644 --- a/public/offline.html +++ b/public/offline.html @@ -66,10 +66,19 @@
📡
-

Can't reach your server

-

NutriTrace couldn't connect. Make sure your server is running and try again.

- +

Can't reach your server

+

NutriTrace couldn't connect. Make sure your server is running and try again.

+
NutriTrace · Trace Every Bite
+ diff --git a/scripts/i18n-check.cjs b/scripts/i18n-check.cjs index 74bb146d..82ab6cdf 100644 --- a/scripts/i18n-check.cjs +++ b/scripts/i18n-check.cjs @@ -203,7 +203,14 @@ function main() { } const { direct, indirect } = collectKeyRefs(topLevel); - const unresolved = [...direct.values(), ...indirect.values()].filter(r => !enKeys.has(r.key)); + // Indirect literals can name an existing namespace passed to a helper + // (e.g. tr('statistics_page.desktop', id)). Only direct $_() arguments + // must point to a leaf string. + const hasNamespace = key => key.split('.').reduce((value, part) => value?.[part], en) != null; + const unresolved = [ + ...[...direct.values()].filter(r => !enKeys.has(r.key)), + ...[...indirect.values()].filter(r => !enKeys.has(r.key) && !hasNamespace(r.key)), + ]; if (unresolved.length) { errors.push(`${unresolved.length} code-referenced key(s) missing from ${SOURCE_FILE}`); console.log(` ✗ keys referenced in code but absent from ${SOURCE_FILE}:`); diff --git a/src/App.svelte b/src/App.svelte index ecd9afde..60c9076c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -459,7 +459,7 @@ } else { lastBack = now; import('./stores/toast.js').then(({ showSuccess }) => { - showSuccess('Tap again to exit'); + showSuccess($_('feedback.general.tap_again_to_exit')); }); } } @@ -541,7 +541,7 @@ const { isShortcutHash } = await import('./lib/app-shortcut.js'); const shortcutWaiting = isShortcutHash(window.location.hash); setAuthToken(token); - import('./stores/toast.js').then(({ showSuccess }) => showSuccess('Signed in')); + import('./stores/toast.js').then(({ showSuccess }) => showSuccess($_('common.signed_in'))); await loadAuthState(); // Re-evaluate the NativeSetup gate. Without this the user // completes OIDC from NativeSetup, gets a valid token, and @@ -572,7 +572,7 @@ params.get('withings') ? 'withings' : 'garmin'; const label = provider === 'google_health' ? 'Google Health' : provider.charAt(0).toUpperCase() + provider.slice(1); - import('./stores/toast.js').then(({ showSuccess }) => showSuccess(`${label} connected!`)); + import('./stores/toast.js').then(({ showSuccess }) => $_('dynamic_feedback.connected', { values: { service: label } })); // Navigate to Wellness page to pick up new connection window.location.hash = '#/wellness'; } else if ( @@ -1001,7 +1001,7 @@ @@ -2334,7 +2334,7 @@ Diary logging streak: ${ctx.streakText || '(unknown)'}` {/if}
{#if msg.image} - Attached + {$_('extracted.assistant.attached_10')} {/if}
{msg.content}
{#if _cardOffer && _cardOffer.msg === msg} @@ -2385,7 +2385,7 @@ Diary logging streak: ${ctx.streakText || '(unknown)'}` forceShowAll={true} />
- · Goal: {_active.goal_hours}h · Target: {_fmtDateTime(_targetEnd)} + {$_('extracted.diary.goal_58')} {_active.goal_hours}{$_('extracted.diary.h_target_59')} {_fmtDateTime(_targetEnd)}
@@ -329,7 +329,7 @@
- +
{/if} diff --git a/src/components/diary/QuickCaloriesSheet.svelte b/src/components/diary/QuickCaloriesSheet.svelte index f127c3b0..41a558af 100644 --- a/src/components/diary/QuickCaloriesSheet.svelte +++ b/src/components/diary/QuickCaloriesSheet.svelte @@ -70,7 +70,7 @@ async function _save() { const raw = parseDecimal(_value); if (!Number.isFinite(raw) || raw <= 0) { - showError(`Enter a positive ${_unitLabel} value.`); + showError($_('dynamic_feedback.positive_energy', { values: { unit: _unitLabel } })); return; } // kJ → kcal: 1 kcal = 4.184 kJ. Store as kcal internally (matches the @@ -100,13 +100,13 @@ } - +

- Log just the {_unitLabel} when you don't have full nutrition info, or when you don't want to model the food. Optional macros are stored only when you fill them in. Adds straight to the diary; no food entry is created. + {$_('extracted.diary.log_just_the_62')} {_unitLabel} {$_('extracted.diary.when_you_don_t_have_full_nutrition_info_or_whe_63')}

- + @@ -149,7 +149,7 @@ bind:value={_fat} on:keydown={_onKey} /> g
- Fat + {$_('diary_deep.fat')} diff --git a/src/components/diary/SmartLogModal.svelte b/src/components/diary/SmartLogModal.svelte index 6bf92a3f..4fc5c072 100644 --- a/src/components/diary/SmartLogModal.svelte +++ b/src/components/diary/SmartLogModal.svelte @@ -132,7 +132,7 @@ async function startListening() { if (!voiceAvailable) { - showError('Voice input not available on this device.'); + showError($_('feedback.diary.voice_input_not_available_on_this_device')); return; } if (isNative) { @@ -143,7 +143,7 @@ if (perm.speechRecognition !== 'granted') { const req = await SpeechRecognition.requestPermissions(); if (req.speechRecognition !== 'granted') { - showError('Microphone permission denied.'); + showError($_('feedback.diary.microphone_permission_denied')); return; } } @@ -151,7 +151,7 @@ const result = await SpeechRecognition.start({ language: _resolveVoiceLang(), maxResults: 1, - prompt: 'Tell me what you ate', + prompt: $_('voice_prompt.tell_me_what_you_ate'), partialResults: false, popup: false, }); @@ -257,7 +257,7 @@ try { const { saved } = await saveItems(matchedItems, { date, defaultMealSlot }); if (saved > 0) { - showSuccess(`Logged ${saved} item${saved === 1 ? '' : 's'}`); + showSuccess($_('dynamic_feedback.logged_items', { values: { count: saved } })); dispatch('saved'); dispatch('close'); } else { @@ -292,7 +292,7 @@ {#if phase === 'input'}
-

Type or speak what you ate. Mention the meal too — "for breakfast I had…"

+

{$_('extracted.diary.type_or_speak_what_you_ate_mention_the_meal_to_66')}

graphic_eq - Listening… speak now + {$_('extracted.diary.listening_speak_now_67')}
{/if} {#if errorMsg} @@ -319,32 +319,32 @@ {/if}
-
Examples:
- - - +
{$_('extracted.diary.examples_69')}
+ + +
{:else if phase === 'parsing'}
autorenew -

Parsing "{inputText}"…

+

{$_('extracted.diary.parsing_73')}{inputText}"…

{:else if phase === 'review'}
- {matchedItems.length} item{matchedItems.length === 1 ? '' : 's'} - {#if parsedMeal}· detected: {parsedMeal}{/if} + {matchedItems.length} {$_('diary.confirm.remove_fallback')}{matchedItems.length === 1 ? '' : 's'} + {#if parsedMeal}{$_('extracted.diary.detected_76')} {parsedMeal}{/if}
@@ -357,24 +357,24 @@ {m.food?.name || m.item.name} {#if m.source === 'local'}{$_('smart_log.badge_local')}{/if} {#if m.source === 'off'}OFF{/if} - {#if m.source === 'meal'}Meal{/if} + {#if m.source === 'meal'}{$_('extracted.diary.meal_11')}{/if} {#if m.source === 'recipe'}{$_('smart_log.badge_recipe')}{/if} {#if m.source === 'yesterday'}{$_('smart_log.badge_yesterday')}{/if} {#if isWater}{$_('smart_log.badge_water')}{/if} {#if !m.food}{$_('smart_log.badge_not_found')}{/if}
{#if isWater && m.food} -
{m.food._waterMl} ml — adds to water log
+
{m.food._waterMl} {$_('extracted.diary.ml_adds_to_water_log_78')}
{:else if m.food && isExpansion}
- Expands to {m.food.items.length} item{m.food.items.length === 1 ? '' : 's'} + {$_('extracted.diary.expands_to_79')} {m.food.items.length} {$_('diary.confirm.remove_fallback')}{m.food.items.length === 1 ? '' : 's'} {#if m.food.nutrition?.calories} {@const _e = Nutrition.displayEnergy(m.food.nutrition.calories, $energyUnit)} - · ~{_e.value.toLocaleString()} {_e.unit} total + · ~{_e.value.toLocaleString()} {_e.unit} {$_('extracted.diary.total_80')} {/if}
- Show items ({m.food.items.length}) + {$_('extracted.diary.show_items_81')}{m.food.items.length})
{#each m.food.items as sub}
{sub.name}{sub.brand ? ' · ' + sub.brand : ''}
@@ -391,11 +391,11 @@ {_e2.value.toLocaleString()} {_e2.unit} · {amountAndUnit(m.quantity, m.food.unit)}
{:else} -
No nutrition data — remove or add manually
+
{$_('extracted.diary.no_nutrition_data_remove_or_add_manually_82')}
{/if} {#if m.candidates && m.candidates.length > 1 && !isExpansion && !isWater}
- Swap match ({m.candidates.length}) + {$_('extracted.diary.swap_match_83')}{m.candidates.length})
{#each m.candidates as c}
@@ -433,7 +433,7 @@
@@ -441,7 +441,7 @@ {:else if phase === 'saving'}
autorenew -

Saving…

+

{$_('common.saving')}

{/if} diff --git a/src/components/diary/WaterWidget.svelte b/src/components/diary/WaterWidget.svelte index 724a77e7..102d57ba 100644 --- a/src/components/diary/WaterWidget.svelte +++ b/src/components/diary/WaterWidget.svelte @@ -12,7 +12,8 @@ * Rendered only inside .diary-right-col which is ≥1280px only. */ import { slide } from 'svelte/transition'; - import { _ } from 'svelte-i18n'; + import { _, locale } from 'svelte-i18n'; + import { waterContainerLabel } from '../../lib/water-container-label.js'; import { decimalInput, parseDecimal } from '../../lib/decimal-input.js'; export let logs = []; @@ -100,7 +101,7 @@
{#each containers as cont (cont.id ?? cont.volumeMl)} - {/each} diff --git a/src/components/diary/WeekStrip.svelte b/src/components/diary/WeekStrip.svelte index 60b5e85f..0197a473 100644 --- a/src/components/diary/WeekStrip.svelte +++ b/src/components/diary/WeekStrip.svelte @@ -1,4 +1,5 @@ -
- +

{$_('settings_diagnostics.log_help')} @@ -261,26 +261,26 @@

{#if isNative && _verboseLogging}

- Today's persisted log on disk (rotates daily, last 7 days kept). Better for long sessions or after a crash — the in-memory buffer above resets every reload. + {$_('extracted.settings.today_s_persisted_log_on_disk_rotates_daily_la_466')}

{/if} {#if isNative && _hasCrashReport} @@ -290,14 +290,14 @@ {$_('settings_diagnostics.crash_available')}

- The app captured an uncaught error. Share the report to help track it down, then dismiss it. + {$_('extracted.settings.the_app_captured_an_uncaught_error_share_the_r_467')}

@@ -306,18 +306,18 @@
- +

- {_calibExportCount} day{_calibExportCount === 1 ? '' : 's'} of data, anonymized. Review the JSON below before sharing — nothing is uploaded automatically. + {$_('settings_diagnostics.export_days_review', { values: { count: _calibExportCount } })}

diff --git a/src/routes/settings/Nutrients.svelte b/src/routes/settings/Nutrients.svelte index 0f4dbb64..93f6eb88 100644 --- a/src/routes/settings/Nutrients.svelte +++ b/src/routes/settings/Nutrients.svelte @@ -99,8 +99,8 @@
-

Visible Nutrients

-

Drag to reorder. Toggle off any nutrient you don't want shown in the diary and food editor.

+

{$_('extracted.settings.visible_nutrients_473')}

+

{$_('extracted.settings.drag_to_reorder_toggle_off_any_nutrient_you_do_474')}

{$_('settings_stats.custom_nutrients')}

-

Track nutrients not covered by the built-in list (e.g. Omega-3).

+

{$_('extracted.settings.track_nutrients_not_covered_by_the_built_in_li_475')}

{#each ($customNutriments || []) as cn, i} {#if i > 0}
{/if}
{cn.label} ({cn.unit})
@@ -146,28 +146,28 @@
- +
- +
- +
diff --git a/src/routes/settings/Regional.svelte b/src/routes/settings/Regional.svelte index 7ea910b7..a38fe6cf 100644 --- a/src/routes/settings/Regional.svelte +++ b/src/routes/settings/Regional.svelte @@ -1,5 +1,6 @@