Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions app/components/PackageDownloadAnalytics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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]
}

/**
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -670,7 +678,7 @@ const config = computed(() => {
</div>

<ClientOnly v-if="inModal && chartData.dataset">
<VueUiXy :dataset="chartData.dataset" :config="config">
<VueUiXy :dataset="chartData.dataset" :config="config" class="[direction:ltr]">
<template #menuIcon="{ isOpen }">
<span v-if="isOpen" class="i-carbon:close w-6 h-6" aria-hidden="true" />
<span v-else class="i-carbon:overflow-menu-vertical w-6 h-6" aria-hidden="true" />
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"downloads": {
"title": "التنزيلات الأسبوعية",
"date_range": "من {start} إلى {end}",
"date_range_multiline": "من {start}\nإلى {end}",
"analyze": "تحليل التنزيلات",
"modal_title": "التنزيلات",
"granularity": "مستوى التفصيل",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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é",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -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à",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"downloads": {
"title": "週間ダウンロード数",
"date_range": "{start} から {end}",
"date_range_multiline": "{start}\nから {end}",
"analyze": "ダウンロード数を分析",
"modal_title": "ダウンロード数",
"granularity": "粒度",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
"downloads": {
"title": "Загрузки за неделю",
"date_range": "С {start} по {end}",
"date_range_multiline": "С {start}\nпо {end}",
"analyze": "Анализировать загрузки",
"modal_title": "Загрузки",
"granularity": "Детализация",
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"downloads": {
"title": "每周下载量",
"date_range": "{start} 到 {end}",
"date_range_multiline": "{start}\n到 {end}",
"analyze": "分析下载量",
"modal_title": "下载量",
"granularity": "周期",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"downloads": {
"title": "التنزيلات الأسبوعية",
"date_range": "من {start} إلى {end}",
"date_range_multiline": "من {start}\nإلى {end}",
"analyze": "تحليل التنزيلات",
"modal_title": "التنزيلات",
"granularity": "مستوى التفصيل",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/es-419.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/es-ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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é",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/it-IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -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à",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
"downloads": {
"title": "週間ダウンロード数",
"date_range": "{start} から {end}",
"date_range_multiline": "{start}\nから {end}",
"analyze": "ダウンロード数を分析",
"modal_title": "ダウンロード数",
"granularity": "粒度",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/ru-RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
"downloads": {
"title": "Загрузки за неделю",
"date_range": "С {start} по {end}",
"date_range_multiline": "С {start}\nпо {end}",
"analyze": "Анализировать загрузки",
"modal_title": "Загрузки",
"granularity": "Детализация",
Expand Down
1 change: 1 addition & 0 deletions lunaria/files/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@
"downloads": {
"title": "每周下载量",
"date_range": "{start} 到 {end}",
"date_range_multiline": "{start}\n到 {end}",
"analyze": "分析下载量",
"modal_title": "下载量",
"granularity": "周期",
Expand Down