Skip to content

Commit 5ae7fde

Browse files
committed
refactor: generalize i18n keys for download trends
I've been working on a PR to add "likes" as a new facet that can be visualized in what I'm calling "trends" charts (e.g. downloads over time, likes over time). That PR generalizes the existing "downloads" chart to support one or more given facets. I've had a half dozen painful merge conflicts across 37 locale files, so I've pulled out just this i18n key rename into its own PR to make this all easier.
1 parent 90ca00f commit 5ae7fde

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+696
-635
lines changed

app/components/Package/DownloadAnalytics.vue

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,10 @@ function buildExportFilename(extension: string): string {
895895
}
896896
897897
const granularityLabels = computed(() => ({
898-
daily: $t('package.downloads.granularity_daily'),
899-
weekly: $t('package.downloads.granularity_weekly'),
900-
monthly: $t('package.downloads.granularity_monthly'),
901-
yearly: $t('package.downloads.granularity_yearly'),
898+
daily: $t('package.trends.granularity_daily'),
899+
weekly: $t('package.trends.granularity_weekly'),
900+
monthly: $t('package.trends.granularity_monthly'),
901+
yearly: $t('package.trends.granularity_yearly'),
902902
}))
903903
904904
function getGranularityLabel(granularity: ChartTimeGranularity) {
@@ -1321,18 +1321,18 @@ const chartConfig = computed(() => {
13211321
userOptions: {
13221322
buttons: { pdf: false, labels: false, fullscreen: false, table: false, tooltip: false },
13231323
buttonTitles: {
1324-
csv: $t('package.downloads.download_file', { fileType: 'CSV' }),
1325-
img: $t('package.downloads.download_file', { fileType: 'PNG' }),
1326-
svg: $t('package.downloads.download_file', { fileType: 'SVG' }),
1327-
annotator: $t('package.downloads.toggle_annotator'),
1324+
csv: $t('package.trends.download_file', { fileType: 'CSV' }),
1325+
img: $t('package.trends.download_file', { fileType: 'PNG' }),
1326+
svg: $t('package.trends.download_file', { fileType: 'SVG' }),
1327+
annotator: $t('package.trends.toggle_annotator'),
13281328
},
13291329
callbacks: {
13301330
img: ({ imageUri }: { imageUri: string }) => {
13311331
loadFile(imageUri, buildExportFilename('png'))
13321332
},
13331333
csv: (csvStr: string) => {
13341334
const PLACEHOLDER_CHAR = '\0'
1335-
const multilineDateTemplate = $t('package.downloads.date_range_multiline', {
1335+
const multilineDateTemplate = $t('package.trends.date_range_multiline', {
13361336
start: PLACEHOLDER_CHAR,
13371337
end: PLACEHOLDER_CHAR,
13381338
})
@@ -1360,8 +1360,9 @@ const chartConfig = computed(() => {
13601360
fontSize: isMobile.value ? 24 : 16,
13611361
color: pending.value ? colors.value.border : colors.value.fgSubtle,
13621362
axis: {
1363-
yLabel: $t('package.downloads.y_axis_label', {
1363+
yLabel: $t('package.trends.y_axis_label', {
13641364
granularity: getGranularityLabel(selectedGranularity.value),
1365+
facet: $t('package.trends.items.downloads'),
13651366
}),
13661367
xLabel: isMultiPackageMode.value ? '' : xAxisLabel.value, // for multiple series, names are displayed in the chart's legend
13671368
yLabelOffsetX: 12,
@@ -1478,7 +1479,7 @@ const chartConfig = computed(() => {
14781479
for="granularity"
14791480
class="text-3xs font-mono text-fg-subtle tracking-wide uppercase"
14801481
>
1481-
{{ $t('package.downloads.granularity') }}
1482+
{{ $t('package.trends.granularity') }}
14821483
</label>
14831484

14841485
<div
@@ -1490,10 +1491,18 @@ const chartConfig = computed(() => {
14901491
:disabled="pending"
14911492
class="w-full px-2.5 py-1.75 bg-bg-subtle font-mono text-sm text-fg outline-none appearance-none focus-visible:outline-accent/70"
14921493
>
1493-
<option value="daily">{{ $t('package.downloads.granularity_daily') }}</option>
1494-
<option value="weekly">{{ $t('package.downloads.granularity_weekly') }}</option>
1495-
<option value="monthly">{{ $t('package.downloads.granularity_monthly') }}</option>
1496-
<option value="yearly">{{ $t('package.downloads.granularity_yearly') }}</option>
1494+
<option value="daily">
1495+
{{ $t('package.trends.granularity_daily') }}
1496+
</option>
1497+
<option value="weekly">
1498+
{{ $t('package.trends.granularity_weekly') }}
1499+
</option>
1500+
<option value="monthly">
1501+
{{ $t('package.trends.granularity_monthly') }}
1502+
</option>
1503+
<option value="yearly">
1504+
{{ $t('package.trends.granularity_yearly') }}
1505+
</option>
14971506
</select>
14981507
</div>
14991508
</div>
@@ -1504,7 +1513,7 @@ const chartConfig = computed(() => {
15041513
for="startDate"
15051514
class="text-3xs font-mono text-fg-subtle tracking-wide uppercase"
15061515
>
1507-
{{ $t('package.downloads.start_date') }}
1516+
{{ $t('package.trends.start_date') }}
15081517
</label>
15091518
<div
15101519
class="flex items-center gap-2 px-2.5 py-1.75 bg-bg-subtle border border-border rounded-md focus-within:(border-border-hover ring-2 ring-accent/70)"
@@ -1522,7 +1531,7 @@ const chartConfig = computed(() => {
15221531

15231532
<div class="flex flex-col gap-1">
15241533
<label for="endDate" class="text-3xs font-mono text-fg-subtle tracking-wide uppercase">
1525-
{{ $t('package.downloads.end_date') }}
1534+
{{ $t('package.trends.end_date') }}
15261535
</label>
15271536
<div
15281537
class="flex items-center gap-2 px-2.5 py-1.75 bg-bg-subtle border border-border rounded-md focus-within:(border-border-hover ring-2 ring-accent/70)"
@@ -1656,9 +1665,7 @@ const chartConfig = computed(() => {
16561665
stroke-linecap="round"
16571666
/>
16581667
</svg>
1659-
<span class="text-fg-subtle">{{
1660-
$t('package.downloads.legend_estimation')
1661-
}}</span>
1668+
<span class="text-fg-subtle">{{ $t('package.trends.legend_estimation') }}</span>
16621669
</div>
16631670
</div>
16641671
</template>
@@ -1747,7 +1754,11 @@ const chartConfig = computed(() => {
17471754
v-if="!chartData.dataset && !pending"
17481755
class="min-h-[260px] flex items-center justify-center text-fg-subtle font-mono text-sm"
17491756
>
1750-
{{ $t('package.downloads.no_data') }}
1757+
{{
1758+
$t('package.trends.no_data', {
1759+
facet: $t('package.trends.items.downloads'),
1760+
})
1761+
}}
17511762
</div>
17521763

17531764
<div
@@ -1756,7 +1767,7 @@ const chartConfig = computed(() => {
17561767
aria-live="polite"
17571768
class="absolute top-1/2 inset-is-1/2 -translate-x-1/2 -translate-y-1/2 text-xs text-fg-subtle font-mono bg-bg/70 backdrop-blur px-3 py-2 rounded-md border border-border"
17581769
>
1759-
{{ $t('package.downloads.loading') }}
1770+
{{ $t('package.trends.loading') }}
17601771
</div>
17611772
</div>
17621773
</template>

app/components/Package/WeeklyDownloadStats.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ watch(
124124
const dataset = computed(() =>
125125
weeklyDownloads.value.map(d => ({
126126
value: d?.downloads ?? 0,
127-
period: $t('package.downloads.date_range', {
127+
period: $t('package.trends.date_range', {
128128
start: d.weekStart ?? '-',
129129
end: d.weekEnd ?? '-',
130130
}),

app/pages/compare.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ useSeoMeta({
242242
id="comparison-heading"
243243
class="text-xs text-fg-subtle uppercase tracking-wider mb-4 mt-10"
244244
>
245-
{{ $t('package.downloads.title') }}
245+
{{ $t('compare.facets.trends.title') }}
246246
</h2>
247247

248248
<CompareLineChart :packages="packages.filter(p => p !== NO_DEPENDENCY_ID)" />

i18n/locales/ar.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -284,23 +284,9 @@
284284
},
285285
"downloads": {
286286
"title": "التنزيلات الأسبوعية",
287-
"date_range": "من {start} إلى {end}",
288-
"date_range_multiline": "من {start}\nإلى {end}",
289287
"analyze": "تحليل التنزيلات",
290288
"community_distribution": "عرض توزيع تبنّي المجتمع",
291-
"modal_title": "التنزيلات",
292-
"granularity": "مستوى التفصيل",
293-
"granularity_daily": "يومي",
294-
"granularity_weekly": "أسبوعي",
295-
"granularity_monthly": "شهري",
296-
"granularity_yearly": "سنوي",
297-
"start_date": "البداية",
298-
"end_date": "النهاية",
299-
"no_data": "لا تتوفر بيانات تنزيل",
300-
"loading": "جارٍ التحميل…",
301-
"y_axis_label": "تنزيلات {granularity}ة",
302-
"download_file": "تنزيل {fileType}",
303-
"toggle_annotator": "إظهار/إخفاء الشروح التوضيحية"
289+
"modal_title": "التنزيلات"
304290
},
305291
"install_scripts": {
306292
"title": "سكربتات التثبيت",
@@ -384,6 +370,20 @@
384370
"published": "الأحدث نشرًا",
385371
"name_asc": "الاسم (A-Z)",
386372
"name_desc": "الاسم (Z-A)"
373+
},
374+
"trends": {
375+
"granularity": "مستوى التفصيل",
376+
"granularity_daily": "يومي",
377+
"granularity_weekly": "أسبوعي",
378+
"granularity_monthly": "شهري",
379+
"granularity_yearly": "سنوي",
380+
"start_date": "البداية",
381+
"end_date": "النهاية",
382+
"loading": "جارٍ التحميل…",
383+
"date_range": "من {start} إلى {end}",
384+
"date_range_multiline": "من {start}\nإلى {end}",
385+
"download_file": "تنزيل {fileType}",
386+
"toggle_annotator": "إظهار/إخفاء الشروح التوضيحية"
387387
}
388388
},
389389
"connector": {

i18n/locales/az-AZ.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -219,22 +219,8 @@
219219
},
220220
"downloads": {
221221
"title": "Həftəlik Endirmələr",
222-
"date_range": "{start} - {end}",
223-
"date_range_multiline": "{start}\n- {end}",
224222
"analyze": "Endirmələri təhlil et",
225-
"modal_title": "Endirmələr",
226-
"granularity": "Dərəcəlilik",
227-
"granularity_daily": "Günlük",
228-
"granularity_weekly": "Həftəlik",
229-
"granularity_monthly": "Aylıq",
230-
"granularity_yearly": "İllik",
231-
"start_date": "Başlanğıc",
232-
"end_date": "Son",
233-
"no_data": "Endirmə məlumatı mövcud deyil",
234-
"loading": "Yüklənir...",
235-
"y_axis_label": "{granularity} endirmələr",
236-
"download_file": "{fileType} endir",
237-
"toggle_annotator": "Annotator keçid"
223+
"modal_title": "Endirmələr"
238224
},
239225
"install_scripts": {
240226
"title": "Quraşdırma Skriptləri",
@@ -315,6 +301,20 @@
315301
"downloads": "Ən çox endirilən",
316302
"name_asc": "Ad (A-Z)",
317303
"name_desc": "Ad (Z-A)"
304+
},
305+
"trends": {
306+
"granularity": "Dərəcəlilik",
307+
"granularity_daily": "Günlük",
308+
"granularity_weekly": "Həftəlik",
309+
"granularity_monthly": "Aylıq",
310+
"granularity_yearly": "İllik",
311+
"start_date": "Başlanğıc",
312+
"end_date": "Son",
313+
"loading": "Yüklənir...",
314+
"date_range": "{start} - {end}",
315+
"date_range_multiline": "{start}\n- {end}",
316+
"download_file": "{fileType} endir",
317+
"toggle_annotator": "Annotator keçid"
318318
}
319319
},
320320
"connector": {

i18n/locales/cs-CZ.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -254,22 +254,8 @@
254254
},
255255
"downloads": {
256256
"title": "Týdenní stažení",
257-
"date_range": "od {start} do {end}",
258-
"date_range_multiline": "od {start}\ndo {end}",
259257
"analyze": "Analyzovat stažení",
260-
"modal_title": "Stažení",
261-
"granularity": "Rozlišení",
262-
"granularity_daily": "Denně",
263-
"granularity_weekly": "Týdně",
264-
"granularity_monthly": "Měsíčně",
265-
"granularity_yearly": "Ročně",
266-
"start_date": "Od",
267-
"end_date": "Do",
268-
"no_data": "Žádná data o stažení nejsou k dispozici",
269-
"loading": "Načítání...",
270-
"y_axis_label": "Stažení {granularity}",
271-
"download_file": "Stáhnout {fileType}",
272-
"toggle_annotator": "Přepnout popisovač"
258+
"modal_title": "Stažení"
273259
},
274260
"install_scripts": {
275261
"title": "Instalační skripty",
@@ -353,6 +339,20 @@
353339
"published": "Nedávno publikováno",
354340
"name_asc": "Název (A-Z)",
355341
"name_desc": "Název (Z-A)"
342+
},
343+
"trends": {
344+
"granularity": "Rozlišení",
345+
"granularity_daily": "Denně",
346+
"granularity_weekly": "Týdně",
347+
"granularity_monthly": "Měsíčně",
348+
"granularity_yearly": "Ročně",
349+
"start_date": "Od",
350+
"end_date": "Do",
351+
"loading": "Načítání...",
352+
"date_range": "od {start} do {end}",
353+
"date_range_multiline": "od {start}\ndo {end}",
354+
"download_file": "Stáhnout {fileType}",
355+
"toggle_annotator": "Přepnout popisovač"
356356
}
357357
},
358358
"connector": {

i18n/locales/de-DE.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -285,23 +285,9 @@
285285
},
286286
"downloads": {
287287
"title": "Wöchentliche Downloads",
288-
"date_range": "{start} bis {end}",
289-
"date_range_multiline": "{start}\nbis {end}",
290288
"analyze": "Downloads analysieren",
291289
"community_distribution": "Community-Adoptionsverteilung ansehen",
292-
"modal_title": "Downloads",
293-
"granularity": "Granularität",
294-
"granularity_daily": "Täglich",
295-
"granularity_weekly": "Wöchentlich",
296-
"granularity_monthly": "Monatlich",
297-
"granularity_yearly": "Jährlich",
298-
"start_date": "Start",
299-
"end_date": "Ende",
300-
"no_data": "Keine Download-Daten verfügbar",
301-
"loading": "Lädt...",
302-
"y_axis_label": "{granularity} Downloads",
303-
"download_file": "{fileType} herunterladen",
304-
"toggle_annotator": "Annotation umschalten"
290+
"modal_title": "Downloads"
305291
},
306292
"install_scripts": {
307293
"title": "Installationsskripte",
@@ -385,6 +371,20 @@
385371
"published": "Zuletzt veröffentlicht",
386372
"name_asc": "Name (A-Z)",
387373
"name_desc": "Name (Z-A)"
374+
},
375+
"trends": {
376+
"granularity": "Granularität",
377+
"granularity_daily": "Täglich",
378+
"granularity_weekly": "Wöchentlich",
379+
"granularity_monthly": "Monatlich",
380+
"granularity_yearly": "Jährlich",
381+
"start_date": "Start",
382+
"end_date": "Ende",
383+
"loading": "Lädt...",
384+
"date_range": "{start} bis {end}",
385+
"date_range_multiline": "{start}\nbis {end}",
386+
"download_file": "{fileType} herunterladen",
387+
"toggle_annotator": "Annotation umschalten"
388388
}
389389
},
390390
"connector": {

i18n/locales/en.json

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -283,26 +283,32 @@
283283
"show_more": "(show {count} more)",
284284
"show_less": "(show fewer)"
285285
},
286-
"downloads": {
287-
"title": "Weekly Downloads",
288-
"date_range": "{start} to {end}",
289-
"date_range_multiline": "{start}\nto {end}",
290-
"analyze": "Analyze downloads",
291-
"community_distribution": "View community adoption distribution",
292-
"modal_title": "Downloads",
286+
"trends": {
293287
"granularity": "Granularity",
294288
"granularity_daily": "Daily",
295289
"granularity_weekly": "Weekly",
296290
"granularity_monthly": "Monthly",
297291
"granularity_yearly": "Yearly",
298292
"start_date": "Start",
299293
"end_date": "End",
300-
"no_data": "No download data available",
301294
"loading": "Loading...",
302-
"y_axis_label": "{granularity} downloads",
295+
"date_range": "{start} to {end}",
296+
"date_range_multiline": "{start}\nto {end}",
303297
"download_file": "Download {fileType}",
304298
"toggle_annotator": "Toggle annotator",
305-
"legend_estimation": "Estimation"
299+
"legend_estimation": "Estimation",
300+
"no_data": "No {facet} data available",
301+
"y_axis_label": "{granularity} {facet}",
302+
"items": {
303+
"downloads": "Downloads",
304+
"likes": "Likes"
305+
}
306+
},
307+
"downloads": {
308+
"title": "Weekly Downloads",
309+
"analyze": "Analyze downloads",
310+
"community_distribution": "View community adoption distribution",
311+
"modal_title": "Downloads"
306312
},
307313
"install_scripts": {
308314
"title": "Install Scripts",
@@ -853,6 +859,7 @@
853859
"add_column": "Add no dependency column to comparison"
854860
},
855861
"facets": {
862+
"facet": "Facet",
856863
"group_label": "Comparison facets",
857864
"all": "all",
858865
"none": "none",
@@ -932,6 +939,9 @@
932939
"types_none": "None",
933940
"vulnerabilities_summary": "{count} ({critical}C/{high}H)",
934941
"up_to_you": "Up to you!"
942+
},
943+
"trends": {
944+
"title": "Compare Trends"
935945
}
936946
}
937947
},

0 commit comments

Comments
 (0)