From 0d2bca0a840f270d665220127c5834250654e070 Mon Sep 17 00:00:00 2001 From: Drew Weymouth Date: Sat, 20 Jul 2024 09:35:41 -0700 Subject: [PATCH] more translation prep --- res/translations/en.json | 22 ++++++++++++++++++++++ ui/dialogs/addeditserverdialog.go | 23 ++++++++++++----------- ui/dialogs/albuminfodialog.go | 5 +++-- ui/dialogs/editplaylistdialog.go | 15 ++++++++------- ui/dialogs/logindialog.go | 9 +++++---- ui/dialogs/selectplaylist.go | 5 +++-- 6 files changed, 53 insertions(+), 26 deletions(-) diff --git a/res/translations/en.json b/res/translations/en.json index cfa702a..9169def 100644 --- a/res/translations/en.json +++ b/res/translations/en.json @@ -4,23 +4,38 @@ "Album": "Album", "Album count": "Album count", "Album gain": "Album gain", + "Album info not available": "Album info not available", "Album peak": "Album peak", "All Tracks": "All Tracks", + "Alt. URL": "Alt. URL", "Artist": "Artist", "Artists": "Artists", "Artist biography not available.": "Artist biography not available.", + "Cancel": "Cancel", + "Close": "Close", "Configure your music server to add radio stations": "Configure your music server to add radio stations", + "Create new playlist": "Create new playlist", + "Delete Playlist": "Delete Playlist", + "Description": "Description", "Discography": "Discography", "Download": "Download", "Duration": "Duration", "Edit": "Edit", + "Edit Playlist": "Edit Playlist", + "Enter": "Enter", "Favorites": "Favorites", "Genre": "Genre", "Genres": "Genres", "Internet Radio Stations": "Internet Radio Stations", + "Login to Server": "Login to Server", "Lyrics": "Lyrics", + "My Server": "My Server", "Name": "Name", + "Nickname": "Nickname", "No radio stations available": "No radio stations available", + "OK": "OK", + "(optional)": "(optional)", + "Password": "Password", "Play": "Play", "Playlist": "Playlist", "Playlists": "Playlists", @@ -33,10 +48,14 @@ "Related": "Related", "Remove from playlist": "Remove from playlist", "Search page": "Search page", + "Search playlists or new playlist name": "Search playlists or new playlist name", + "Server": "Server", + "Server Type": "Server Type", "Share": "Share", "Show info": "Show info", "Shuffle": "Shuffle", "Similar artists": "Similar artists", + "Skip duplicate tracks": "Skip duplicate tracks", "Title": "Title", "Top Tracks": "Top Tracks", "Track": "Track", @@ -45,5 +64,8 @@ "Track count": "Track count", "Track gain": "Track gain", "Track peak": "Track peak", + "URL": "URL", + "Use legacy authentication": "Use legacy authentication", + "Username": "Username", "Year": "Year" } \ No newline at end of file diff --git a/ui/dialogs/addeditserverdialog.go b/ui/dialogs/addeditserverdialog.go index 7ad0ac1..b48b5f2 100644 --- a/ui/dialogs/addeditserverdialog.go +++ b/ui/dialogs/addeditserverdialog.go @@ -6,6 +6,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/data/binding" + "fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" @@ -46,7 +47,7 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen titleLabel := widget.NewLabel(title) titleLabel.TextStyle.Bold = true - legacyAuthCheck := widget.NewCheckWithData("Use legacy authentication", binding.BindBool(&a.LegacyAuth)) + legacyAuthCheck := widget.NewCheckWithData(lang.L("Use legacy authentication"), binding.BindBool(&a.LegacyAuth)) serverTypeChoice := widget.NewRadioGroup([]string{"Subsonic", "Jellyfin"}, func(s string) { a.ServerType = backend.ServerType(s) if s == string(backend.ServerTypeSubsonic) { @@ -67,15 +68,15 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen userField := widget.NewEntryWithData(binding.BindString(&a.Username)) userField.OnSubmitted = func(_ string) { focusHandler(a.passField) } altHostField := widget.NewEntryWithData(binding.BindString(&a.AltHost)) - altHostField.SetPlaceHolder("(optional) https://my-external-domain.net/music") + altHostField.SetPlaceHolder(lang.L("(optional)") + " https://my-external-domain.net/music") altHostField.OnSubmitted = func(_ string) { focusHandler(userField) } hostField := widget.NewEntryWithData(binding.BindString(&a.Host)) hostField.SetPlaceHolder("http://localhost:4533") hostField.OnSubmitted = func(_ string) { focusHandler(altHostField) } nickField := widget.NewEntryWithData(binding.BindString(&a.Nickname)) - nickField.SetPlaceHolder("My Server") + nickField.SetPlaceHolder(lang.L("My Server")) nickField.OnSubmitted = func(_ string) { focusHandler(hostField) } - a.submitBtn = widget.NewButton("Enter", a.doSubmit) + a.submitBtn = widget.NewButton(lang.L("Enter"), a.doSubmit) a.submitBtn.Importance = widget.HighImportance a.promptText = widget.NewRichTextWithText("") a.promptText.Hidden = true @@ -85,7 +86,7 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen bottomRow = container.NewHBox( a.promptText, layout.NewSpacer(), - widget.NewButton("Cancel", a.onCancel), + widget.NewButton(lang.L("Cancel"), a.onCancel), a.submitBtn) } else { bottomRow = container.NewHBox( @@ -97,17 +98,17 @@ func NewAddEditServerDialog(title string, cancelable bool, prefillServer *backen a.container = container.NewVBox( container.NewHBox(layout.NewSpacer(), titleLabel, layout.NewSpacer()), container.New(layout.NewFormLayout(), - widget.NewLabel("Type"), + widget.NewLabel(lang.L("Server Type")), serverTypeChoice, - widget.NewLabel("Nickname"), + widget.NewLabel(lang.L("Nickname")), nickField, - widget.NewLabel("URL"), + widget.NewLabel(lang.L("URL")), hostField, - widget.NewLabel("Alt. URL"), + widget.NewLabel(lang.L("Alt. URL")), altHostField, - widget.NewLabel("Username"), + widget.NewLabel(lang.L("Username")), userField, - widget.NewLabel("Password"), + widget.NewLabel(lang.L("Password")), a.passField, ), container.NewHBox(layout.NewSpacer(), legacyAuthCheck), diff --git a/ui/dialogs/albuminfodialog.go b/ui/dialogs/albuminfodialog.go index 3ecf486..2110082 100644 --- a/ui/dialogs/albuminfodialog.go +++ b/ui/dialogs/albuminfodialog.go @@ -11,6 +11,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/canvas" "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/theme" @@ -36,7 +37,7 @@ func NewAlbumInfoDialog(albumInfo *mediaprovider.AlbumInfo, albumName string, al widget.NewSeparator(), container.NewHBox( layout.NewSpacer(), - widget.NewButton("Close", func() { + widget.NewButton(lang.L("Close"), func() { if a.OnDismiss != nil { a.OnDismiss() } @@ -61,7 +62,7 @@ func (a *AlbumInfoDialog) buildMainContainer(albumInfo *mediaprovider.AlbumInfo, title.Segments[0].(*widget.TextSegment).Style.Alignment = fyne.TextAlignCenter title.Truncation = fyne.TextTruncateEllipsis - infoContent := widget.NewLabel("Album info not available") + infoContent := widget.NewLabel(lang.L("Album info not available")) if albumInfo.Notes != "" { infoContent = a.infoLabel(albumInfo.Notes) diff --git a/ui/dialogs/editplaylistdialog.go b/ui/dialogs/editplaylistdialog.go index 20320b7..7ffaccb 100644 --- a/ui/dialogs/editplaylistdialog.go +++ b/ui/dialogs/editplaylistdialog.go @@ -4,6 +4,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/data/binding" + "fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/widget" "github.com/dweymouth/supersonic/backend/mediaprovider" @@ -31,33 +32,33 @@ func NewEditPlaylistDialog(playlist *mediaprovider.Playlist, showPublicCheck boo } e.ExtendBaseWidget(e) - isPublicCheck := widget.NewCheckWithData("Public", binding.BindBool(&e.IsPublic)) + isPublicCheck := widget.NewCheckWithData(lang.L("Public"), binding.BindBool(&e.IsPublic)) isPublicCheck.Hidden = !showPublicCheck nameEntry := widget.NewEntryWithData(binding.BindString(&e.Name)) descriptionEntry := widget.NewEntryWithData(binding.BindString(&e.Description)) - deleteBtn := widget.NewButton("Delete Playlist", func() { + deleteBtn := widget.NewButton(lang.L("Delete Playlist"), func() { if e.OnDeletePlaylist != nil { e.OnDeletePlaylist() } }) - submitBtn := widget.NewButton("OK", func() { + submitBtn := widget.NewButton(lang.L("OK"), func() { if e.OnUpdateMetadata != nil { e.OnUpdateMetadata() } }) submitBtn.Importance = widget.HighImportance - cancelBtn := widget.NewButton("Cancel", func() { + cancelBtn := widget.NewButton(lang.L("Cancel"), func() { if e.OnCanceled != nil { e.OnCanceled() } }) e.container = container.NewVBox( - container.NewHBox(layout.NewSpacer(), widget.NewLabel("Edit Playlist"), layout.NewSpacer()), + container.NewHBox(layout.NewSpacer(), widget.NewLabel(lang.L("Edit Playlist")), layout.NewSpacer()), container.New(layout.NewFormLayout(), - widget.NewLabel("Name"), + widget.NewLabel(lang.L("Name")), nameEntry, - widget.NewLabel("Description"), + widget.NewLabel(lang.L("Description")), descriptionEntry, ), container.NewHBox(isPublicCheck, layout.NewSpacer(), deleteBtn), diff --git a/ui/dialogs/logindialog.go b/ui/dialogs/logindialog.go index 6d083cd..5d90d89 100644 --- a/ui/dialogs/logindialog.go +++ b/ui/dialogs/logindialog.go @@ -7,6 +7,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" + "fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/layout" "fyne.io/fyne/v2/theme" "fyne.io/fyne/v2/widget" @@ -37,7 +38,7 @@ var _ fyne.Widget = (*LoginDialog)(nil) func NewLoginDialog(servers []*backend.ServerConfig, pwFetch PasswordFetchFunc) *LoginDialog { l := &LoginDialog{servers: servers} l.ExtendBaseWidget(l) - titleLabel := widget.NewLabel("Login to Server") + titleLabel := widget.NewLabel(lang.L("Login to Server")) titleLabel.TextStyle.Bold = true l.passField = widget.NewPasswordEntry() l.passField.OnSubmitted = func(_ string) { l.onSubmit() } @@ -57,7 +58,7 @@ func NewLoginDialog(servers []*backend.ServerConfig, pwFetch PasswordFetchFunc) editBtn := widget.NewButtonWithIcon("", theme.DocumentCreateIcon(), l.onEditServer) newBtn := widget.NewButtonWithIcon("", theme.ContentAddIcon(), l.onNewServer) deleteBtn := widget.NewButtonWithIcon("", theme.DeleteIcon(), func() { l.onDeleteServer(l.serverSelect.SelectedIndex()) }) - l.submitBtn = widget.NewButton("OK", l.onSubmit) + l.submitBtn = widget.NewButton(lang.L("OK"), l.onSubmit) l.submitBtn.Importance = widget.HighImportance l.promptText = widget.NewRichTextWithText("") l.promptText.Segments[0].(*widget.TextSegment).Style.ColorName = theme.ColorNameError @@ -66,9 +67,9 @@ func NewLoginDialog(servers []*backend.ServerConfig, pwFetch PasswordFetchFunc) l.container = container.NewVBox( container.NewHBox(layout.NewSpacer(), titleLabel, layout.NewSpacer()), container.New(layout.NewFormLayout(), - widget.NewLabel("Server"), + widget.NewLabel(lang.L("Server")), container.NewBorder(nil, nil, nil, container.NewHBox(editBtn, newBtn, deleteBtn), l.serverSelect), - widget.NewLabel("Password"), + widget.NewLabel(lang.L("Password")), l.passField), widget.NewSeparator(), container.NewHBox(l.promptText, layout.NewSpacer(), l.submitBtn), diff --git a/ui/dialogs/selectplaylist.go b/ui/dialogs/selectplaylist.go index 9032e0d..e294e3b 100644 --- a/ui/dialogs/selectplaylist.go +++ b/ui/dialogs/selectplaylist.go @@ -8,6 +8,7 @@ import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/data/binding" + "fyne.io/fyne/v2/lang" "fyne.io/fyne/v2/widget" "github.com/deluan/sanitize" "github.com/dweymouth/supersonic/backend/mediaprovider" @@ -35,7 +36,7 @@ func NewSelectPlaylistDialog(mp mediaprovider.MediaProvider, im util.ImageFetche "Cancel", sp.onSearched, ) - sd.ActionItem = widget.NewCheckWithData("Skip duplicate tracks", binding.BindBool(&sp.SkipDuplicates)) + sd.ActionItem = widget.NewCheckWithData(lang.L("Skip duplicate tracks"), binding.BindBool(&sp.SkipDuplicates)) sd.PlaceholderText = "Search playlists or new playlist name" sp.SearchDialog = sd return sp @@ -82,7 +83,7 @@ func (sp *SelectPlaylist) onSearched(query string) []*mediaprovider.SearchResult ) }) results = append(results, &mediaprovider.SearchResult{ - Name: fmt.Sprintf("Create new playlist: %s", query), + Name: fmt.Sprintf("%s: %s", lang.L("Create new playlist"), query), Type: mediaprovider.ContentTypePlaylist, }) }