Skip to content

Commit

Permalink
add translations for playlist add toast
Browse files Browse the repository at this point in the history
  • Loading branch information
dweymouth committed Jan 5, 2025
1 parent 1891378 commit dd92d64
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 20 deletions.
7 changes: 6 additions & 1 deletion res/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,10 @@
"Sept": "Sept",
"Oct": "Okt",
"Nov": "Nov",
"Dec": "Dec"
"Dec": "Dec",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,5 +242,10 @@
"Sept": "Sept",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dec"
"Dec": "Dec",

"playlist.addedtracks": {
"one": "Added one track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,5 +241,10 @@
"Sept": "Set",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dic"
"Dec": "Dic",

"playlist.addedtracks": {
"one": "Se ha añadido una pista a la lista de reproducción",
"other": "Se han añadido {{.trackCount}} pistas a la lista de reproducción"
}
}
7 changes: 6 additions & 1 deletion res/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,5 +240,10 @@
"Sept": "Sept",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Déc"
"Dec": "Déc",

"playlist.addedtracks": {
"one": "Une piste ajoutée à la liste de lecture",
"other": "{{.trackCount}} pistes ajoutées à la liste de lecture"
}
}
7 changes: 6 additions & 1 deletion res/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,10 @@
"Sept": "Set",
"Oct": "Ott",
"Nov": "Nov",
"Dec": "Dic"
"Dec": "Dic",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@
"Remove from queue": "キューから削除",
"Play song radio": "曲をラジオで再生",
"to":"to",
"by":"by"
"by":"by",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@
"Remove from queue": "Usuń z kolejki odtwarzania",
"Play song radio": "Odtwórz mix utworów",
"to":"do",
"by":"przez"
"by":"przez",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,10 @@
"Remove from queue": "Remover da fila",
"Play song radio": "Reproduzir rádio da faixa",
"to":"a",
"by":"de"
"by":"de",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/ro.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,5 +230,10 @@
"Sept": "Sept",
"Oct": "Oct",
"Nov": "Noiem",
"Dec": "Dec"
"Dec": "Dec",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,10 @@
"Unset favorite": "取消收藏",
"Remove from queue": "从队列中移除",
"Size": "大小",
"Play song radio": "播放歌曲电台"
"Play song radio": "播放歌曲电台",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
7 changes: 6 additions & 1 deletion res/translations/zhHans.json
Original file line number Diff line number Diff line change
Expand Up @@ -216,5 +216,10 @@
"Unset favorite": "取消收藏",
"Remove from queue": "从队列中移除",
"Size": "大小",
"Play song radio": "播放歌曲电台"
"Play song radio": "播放歌曲电台",

"playlist.addedtracks": {
"one": "Added {{.trackCount}} track to playlist",
"other": "Added {{.trackCount}} tracks to playlist"
}
}
15 changes: 9 additions & 6 deletions ui/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"net/url"
"os"
"path/filepath"
"strconv"
"sync"
"time"

Expand Down Expand Up @@ -304,14 +305,18 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
m.doModalClosed()
})
sp.SetOnNavigateTo(func(contentType mediaprovider.ContentType, id string) {
notifySuccess := func(n int) {
msg := lang.LocalizePluralKey("playlist.addedtracks",
"Added tracks to playlist", n, map[string]string{"trackCount": strconv.Itoa(n)})
m.ToastProvider.ShowSuccessToast(msg)
}
pop.Hide()
m.App.Config.Application.AddToPlaylistSkipDuplicates = sp.SkipDuplicates
if id == "" /* creating new playlist */ {
go func() {
err := m.App.ServerManager.Server.CreatePlaylist(sp.SearchDialog.SearchQuery(), trackIDs)
if err == nil {
// TODO: translate, adjust by plurality
m.ToastProvider.ShowSuccessToast(fmt.Sprintf("Added %d tracks to playlist", len(trackIDs)))
notifySuccess(len(trackIDs))
}
}()
} else {
Expand All @@ -331,17 +336,15 @@ func (m *Controller) DoAddTracksToPlaylistWorkflow(trackIDs []string) {
})
err := m.App.ServerManager.Server.AddPlaylistTracks(id, filterTrackIDs)
if err == nil {
// TODO: translate, adjust by plurality
m.ToastProvider.ShowSuccessToast(fmt.Sprintf("Added %d tracks to playlist", len(filterTrackIDs)))
notifySuccess(len(filterTrackIDs))
}
}
}()
} else {
go func() {
err := m.App.ServerManager.Server.AddPlaylistTracks(id, trackIDs)
if err == nil {
// TODO: translate, adjust by plurality
m.ToastProvider.ShowSuccessToast(fmt.Sprintf("Added %d tracks to playlist", len(trackIDs)))
notifySuccess(len(trackIDs))
}
}()
}
Expand Down
11 changes: 8 additions & 3 deletions ui/toastoverlay.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (
"github.com/dweymouth/supersonic/ui/widgets"
)

const (
toastAutoDismissalTime = 3 * time.Second
toastAnimationDuration = 100 * time.Millisecond
)

type ToastOverlay struct {
widget.BaseWidget

Expand Down Expand Up @@ -46,15 +51,15 @@ func (t *ToastOverlay) ShowSuccessToast(message string) {
endPos := fyne.NewPos(s.Width-min.Width-pad, s.Height-min.Height-pad)
startPos := fyne.NewPos(s.Width, endPos.Y)
f := t.makeToastAnimFunc(endPos, false)
t.currentToastAnim = canvas.NewPositionAnimation(startPos, endPos, 100*time.Millisecond, f)
t.currentToastAnim = canvas.NewPositionAnimation(startPos, endPos, toastAnimationDuration, f)
t.currentToastAnim.Curve = fyne.AnimationEaseOut
t.currentToastAnim.Start()
t.Refresh()

ctx, cancel := context.WithCancel(context.Background())
t.dismissCancel = cancel // always canceled by dismissToast
go func() {
time.Sleep(2 * time.Second)
time.Sleep(toastAutoDismissalTime)
select {
case <-ctx.Done():
return
Expand Down Expand Up @@ -120,7 +125,7 @@ func (t *ToastOverlay) dismissToast() {
startPos := fyne.NewPos(s.Width-min.Width-pad, s.Height-min.Height-pad)
endPos := fyne.NewPos(s.Width, startPos.Y)
f := t.makeToastAnimFunc(endPos, true)
t.currentToastAnim = canvas.NewPositionAnimation(startPos, endPos, 100*time.Millisecond, f)
t.currentToastAnim = canvas.NewPositionAnimation(startPos, endPos, toastAnimationDuration, f)
t.currentToastAnim.Curve = fyne.AnimationEaseIn
t.currentToastAnim.Start()
}
Expand Down

0 comments on commit dd92d64

Please sign in to comment.