fix(playlist): migrate duplicate modal to Svelte 5 and add i18n
Migrate PlaylistDuplicateConfirmModal from Svelte 4 (export let, createEventDispatcher, on:click) to Svelte 5 ($props, callback props, onclick). Replace hardcoded English strings with i18n keys under playlist.duplicates for all 4 locales (en, es, de, fr).
This commit is contained in:
1 parent
ae1a3533a8
commit
f85d04fa68
6 files changed
+63
-37
No files matched your search
@@ -1,40 +1,38 @@
|
||||
<script lang="ts">
|
||||
import { createEventDispatcher } from 'svelte';
|
||||
import { t } from '$lib/i18n';
|
||||
import Modal from './Modal.svelte';
|
||||
import type { PlaylistDuplicateResult } from '$lib/types/index';
|
||||
|
||||
export let isOpen = false;
|
||||
export let duplicateResult: PlaylistDuplicateResult | null = null;
|
||||
export let loading = false;
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function handleAddAll() {
|
||||
dispatch('addAll');
|
||||
interface Props {
|
||||
isOpen: boolean;
|
||||
duplicateResult: PlaylistDuplicateResult | null;
|
||||
loading?: boolean;
|
||||
onAddAll: () => void;
|
||||
onSkipDuplicates: () => void;
|
||||
onCancel: () => void;
|
||||
}
|
||||
|
||||
function handleSkipDuplicates() {
|
||||
dispatch('skipDuplicates');
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
dispatch('cancel');
|
||||
}
|
||||
let {
|
||||
isOpen,
|
||||
duplicateResult,
|
||||
loading = false,
|
||||
onAddAll,
|
||||
onSkipDuplicates,
|
||||
onCancel
|
||||
}: Props = $props();
|
||||
|
||||
function handleClose() {
|
||||
if (!loading) {
|
||||
dispatch('cancel');
|
||||
onCancel();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Modal {isOpen} onClose={handleClose} title={'You\'ve added some of these tracks before'}>
|
||||
<Modal {isOpen} onClose={handleClose} title={$t('playlist.duplicates.title')}>
|
||||
{#if duplicateResult}
|
||||
<div class="duplicate-info">
|
||||
<p>
|
||||
This playlist already contains <strong>{duplicateResult.duplicate_count}</strong> of the
|
||||
track{duplicateResult.duplicate_count !== 1 ? 's' : ''} you're adding.
|
||||
Add only the new ones, or add everything including duplicates ({duplicateResult.total_tracks} track{duplicateResult.total_tracks !== 1 ? 's' : ''}).
|
||||
{$t('playlist.duplicates.description', { values: { duplicateCount: duplicateResult.duplicate_count, totalCount: duplicateResult.total_tracks } })}
|
||||
</p>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -43,25 +41,25 @@
|
||||
<div class="footer-right">
|
||||
<button
|
||||
class="btn btn-secondary"
|
||||
on:click={handleAddAll}
|
||||
onclick={onAddAll}
|
||||
disabled={loading}
|
||||
>
|
||||
{#if loading}
|
||||
Adding...
|
||||
{$t('playlist.duplicates.adding')}
|
||||
{:else}
|
||||
Add all tracks
|
||||
{$t('playlist.duplicates.addAll')}
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
<button
|
||||
class="btn btn-primary"
|
||||
on:click={handleSkipDuplicates}
|
||||
onclick={onSkipDuplicates}
|
||||
disabled={loading || duplicateResult?.duplicate_count === 0}
|
||||
>
|
||||
{#if loading}
|
||||
Adding...
|
||||
{$t('playlist.duplicates.adding')}
|
||||
{:else}
|
||||
Add only new tracks
|
||||
{$t('playlist.duplicates.addNew')}
|
||||
{/if}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -820,12 +820,12 @@
|
||||
{/if}
|
||||
|
||||
<PlaylistDuplicateConfirmModal
|
||||
bind:isOpen={showDuplicateConfirm}
|
||||
bind:duplicateResult={duplicateResult}
|
||||
bind:loading={loading}
|
||||
on:addAll={handleDuplicateAddAll}
|
||||
on:skipDuplicates={handleDuplicateSkipDuplicates}
|
||||
on:cancel={handleDuplicateCancel}
|
||||
isOpen={showDuplicateConfirm}
|
||||
{duplicateResult}
|
||||
{loading}
|
||||
onAddAll={handleDuplicateAddAll}
|
||||
onSkipDuplicates={handleDuplicateSkipDuplicates}
|
||||
onCancel={handleDuplicateCancel}
|
||||
/>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -271,7 +271,14 @@
|
||||
"createNewPlaylist": "Neue Playlist erstellen",
|
||||
"newPlaylist": "Neue Playlist",
|
||||
"editPlaylist": "Playlist bearbeiten",
|
||||
"addToPlaylist": "Zur Playlist hinzufügen"
|
||||
"addToPlaylist": "Zur Playlist hinzufügen",
|
||||
"duplicates": {
|
||||
"title": "Einige dieser Titel wurden bereits hinzugefügt",
|
||||
"description": "Diese Playlist enthält bereits {duplicateCount} der {totalCount} Titel, die du hinzufügst. Füge nur die neuen hinzu oder füge alle einschließlich Duplikate hinzu.",
|
||||
"addAll": "Alle Titel hinzufügen",
|
||||
"addNew": "Nur neue Titel hinzufügen",
|
||||
"adding": "Wird hinzugefügt..."
|
||||
}
|
||||
},
|
||||
"favorites": {
|
||||
"title": "Favoriten",
|
||||
|
||||
@@ -273,7 +273,14 @@
|
||||
"hideFromSidebar": "Hide from sidebar",
|
||||
"createAndAdd": "Create & Add",
|
||||
"playlistWithTracks": "{name} ({count} tracks)",
|
||||
"copyToLibrary": "Copy to library"
|
||||
"copyToLibrary": "Copy to library",
|
||||
"duplicates": {
|
||||
"title": "Some of these tracks were already added",
|
||||
"description": "This playlist already contains {duplicateCount} of the {totalCount} tracks you're adding. Add only the new ones, or add everything including duplicates.",
|
||||
"addAll": "Add all tracks",
|
||||
"addNew": "Add only new tracks",
|
||||
"adding": "Adding..."
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"nameAZ": "Name (A-Z)",
|
||||
|
||||
@@ -273,7 +273,14 @@
|
||||
"hideFromSidebar": "Ocultar de la barra lateral",
|
||||
"createAndAdd": "Crear y Agregar",
|
||||
"playlistWithTracks": "{name} ({count} pistas)",
|
||||
"copyToLibrary": "Copiar a mi biblioteca"
|
||||
"copyToLibrary": "Copiar a mi biblioteca",
|
||||
"duplicates": {
|
||||
"title": "Algunas de estas pistas ya fueron agregadas",
|
||||
"description": "Esta lista ya contiene {duplicateCount} de las {totalCount} pistas que estás agregando. Agrega solo las nuevas o agrega todas incluyendo duplicadas.",
|
||||
"addAll": "Agregar todas",
|
||||
"addNew": "Agregar solo nuevas",
|
||||
"adding": "Agregando..."
|
||||
}
|
||||
},
|
||||
"sort": {
|
||||
"nameAZ": "Nombre (A-Z)",
|
||||
|
||||
@@ -271,7 +271,14 @@
|
||||
"createNewPlaylist": "Créer une nouvelle playlist",
|
||||
"newPlaylist": "Nouvelle playlist",
|
||||
"editPlaylist": "Modifier la playlist",
|
||||
"addToPlaylist": "Ajouter à la playlist"
|
||||
"addToPlaylist": "Ajouter à la playlist",
|
||||
"duplicates": {
|
||||
"title": "Certaines de ces pistes ont déjà été ajoutées",
|
||||
"description": "Cette playlist contient déjà {duplicateCount} des {totalCount} pistes que vous ajoutez. Ajoutez uniquement les nouvelles ou ajoutez tout y compris les doublons.",
|
||||
"addAll": "Ajouter toutes les pistes",
|
||||
"addNew": "Ajouter uniquement les nouvelles",
|
||||
"adding": "Ajout en cours..."
|
||||
}
|
||||
},
|
||||
"favorites": {
|
||||
"title": "Favoris",
|
||||
|
||||
Reference in new issue
Block a user