Add plural keys for albums and tracks

This commit is contained in:
Alexey Remizov
2025-06-27 08:09:08 -07:00
committed by Drew Weymouth
parent bb8d677aab
commit 097310504c
6 changed files with 37 additions and 5 deletions
+14
View File
@@ -277,5 +277,19 @@
"few": "{{.trackCount}} композиции добавлены в список воспроизведения",
"many": "{{.trackCount}} композиций добавлены в список воспроизведения",
"other": "{{.trackCount}} композиций добавлены в список воспроизведения"
},
"{{.trackCount}} tracks": {
"one": "{{.trackCount}} композиция",
"few": "{{.trackCount}} композиции",
"many": "{{.trackCount}} композиций",
"other": "{{.trackCount}} композиций"
},
"{{.albumsCount}} albums": {
"one": "{{.albumsCount}} альбом",
"few": "{{.albumsCount}} альбома",
"many": "{{.albumsCount}} альбомов",
"other": "{{.albumsCount}} альбомов"
}
}
+5 -1
View File
@@ -3,6 +3,7 @@ package browsing
import (
"fmt"
"log"
"strconv"
"strings"
"github.com/dweymouth/supersonic/backend"
@@ -396,11 +397,14 @@ func formatMiscLabelStr(a *mediaprovider.AlbumWithTracks) string {
if a.TrackCount == 1 {
tracks = lang.L("track")
}
fallbackTracksMsg := fmt.Sprintf("%d %s", a.TrackCount, tracks)
tracksMsg := lang.LocalizePluralKey("{{.trackCount}} tracks",
fallbackTracksMsg, a.TrackCount, map[string]string{"trackCount": strconv.Itoa(a.TrackCount)})
yearStr := util.FormatItemDate(a.Date)
if y := a.ReissueDate.Year; y != nil && *y > a.YearOrZero() {
yearStr += fmt.Sprintf(" (%s %s)", lang.L("reissued"), util.FormatItemDate(a.ReissueDate))
}
return fmt.Sprintf("%s · %d %s · %s%s", yearStr, a.TrackCount, tracks, discs, util.SecondsToTimeString(float64(a.Duration)))
return fmt.Sprintf("%s · %s · %s%s", yearStr, tracksMsg, discs, util.SecondsToTimeString(float64(a.Duration)))
}
func (s *albumPageState) Restore() Page {
+5 -1
View File
@@ -3,6 +3,7 @@ package browsing
import (
"fmt"
"log"
"strconv"
"github.com/dweymouth/supersonic/backend"
"github.com/dweymouth/supersonic/backend/mediaprovider"
@@ -389,11 +390,14 @@ func buildArtistGridViewModel(artists []*mediaprovider.Artist) []widgets.GridVie
if ar.AlbumCount == 1 {
albums = lang.L("album")
}
fallbackAlbumsMsg := fmt.Sprintf("%d %s", ar.AlbumCount, albums)
albumsMsg := lang.LocalizePluralKey("{{.albumsCount}} albums",
fallbackAlbumsMsg, ar.AlbumCount, map[string]string{"albumsCount": strconv.Itoa(ar.AlbumCount)})
model = append(model, widgets.GridViewItemModel{
ID: ar.ID,
CoverArtID: ar.CoverArtID,
Name: ar.Name,
Secondary: []string{fmt.Sprintf("%d %s", ar.AlbumCount, albums)},
Secondary: []string{albumsMsg},
CanFavorite: true,
IsFavorite: ar.Favorite,
})
+5 -1
View File
@@ -3,6 +3,7 @@ package browsing
import (
"fmt"
"log"
"strconv"
"strings"
"github.com/deluan/sanitize"
@@ -510,7 +511,10 @@ func (a *PlaylistPageHeader) formatPlaylistTrackTimeStr(p *mediaprovider.Playlis
} else {
tracks = lang.L("tracks")
}
return fmt.Sprintf("%d %s, %s", p.TrackCount, tracks, util.SecondsToTimeString(float64(p.Duration)))
fallbackTracksMsg := fmt.Sprintf("%d %s", p.TrackCount, tracks)
tracksMsg := lang.LocalizePluralKey("{{.trackCount}} tracks",
fallbackTracksMsg, p.TrackCount, map[string]string{"trackCount": strconv.Itoa(p.TrackCount)})
return fmt.Sprintf("%s, %s", tracksMsg, util.SecondsToTimeString(float64(p.Duration)))
}
func (s *playlistPageState) Restore() Page {
+4 -1
View File
@@ -206,11 +206,14 @@ func createPlaylistGridViewModel(playlists []*mediaprovider.Playlist) []widgets.
} else {
tracks = lang.L("tracks")
}
fallbackTracksMsg := fmt.Sprintf("%d %s", pl.TrackCount, tracks)
tracksMsg := lang.LocalizePluralKey("{{.trackCount}} tracks",
fallbackTracksMsg, pl.TrackCount, map[string]string{"trackCount": strconv.Itoa(pl.TrackCount)})
return widgets.GridViewItemModel{
Name: pl.Name,
ID: pl.ID,
CoverArtID: pl.CoverArtID,
Secondary: []string{fmt.Sprintf("%d %s", pl.TrackCount, tracks)},
Secondary: []string{tracksMsg},
}
})
}
+4 -1
View File
@@ -98,11 +98,14 @@ func (g gridViewArtistIterator) NextN(n int) []GridViewItemModel {
if ar.AlbumCount == 1 {
albumsLabel = lang.L("album")
}
fallbackAlbumsMsg := fmt.Sprintf("%d %s", ar.AlbumCount, albumsLabel)
albumsMsg := lang.LocalizePluralKey("{{.albumsCount}} albums",
fallbackAlbumsMsg, ar.AlbumCount, map[string]string{"albumsCount": strconv.Itoa(ar.AlbumCount)})
return GridViewItemModel{
Name: ar.Name,
ID: ar.ID,
CoverArtID: ar.CoverArtID,
Secondary: []string{fmt.Sprintf("%d %s", ar.AlbumCount, albumsLabel)},
Secondary: []string{albumsMsg},
CanFavorite: true,
IsFavorite: ar.Favorite,
}