From 40d571f91510e6140d3b0625a7bb11780805643a Mon Sep 17 00:00:00 2001 From: graphieros Date: Fri, 30 Jan 2026 15:51:23 +0100 Subject: [PATCH 1/3] fix: add translations for multiline date range --- i18n/locales/ar.json | 1 + i18n/locales/de-DE.json | 1 + i18n/locales/en.json | 1 + i18n/locales/es.json | 1 + i18n/locales/fr-FR.json | 1 + i18n/locales/it-IT.json | 1 + i18n/locales/ja-JP.json | 1 + i18n/locales/ru-RU.json | 1 + i18n/locales/zh-CN.json | 1 + 9 files changed, 9 insertions(+) diff --git a/i18n/locales/ar.json b/i18n/locales/ar.json index c858a3cb..e0dc5180 100644 --- a/i18n/locales/ar.json +++ b/i18n/locales/ar.json @@ -213,6 +213,7 @@ "downloads": { "title": "التنزيلات الأسبوعية", "date_range": "من {start} إلى {end}", + "date_range_multiline": "من {start}\nإلى {end}", "analyze": "تحليل التنزيلات", "modal_title": "التنزيلات", "granularity": "مستوى التفصيل", diff --git a/i18n/locales/de-DE.json b/i18n/locales/de-DE.json index dbc7d17a..652199bd 100644 --- a/i18n/locales/de-DE.json +++ b/i18n/locales/de-DE.json @@ -226,6 +226,7 @@ "downloads": { "title": "Wöchentliche Downloads", "date_range": "{start} bis {end}", + "date_range_multiline": "{start}\nbis {end}", "analyze": "Downloads analysieren", "modal_title": "Downloads", "granularity": "Granularität", diff --git a/i18n/locales/en.json b/i18n/locales/en.json index 07df690d..8a6cc33a 100644 --- a/i18n/locales/en.json +++ b/i18n/locales/en.json @@ -226,6 +226,7 @@ "downloads": { "title": "Weekly Downloads", "date_range": "{start} to {end}", + "date_range_multiline": "{start}\nto {end}", "analyze": "Analyze downloads", "modal_title": "Downloads", "granularity": "Granularity", diff --git a/i18n/locales/es.json b/i18n/locales/es.json index 57707b5b..4c8a026d 100644 --- a/i18n/locales/es.json +++ b/i18n/locales/es.json @@ -213,6 +213,7 @@ "downloads": { "title": "Descargas Semanales", "date_range": "{start} a {end}", + "date_range_multiline": "{start}\na {end}", "analyze": "Analizar descargas", "modal_title": "Descargas", "granularity": "Granularidad", diff --git a/i18n/locales/fr-FR.json b/i18n/locales/fr-FR.json index 09e96706..bdaef15d 100644 --- a/i18n/locales/fr-FR.json +++ b/i18n/locales/fr-FR.json @@ -213,6 +213,7 @@ "downloads": { "title": "Téléchargements hebdomadaires", "date_range": "{start} au {end}", + "date_range_multiline": "{start}\nau {end}", "analyze": "Analyser les téléchargements", "modal_title": "Téléchargements", "granularity": "Granularité", diff --git a/i18n/locales/it-IT.json b/i18n/locales/it-IT.json index 611a1680..8461105d 100644 --- a/i18n/locales/it-IT.json +++ b/i18n/locales/it-IT.json @@ -213,6 +213,7 @@ "downloads": { "title": "Downloads settimanali", "date_range": "{start} a {end}", + "date_range_multiline": "{start}\na {end}", "analyze": "Analizza downloads", "modal_title": "Downloads", "granularity": "Granularità", diff --git a/i18n/locales/ja-JP.json b/i18n/locales/ja-JP.json index b20923f0..ff5096a3 100644 --- a/i18n/locales/ja-JP.json +++ b/i18n/locales/ja-JP.json @@ -213,6 +213,7 @@ "downloads": { "title": "週間ダウンロード数", "date_range": "{start} から {end}", + "date_range_multiline": "{start}\nから {end}", "analyze": "ダウンロード数を分析", "modal_title": "ダウンロード数", "granularity": "粒度", diff --git a/i18n/locales/ru-RU.json b/i18n/locales/ru-RU.json index d0459c8c..667d8c08 100644 --- a/i18n/locales/ru-RU.json +++ b/i18n/locales/ru-RU.json @@ -222,6 +222,7 @@ "downloads": { "title": "Загрузки за неделю", "date_range": "С {start} по {end}", + "date_range_multiline": "С {start}\nпо {end}", "analyze": "Анализировать загрузки", "modal_title": "Загрузки", "granularity": "Детализация", diff --git a/i18n/locales/zh-CN.json b/i18n/locales/zh-CN.json index 319ce23b..ad5b661b 100644 --- a/i18n/locales/zh-CN.json +++ b/i18n/locales/zh-CN.json @@ -226,6 +226,7 @@ "downloads": { "title": "每周下载量", "date_range": "{start} 到 {end}", + "date_range_multiline": "{start}\n到 {end}", "analyze": "分析下载量", "modal_title": "下载量", "granularity": "周期", From bbcaa11eae37ba13b142182abcd5f50920f0c712 Mon Sep 17 00:00:00 2001 From: graphieros Date: Fri, 30 Jan 2026 15:54:25 +0100 Subject: [PATCH 2/3] fix: force ltr on download chart in modal --- app/components/PackageDownloadAnalytics.vue | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/app/components/PackageDownloadAnalytics.vue b/app/components/PackageDownloadAnalytics.vue index ab1b72bb..ec643bad 100644 --- a/app/components/PackageDownloadAnalytics.vue +++ b/app/components/PackageDownloadAnalytics.vue @@ -138,7 +138,12 @@ function formatXyDataset( color: accent.value, }, ], - dates: dataset.map(d => `${d.weekStart}\nto ${d.weekEnd}`), + dates: dataset.map(d => + $t('package.downloads.date_range_multiline', { + start: d.weekStart, + end: d.weekEnd, + }), + ), } } if (selectedGranularity === 'daily' && isDailyDataset(dataset)) { @@ -199,14 +204,16 @@ function safeMax(a: string, b: string): string { return a.localeCompare(b) >= 0 ? a : b } -function extractDates(dateLabel: string) { - if (typeof dateLabel !== 'string') return [] +function extractDates(dateLabel: string): [string, string] | null { + const matches = dateLabel.match(/\b(\d{4}(?:-\d{2}-\d{2})?)\b/g) // either yyyy or yyyy-mm-dd + if (!matches) return null - const parts = dateLabel.trim().split(/\s+/).filter(Boolean) + const first = matches.at(0) + const last = matches.at(-1) - if (parts.length < 2) return [] + if (!first || !last || first === last) return null - return [parts[0], parts[parts.length - 1]] + return [first, last] } /** @@ -553,7 +560,8 @@ const config = computed(() => { ? undefined : ({ absoluteIndex, side }: { absoluteIndex: number; side: 'left' | 'right' }) => { const parts = extractDates(chartData.value.dates[absoluteIndex] ?? '') - return side === 'left' ? parts[0] : parts.at(-1) + if (!parts) return '' + return side === 'left' ? parts[0] : parts[1] }, highlightColor: colors.value.bgElevated, minimap: { @@ -670,7 +678,7 @@ const config = computed(() => { - +