From c7023dab1d189bc0880887207e991c5064588a43 Mon Sep 17 00:00:00 2001 From: Benedikt Ortwein Date: Wed, 10 Sep 2025 21:50:48 +0200 Subject: [PATCH] feat(currency): add dynamic currency list with locale support (closes #49, #59, #75, #83) - Implemented utility to list currencies using Intl API with fallback set - Integrated locale detection (navigator.language) for proper labels --- .../src/components/forms/ConfigForm.svelte | 32 ++++++------ app/frontend/src/lib/utils/currencies.ts | 51 +++++++++++++++++++ 2 files changed, 66 insertions(+), 17 deletions(-) create mode 100644 app/frontend/src/lib/utils/currencies.ts diff --git a/app/frontend/src/components/forms/ConfigForm.svelte b/app/frontend/src/components/forms/ConfigForm.svelte index 80ec3e4b..17e4799e 100644 --- a/app/frontend/src/components/forms/ConfigForm.svelte +++ b/app/frontend/src/components/forms/ConfigForm.svelte @@ -12,23 +12,21 @@ }); import { config, type Config } from '$lib/stores/config'; + import { listCurrencies } from '$lib/utils/currencies'; let localConfig: Config[] = $state([]); + const userLocale = navigator.language || 'en'; + + const currencyOptions = listCurrencies(userLocale); + const dateFormatOptions = [ { value: 'dd/MM/yyyy', label: 'dd/MM/yyyy (e.g., 31/12/2000)' }, { value: 'MM/dd/yyyy', label: 'MM/dd/yyyy (e.g., 12/25/2000)' }, { value: 'yyyy-MM-dd', label: 'yyyy-MM-dd (e.g., 2000-12-31)' }, { value: 'dd MMM, yyyy', label: 'dd MMM, yyyy (e.g., 31 Dec, 2000)' } ]; - - const currencyOptions = [ - { value: 'INR', label: 'INR (₹)' }, - { value: 'USD', label: 'USD ($)' }, - { value: 'EUR', label: 'EUR (€)' }, - { value: 'GBP', label: 'GBP (£)' } - ]; - + const uomOptions = [ { value: 'metric', label: 'Metric' }, { value: 'imperial', label: 'Imperial' } @@ -76,15 +74,15 @@ {/each} {:else if item.key === 'currency'} - + {:else if item.key === 'unitOfMeasure'}