refactor: every count in the web app is said by one plural(), with the viewer's thousands separator; a source guard names any hand-written copy (M505 #5642)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { createWantArtistsQuery } from '#lib/api/wanted.js';
|
||||
import { createAdminSummaryQuery } from '#lib/api/admin.js';
|
||||
import { QUEUES, countOf, queueLabel } from '#lib/admin/queues.js';
|
||||
@@ -18,13 +19,13 @@
|
||||
const verdict = $derived.by(() => {
|
||||
if (!counts) return '';
|
||||
if (counts.attention) {
|
||||
return counts.attention === 1 ? '1 download needs you.' : `${counts.attention} downloads need you.`;
|
||||
return `${plural(counts.attention, 'download needs', 'downloads need')} you.`;
|
||||
}
|
||||
const parts = [counts.wanted === 1 ? '1 album wanted' : `${counts.wanted} albums wanted`];
|
||||
const parts = [plural(counts.wanted, 'album wanted', 'albums wanted')];
|
||||
if (counts.activity) parts.push(`${counts.activity} downloading`);
|
||||
// Library albums no MusicBrainz album matched wait on a person too (#5579).
|
||||
if (counts.unmatched) {
|
||||
const n = counts.unmatched === 1 ? '1 album in your library needs' : `${counts.unmatched} albums in your library need`;
|
||||
const n = plural(counts.unmatched, 'album in your library needs', 'albums in your library need');
|
||||
return parts.join(', ') + `. ${n} matching.`;
|
||||
}
|
||||
return parts.join(', ') + '. Nothing needs you.';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { page } from '$app/state';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { Copy, Info, TriangleAlert } from 'lucide-svelte';
|
||||
@@ -103,10 +104,6 @@
|
||||
return keepChoice[group.id] ?? group.survivor_track_id;
|
||||
}
|
||||
|
||||
function fileCountLabel(n: number): string {
|
||||
return n === 1 ? '1 file' : `${n} files`;
|
||||
}
|
||||
|
||||
async function onMerge(group: AdminDuplicateGroup) {
|
||||
// First click arms; the second, on the button that now names how many files
|
||||
// go, does it. A merge deletes files, and nothing brings them back.
|
||||
@@ -118,7 +115,7 @@
|
||||
merging = group.id;
|
||||
try {
|
||||
const result = await mergeDuplicateGroup(group.id, { survivor_track_id: keeperOf(group) });
|
||||
pushToast(`Merged. Removed ${fileCountLabel(result.removed_paths.length)}.`);
|
||||
pushToast(`Merged. Removed ${plural(result.removed_paths.length, 'file', 'files')}.`);
|
||||
query.refetch();
|
||||
} catch (e: unknown) {
|
||||
pushToast(errMessage(e), 'error');
|
||||
@@ -136,10 +133,6 @@
|
||||
return `Same recording · ${match}% match`;
|
||||
}
|
||||
|
||||
function countLabel(n: number, one: string, many: string): string {
|
||||
return n === 1 ? `1 ${one}` : `${n} ${many}`;
|
||||
}
|
||||
|
||||
// Identical audio under different titles means at least one file's tags are
|
||||
// wrong, and the recording the other title names may not be in the library at
|
||||
// all. #3885: "WWW" was a second copy of the instrumental, and the vocal was
|
||||
@@ -164,7 +157,7 @@
|
||||
// What the copy carries is the fact that decides which to keep.
|
||||
function historyLabel(m: AdminDuplicateMember): string {
|
||||
if (m.like_count === 0 && m.play_count === 0) return 'no likes or plays';
|
||||
return `${countLabel(m.like_count, 'like', 'likes')} · ${countLabel(m.play_count, 'play', 'plays')}`;
|
||||
return `${plural(m.like_count, 'like', 'likes')} · ${plural(m.play_count, 'play', 'plays')}`;
|
||||
}
|
||||
|
||||
function position(m: AdminDuplicateMember): string {
|
||||
@@ -253,7 +246,7 @@
|
||||
{#if item.details.survivor_reason}
|
||||
<span class="text-text-secondary">({item.details.survivor_reason})</span>
|
||||
{/if}
|
||||
and removed {fileCountLabel(removed.length)}.
|
||||
and removed {plural(removed.length, 'file', 'files')}.
|
||||
</p>
|
||||
{#each removed as r (r.track_id)}
|
||||
<p class="truncate font-mono text-xs text-text-muted" title={r.file_path}>{r.file_path}</p>
|
||||
@@ -346,7 +339,7 @@
|
||||
{#if merging === group.id}
|
||||
Merging…
|
||||
{:else if confirmingMerge === group.id}
|
||||
Remove {fileCountLabel(group.members.length - 1)} and merge
|
||||
Remove {plural(group.members.length - 1, 'file', 'files')} and merge
|
||||
{:else}
|
||||
Merge…
|
||||
{/if}
|
||||
@@ -382,7 +375,7 @@
|
||||
<!-- What the second click will do, said plainly before it is done. -->
|
||||
<div class="space-y-2 border-b border-border bg-surface-hover px-4 py-3 text-sm" data-testid="merge-confirm">
|
||||
<p class="text-text-primary">
|
||||
The copy marked Keep stays. The other {fileCountLabel(group.members.length - 1)} will be
|
||||
The copy marked Keep stays. The other {plural(group.members.length - 1, 'file', 'files')} will be
|
||||
deleted from disk, and their likes, plays and playlist entries move to the copy kept.
|
||||
</p>
|
||||
<button
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { ChevronDown, FolderX, Music2, Search, X } from 'lucide-svelte';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
@@ -40,10 +41,6 @@
|
||||
const shown = $derived(groups.reduce((n, g) => n + g.tracks.length, 0));
|
||||
const hasMore = $derived(offset + shown < total);
|
||||
|
||||
function trackCountLabel(n: number): string {
|
||||
return n === 1 ? '1 track' : `${n} tracks`;
|
||||
}
|
||||
|
||||
// What happens to these is set under Acquisition (#5607); the line above
|
||||
// the list says what it is now, since this is where the question comes up.
|
||||
let policy = $state<ReacquisitionSettings | null>(null);
|
||||
@@ -158,7 +155,7 @@
|
||||
{group.directory}
|
||||
</h3>
|
||||
<span class="shrink-0 text-xs text-text-secondary">
|
||||
{trackCountLabel(group.tracks.length)} · gone {relativeTime(group.missing_since)}
|
||||
{plural(group.tracks.length, 'track', 'tracks')} · gone {relativeTime(group.missing_since)}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { Music2, CheckCircle2, Trash2, Play, Copy, ChevronRight } from 'lucide-svelte';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
@@ -144,7 +145,6 @@
|
||||
};
|
||||
}
|
||||
|
||||
const plural = (n: number, one: string, many: string) => `${n} ${n === 1 ? one : many}`;
|
||||
</script>
|
||||
|
||||
<svelte:head><title>{pageTitle('Collection · Reports')}</title></svelte:head>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { FileCheck, Music2 } from 'lucide-svelte';
|
||||
import { createSuspectSourcesQuery, setSuspectVerdict } from '#lib/api/admin.js';
|
||||
@@ -64,10 +65,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function trackCountLabel(n: number): string {
|
||||
return n === 1 ? '1 track' : `${n} tracks`;
|
||||
}
|
||||
|
||||
function basename(path: string): string {
|
||||
return path.slice(path.lastIndexOf('/') + 1);
|
||||
}
|
||||
@@ -134,7 +131,7 @@
|
||||
{group.directory}
|
||||
</h3>
|
||||
<span class="shrink-0 text-xs text-text-secondary">
|
||||
{trackCountLabel(group.tracks.length)}
|
||||
{plural(group.tracks.length, 'track', 'tracks')}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user