Added translation support for toast messages

This commit is contained in:
RemixDev
2020-07-21 11:09:47 +02:00
parent 57691329b3
commit 9d074bc538
9 changed files with 69 additions and 28 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -3
View File
File diff suppressed because one or more lines are too long
+12 -12
View File
@@ -44,7 +44,7 @@ socket.on('message', function(msg) {
}) })
socket.on('logging_in', function() { socket.on('logging_in', function() {
toast('Logging in', 'loading', false, 'login-toast') toast(i18n.t('toasts.loggingIn'), 'loading', false, 'login-toast')
}) })
socket.on('init_autologin', function() { socket.on('init_autologin', function() {
@@ -64,7 +64,7 @@ socket.on('logged_in', function(data) {
switch (data.status) { switch (data.status) {
case 1: case 1:
case 3: case 3:
toast('Logged in', 'done', true, 'login-toast') toast(i18n.t('toasts.loggedIn'), 'done', true, 'login-toast')
if (data.arl) { if (data.arl) {
localStorage.setItem('arl', data.arl) localStorage.setItem('arl', data.arl)
$('#login_input_arl').val(data.arl) $('#login_input_arl').val(data.arl)
@@ -82,7 +82,7 @@ socket.on('logged_in', function(data) {
document.getElementById('home_not_logged_in').classList.add('hide') document.getElementById('home_not_logged_in').classList.add('hide')
break break
case 2: case 2:
toast('Already logged in', 'done', true, 'login-toast') toast(i18n.t('toasts.alreadyLogged'), 'done', true, 'login-toast')
if (data.user) { if (data.user) {
$('#settings_username').text(data.user.name) $('#settings_username').text(data.user.name)
$('#settings_picture').attr( $('#settings_picture').attr(
@@ -95,7 +95,7 @@ socket.on('logged_in', function(data) {
document.getElementById('home_not_logged_in').classList.add('hide') document.getElementById('home_not_logged_in').classList.add('hide')
break break
case 0: case 0:
toast("Couldn't log in", 'close', true, 'login-toast') toast(i18n.t('toasts.loginFailed'), 'close', true, 'login-toast')
localStorage.removeItem('arl') localStorage.removeItem('arl')
$('#login_input_arl').val('') $('#login_input_arl').val('')
$('#open_login_prompt').show() $('#open_login_prompt').show()
@@ -109,7 +109,7 @@ socket.on('logged_in', function(data) {
}) })
socket.on('logged_out', function() { socket.on('logged_out', function() {
toast('Logged out', 'done', true, 'login-toast') toast(i18n.t('toasts.loggedOut'), 'done', true, 'login-toast')
localStorage.removeItem('arl') localStorage.removeItem('arl')
$('#login_input_arl').val('') $('#login_input_arl').val('')
$('#open_login_prompt').show() $('#open_login_prompt').show()
@@ -120,27 +120,27 @@ socket.on('logged_out', function() {
}) })
socket.on('cancellingCurrentItem', function(uuid) { socket.on('cancellingCurrentItem', function(uuid) {
toast('Cancelling current item.', 'loading', false, 'cancelling_' + uuid) toast(i18n.t('toasts.cancellingCurrentItem'), 'loading', false, 'cancelling_' + uuid)
}) })
socket.on('currentItemCancelled', function(uuid) { socket.on('currentItemCancelled', function(uuid) {
toast('Current item cancelled.', 'done', true, 'cancelling_' + uuid) toast(i18n.t('toasts.currentItemCancelled'), 'done', true, 'cancelling_' + uuid)
}) })
socket.on('startAddingArtist', function(data) { socket.on('startAddingArtist', function(data) {
toast(`Adding ${data.name} albums to queue`, 'loading', false, 'artist_' + data.id) toast(i18n.t('toasts.startAddingArtist', [data.name]), 'loading', false, 'artist_' + data.id)
}) })
socket.on('finishAddingArtist', function(data) { socket.on('finishAddingArtist', function(data) {
toast(`Added ${data.name} albums to queue`, 'done', true, 'artist_' + data.id) toast(i18n.t('toasts.finishAddingArtist', [data.name]), 'done', true, 'artist_' + data.id)
}) })
socket.on('startConvertingSpotifyPlaylist', function(id) { socket.on('startConvertingSpotifyPlaylist', function(id) {
toast('Converting spotify tracks to deezer tracks', 'loading', false, 'spotifyplaylist_' + id) toast(i18n.t('toasts.startConvertingSpotifyPlaylist'), 'loading', false, 'spotifyplaylist_' + id)
}) })
socket.on('finishConvertingSpotifyPlaylist', function(id) { socket.on('finishConvertingSpotifyPlaylist', function(id) {
toast('Spotify playlist converted', 'done', true, 'spotifyplaylist_' + id) toast(i18n.t('toasts.finishConvertingSpotifyPlaylist'), 'done', true, 'spotifyplaylist_' + id)
}) })
socket.on('errorMessage', function(error) { socket.on('errorMessage', function(error) {
@@ -148,5 +148,5 @@ socket.on('errorMessage', function(error) {
}) })
socket.on('alreadyInQueue', function(data) { socket.on('alreadyInQueue', function(data) {
toast(`${data.title} is already in queue!`, 'playlist_add_check') toast(i18n.t('toasts.alreadyInQueue', [data.title]), 'playlist_add_check')
}) })
+5 -4
View File
@@ -4,6 +4,7 @@
class="tab_hidden" class="tab_hidden"
@transitionend="$refs.container.style.transition = ''" @transitionend="$refs.container.style.transition = ''"
ref="container" ref="container"
:data-label="$t('downloads')"
> >
<div id="download_tab_drag_handler" @mousedown.prevent="startDrag" ref="dragHandler"></div> <div id="download_tab_drag_handler" @mousedown.prevent="startDrag" ref="dragHandler"></div>
<i <i
@@ -187,7 +188,7 @@ export default {
} }
if (!queueItem.init) { if (!queueItem.init) {
toast(`${queueItem.title} added to queue`, 'playlist_add_check') toast(this.$t('toasts.addedToQueue', [queueItem.title]), 'playlist_add_check')
} }
}, },
updateQueue(update) { updateQueue(update) {
@@ -280,7 +281,7 @@ export default {
}, },
finishDownload(uuid) { finishDownload(uuid) {
if (this.queue.indexOf(uuid) > -1) { if (this.queue.indexOf(uuid) > -1) {
toast(`${this.queueList[uuid].title} finished downloading.`, 'done') toast(this.$t('toasts.finishDownload', [this.queueList[uuid].title]), 'done')
$('#bar_' + uuid).css('width', '100%') $('#bar_' + uuid).css('width', '100%')
@@ -311,7 +312,7 @@ export default {
} }
if (this.queue.length <= 0) { if (this.queue.length <= 0) {
toast('All downloads completed!', 'done_all') toast(this.$t('toasts.allDownloaded'), 'done_all')
} }
} }
}, },
@@ -348,4 +349,4 @@ export default {
</script> </script>
<style> <style>
</style> </style>
+1 -1
View File
@@ -303,7 +303,7 @@ export default {
'animationiteration', 'animationiteration',
() => { () => {
this.$refs.reloadButton.classList.remove('spin') this.$refs.reloadButton.classList.remove('spin')
toast('Refresh completed!', 'done', true) toast(this.$t('toasts.refreshFavs'), 'done', true)
}, },
{ once: true } { once: true }
) )
+2 -4
View File
@@ -1,10 +1,8 @@
<template> <template>
<div id="search_tab" class="main_tabcontent" @click="handleSearchTabClick"> <div id="search_tab" class="main_tabcontent" @click="handleSearchTabClick">
<div :class="{ hide: results.query != '' }"> <div :class="{ hide: results.query != '' }">
<h2>Start searching!</h2> <h2>{{ $t('search.startSearching') }}</h2>
<p> <p>{{ $t('search.description') }}</p>
You can search a track, a whole album, an artist, a playlist.... everything! You can also paste a Deezer link
</p>
</div> </div>
<div v-show="results.query !== ''"> <div v-show="results.query !== ''">
<ul class="section-tabs"> <ul class="section-tabs">
+19
View File
@@ -73,6 +73,25 @@ const en = {
'You can search a track, a whole album, an artist, a playlist.... everything! You can also paste a Deezer link' 'You can search a track, a whole album, an artist, a playlist.... everything! You can also paste a Deezer link'
}, },
searchbar: 'Search anything you want (or just paste a link)', searchbar: 'Search anything you want (or just paste a link)',
downloads: 'downloads',
toasts: {
addedToQueue: '{0} added to queue',
alreadyInQueue: '{0} is already in queue!',
finishDownload: '{0} finished downloading.',
allDownloaded: 'All downloads completed!',
refreshFavs: 'Refresh completed!',
loggingIn: 'Logging in',
loggedIn: 'Logged in',
alreadyLogged: 'Already logged in',
loginFailed: 'Couldn\'t log in',
loggedOut: 'Logged out',
cancellingCurrentItem: 'Cancelling current item.',
currentItemCancelled: 'Current item cancelled.',
startAddingArtist: 'Adding {0} albums to queue',
finishAddingArtist: 'Added {0} albums to queue',
startConvertingSpotifyPlaylist: 'Converting spotify tracks to deezer tracks',
finishConvertingSpotifyPlaylist: 'Spotify playlist converted'
},
settings: { settings: {
title: 'Settings', title: 'Settings',
languages: 'Languages', languages: 'Languages',
+25 -2
View File
@@ -68,7 +68,30 @@ const it = {
tracklist: 'Lista tracce' tracklist: 'Lista tracce'
} }
}, },
search: {
startSearching: 'Inizia a cercare!',
description:
'Puoi cercare una traccia, un intero album, un artista, una playlist.... quello che vuoi! Puoi anche incollare un link di Deezer'
},
searchbar: 'Cerca qualsiasi cosa (o incolla semplicemente un link)', searchbar: 'Cerca qualsiasi cosa (o incolla semplicemente un link)',
downloads: 'download',
toasts: {
addedToQueue: '{0} aggiunto alla coda',
finishDownload: '{0} ha finito di scaricarsi.',
allDownloaded: 'Tutti i download completati!',
refreshFavs: 'Preferiti ricaricati!',
loggingIn: 'Effettuando il login',
loggedIn: 'Login effettuato',
alreadyLogged: 'Sei già loggato',
loginFailed: 'Impossibile loggarsi',
loggedOut: 'Disconnesso',
cancellingCurrentItem: 'Cancellando download corrente.',
currentItemCancelled: 'Download corrente cancellato.',
startAddingArtist: 'Aggiungendo gli album di {0} alla coda',
finishAddingArtist: 'Aggiunto gli album di {0} alla coda',
startConvertingSpotifyPlaylist: 'Convertendo le tracce da spotify a deezer',
finishConvertingSpotifyPlaylist: 'Playlist di spotify convertita'
},
settings: { settings: {
title: 'Impostazioni', title: 'Impostazioni',
languages: 'Lingue', languages: 'Lingue',
@@ -104,7 +127,7 @@ const it = {
albumNameTemplate: 'Template nome della cartella Album', albumNameTemplate: 'Template nome della cartella Album',
createCDFolder: 'Crea cartelle per i CD', createCDFolder: 'Crea cartelle per i CD',
createStructurePlaylist: 'Crea la struttura di cartelle per le Playlist', createStructurePlaylist: 'Crea la struttura di cartelle per le Playlist',
createSingleFolder: 'Crea la struttura di cartelle per le traccie singole' createSingleFolder: 'Crea la struttura di cartelle per le tracce singole'
}, },
trackTitles: { trackTitles: {
title: 'Titoli tracce', title: 'Titoli tracce',
@@ -159,7 +182,7 @@ const it = {
album: 'Album', album: 'Album',
cover: 'Copertina', cover: 'Copertina',
trackNumber: 'Numero Traccia', trackNumber: 'Numero Traccia',
trackTotal: 'Traccie Totali', trackTotal: 'Tracce Totali',
discNumber: 'Numero Disco', discNumber: 'Numero Disco',
discTotal: 'Dischi Totali', discTotal: 'Dischi Totali',
albumArtist: "Artista dell'album", albumArtist: "Artista dell'album",
+1 -1
View File
@@ -38,7 +38,7 @@
} }
&::after { &::after {
content: 'downloads'; content: attr(data-label);
display: flex; display: flex;
align-items: center; align-items: center;
text-transform: capitalize; text-transform: capitalize;