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 { pageTitle } from '#lib/branding.js';
|
||||
import { createAdminStatusQuery, createAdminSummaryQuery, createScanStatusQuery } from '#lib/api/admin.js';
|
||||
import { relativeTime } from '#lib/utils/relativeTime.js';
|
||||
@@ -47,7 +48,7 @@
|
||||
if (dl.needs_you > 0) {
|
||||
out.push({
|
||||
key: 'downloads',
|
||||
text: dl.needs_you === 1 ? '1 download needs you' : `${dl.needs_you} downloads need you`,
|
||||
text: plural(dl.needs_you, 'download needs you', 'downloads need you'),
|
||||
since: dl.needs_you_since,
|
||||
href: '/collection/activity'
|
||||
});
|
||||
@@ -66,7 +67,6 @@
|
||||
return out;
|
||||
});
|
||||
|
||||
const plural = (n: number, one: string, many: string) => `${n.toLocaleString('en-US')} ${n === 1 ? one : many}`;
|
||||
|
||||
// Worded as the wanted list words it; before the client reports, it is
|
||||
// simply downloading, as the Downloads list says.
|
||||
@@ -92,7 +92,7 @@
|
||||
{#if problems === 0}
|
||||
Nothing needs you.
|
||||
{:else}
|
||||
{problems === 1 ? '1 thing needs you.' : `${problems} things need you.`}
|
||||
{plural(problems, 'thing needs you.', 'things need you.')}
|
||||
{/if}
|
||||
</p>
|
||||
{#if problems > 0}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { Disc3, Album, Music2, Check, X, SlidersHorizontal } from 'lucide-svelte';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
@@ -196,10 +197,10 @@
|
||||
{#if r.imported_album_count > 0 || r.imported_track_count > 0}
|
||||
<div class="text-sm text-accent-fg" data-testid="ingest-progress">
|
||||
{#if r.kind === 'artist'}
|
||||
{r.imported_album_count} {r.imported_album_count === 1 ? 'album' : 'albums'}
|
||||
· {r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{plural(r.imported_album_count, 'album', 'albums')}
|
||||
· {plural(r.imported_track_count, 'track', 'tracks')} ingested
|
||||
{:else if r.kind === 'album'}
|
||||
{r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{plural(r.imported_track_count, 'track', 'tracks')} ingested
|
||||
{:else}
|
||||
Track ingested
|
||||
{/if}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
import { qk } from '#lib/api/queries.js';
|
||||
@@ -227,8 +228,8 @@
|
||||
{#if usersQuery.data}
|
||||
{@const admins = users.filter((u) => u.is_admin).length}
|
||||
<p class="text-sm text-text-secondary" data-testid="users-summary">
|
||||
{users.length === 1 ? '1 account' : `${users.length} accounts`}, {admins === 1 ? '1 admin' : `${admins} admins`}{invitesQuery.data
|
||||
? ` · ${invites.length === 1 ? '1 invite open' : `${invites.length} invites open`}`
|
||||
{plural(users.length, 'account', 'accounts')}, {plural(admins, 'admin', 'admins')}{invitesQuery.data
|
||||
? ` · ${plural(invites.length, 'invite open', 'invites open')}`
|
||||
: ''}.
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import PageColumn from '#lib/components/PageColumn.svelte';
|
||||
import { page } from '$app/state';
|
||||
import { createAlbumQuery } from '#lib/api/queries.js';
|
||||
@@ -140,7 +141,7 @@
|
||||
</ul>
|
||||
{/if}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{album.track_count} {album.track_count === 1 ? 'track' : 'tracks'}
|
||||
{plural(album.track_count, 'track', 'tracks')}
|
||||
· {formatDuration(album.duration_sec)}
|
||||
</p>
|
||||
{#snippet actions()}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import PlayActions from '#lib/components/PlayActions.svelte';
|
||||
import { shuffled } from '#lib/utils/shuffle.js';
|
||||
import { page } from '$app/state';
|
||||
@@ -86,7 +87,7 @@
|
||||
<LikeButton entityType="artist" entityId={detail.id} size="lg" />
|
||||
</div>
|
||||
<p class="text-sm text-text-secondary">
|
||||
{detail.album_count} {detail.album_count === 1 ? 'album' : 'albums'}
|
||||
{plural(detail.album_count, 'album', 'albums')}
|
||||
</p>
|
||||
<!-- Genre quick-jumps (#367). No year link here: an artist spans many,
|
||||
so a single year would be a lie about the discography. -->
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { createAlbumsAlphaInfiniteQuery } from '#lib/api/albums.js';
|
||||
import AlbumCard from '#lib/components/AlbumCard.svelte';
|
||||
@@ -35,7 +36,7 @@
|
||||
<h1 class="font-display text-2xl font-medium text-text-primary">Albums</h1>
|
||||
{#if !query.isPending && !(query.isError && !query.isFetchNextPageError)}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{total} {total === 1 ? 'album' : 'albums'}
|
||||
{plural(total, 'album', 'albums')}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { createArtistsQuery } from '#lib/api/queries.js';
|
||||
import ArtistCard from '#lib/components/ArtistCard.svelte';
|
||||
@@ -33,7 +34,7 @@
|
||||
<h1 class="font-display text-2xl font-medium text-text-primary">Artists</h1>
|
||||
{#if !query.isPending && !(query.isError && !query.isFetchNextPageError)}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{total} {total === 1 ? 'artist' : 'artists'}
|
||||
{plural(total, 'artist', 'artists')}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -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 { ChevronLeft } from 'lucide-svelte';
|
||||
@@ -131,7 +132,7 @@
|
||||
<h1 class="font-display text-2xl font-medium text-text-primary">{selected}</h1>
|
||||
{#if !loading || albums.length > 0}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{total} {total === 1 ? 'album' : 'albums'}
|
||||
{plural(total, 'album', 'albums')}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -183,7 +184,7 @@
|
||||
{#if filter.trim()}
|
||||
{visibleGenres.length} of {genres.length} genres
|
||||
{:else}
|
||||
{genres.length} {genres.length === 1 ? 'genre' : 'genres'}, straight from your file tags
|
||||
{plural(genres.length, 'genre', 'genres')}, straight from your file tags
|
||||
{/if}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
@@ -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 { ChevronLeft } from 'lucide-svelte';
|
||||
@@ -116,7 +117,7 @@
|
||||
<h1 class="font-display text-2xl font-medium text-text-primary">{selected}</h1>
|
||||
{#if !loading || albums.length > 0}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{total} {total === 1 ? 'album' : 'albums'}
|
||||
{plural(total, 'album', 'albums')}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -161,7 +162,7 @@
|
||||
<h1 class="font-display text-2xl font-medium text-text-primary">Years</h1>
|
||||
{#if !index.isPending && !index.isError}
|
||||
<p class="text-sm text-text-secondary">
|
||||
{years.length} {years.length === 1 ? 'year' : 'years'} with dated releases
|
||||
{plural(years.length, 'year', 'years')} with dated releases
|
||||
</p>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import PageColumn from '#lib/components/PageColumn.svelte';
|
||||
import { page } from '$app/state';
|
||||
import { goto } from '$app/navigation';
|
||||
@@ -272,7 +273,7 @@
|
||||
<p class="text-sm text-text-muted">{pl.description}</p>
|
||||
{/if}
|
||||
<p class="text-xs text-text-muted">
|
||||
{pl.track_count} {pl.track_count === 1 ? 'track' : 'tracks'}
|
||||
{plural(pl.track_count, 'track', 'tracks')}
|
||||
{#if pl.is_public}· public{:else}· private{/if}
|
||||
{#if !isOwner}· by {pl.owner_username}{/if}
|
||||
</p>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { Disc3, Album, Music2, X } from 'lucide-svelte';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
@@ -109,10 +110,10 @@
|
||||
{#if r.imported_album_count > 0 || r.imported_track_count > 0}
|
||||
<div class="text-sm text-accent-fg" data-testid="ingest-progress">
|
||||
{#if r.kind === 'artist'}
|
||||
{r.imported_album_count} {r.imported_album_count === 1 ? 'album' : 'albums'}
|
||||
· {r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{plural(r.imported_album_count, 'album', 'albums')}
|
||||
· {plural(r.imported_track_count, 'track', 'tracks')} ingested
|
||||
{:else if r.kind === 'album'}
|
||||
{r.imported_track_count} {r.imported_track_count === 1 ? 'track' : 'tracks'} ingested
|
||||
{plural(r.imported_track_count, 'track', 'tracks')} ingested
|
||||
{:else}
|
||||
Track ingested
|
||||
{/if}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { page } from '$app/state';
|
||||
import { createSearchAlbumsInfiniteQuery } from '#lib/api/queries.js';
|
||||
@@ -26,7 +27,7 @@
|
||||
</a>
|
||||
<h1 class="mt-2 text-2xl font-semibold">Albums matching '{q}'</h1>
|
||||
{#if q && !query?.isPending && !(query?.isError && albums.length === 0)}
|
||||
<p class="text-sm text-text-secondary">{total} {total === 1 ? 'album' : 'albums'}</p>
|
||||
<p class="text-sm text-text-secondary">{plural(total, 'album', 'albums')}</p>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { page } from '$app/state';
|
||||
import { createSearchArtistsInfiniteQuery } from '#lib/api/queries.js';
|
||||
@@ -26,7 +27,7 @@
|
||||
</a>
|
||||
<h1 class="mt-2 text-2xl font-semibold">Artists matching '{q}'</h1>
|
||||
{#if q && !query?.isPending && !(query?.isError && artists.length === 0)}
|
||||
<p class="text-sm text-text-secondary">{total} {total === 1 ? 'artist' : 'artists'}</p>
|
||||
<p class="text-sm text-text-secondary">{plural(total, 'artist', 'artists')}</p>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { plural } from '#lib/utils/plural.js';
|
||||
import PageColumn from '#lib/components/PageColumn.svelte';
|
||||
import { pageTitle } from '#lib/branding.js';
|
||||
import { page } from '$app/state';
|
||||
@@ -34,7 +35,7 @@
|
||||
</a>
|
||||
<h1 class="mt-2 font-display text-2xl font-medium text-text-primary">Tracks matching '{q}'</h1>
|
||||
{#if q && !query?.isPending && !(query?.isError && tracks.length === 0)}
|
||||
<p class="text-sm text-text-secondary">{total} {total === 1 ? 'track' : 'tracks'}</p>
|
||||
<p class="text-sm text-text-secondary">{plural(total, 'track', 'tracks')}</p>
|
||||
{/if}
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user