From 87671fc499d3e1b522fb052d3cecf6d06afb8fc8 Mon Sep 17 00:00:00 2001 From: Piekay Date: Fri, 20 Mar 2026 20:43:13 +0100 Subject: [PATCH] added Carplay translations --- flo/CarPlay/CarPlayCoordinator.swift | 82 ++--- flo/CarPlay/CarPlayNowPlayingManager.swift | 10 +- flo/Resources/Localizable.xcstrings | 330 +++++++++++++++++++++ 3 files changed, 376 insertions(+), 46 deletions(-) diff --git a/flo/CarPlay/CarPlayCoordinator.swift b/flo/CarPlay/CarPlayCoordinator.swift index 1c2716c..4ccdd39 100644 --- a/flo/CarPlay/CarPlayCoordinator.swift +++ b/flo/CarPlay/CarPlayCoordinator.swift @@ -47,7 +47,7 @@ class CarPlayCoordinator { private func makeLibraryTab() -> CPListTemplate { let albumsItem = CPListItem( - text: "Albums", detailText: nil, + text: String(localized: "Albums"), detailText: nil, image: UIImage(systemName: "square.stack")?.withRenderingMode(.alwaysTemplate)) albumsItem.handler = { [weak self] _, completion in self?.showAlbumsList() @@ -55,7 +55,7 @@ class CarPlayCoordinator { } let artistsItem = CPListItem( - text: "Artists", detailText: nil, + text: String(localized: "Artists"), detailText: nil, image: UIImage(systemName: "music.mic")?.withRenderingMode(.alwaysTemplate)) artistsItem.handler = { [weak self] _, completion in self?.showArtistsList() @@ -63,7 +63,7 @@ class CarPlayCoordinator { } let songsItem = CPListItem( - text: "Songs", detailText: nil, + text: String(localized: "Songs"), detailText: nil, image: UIImage(systemName: "music.note")?.withRenderingMode(.alwaysTemplate)) songsItem.handler = { [weak self] _, completion in self?.showSongsList() @@ -71,7 +71,7 @@ class CarPlayCoordinator { } let section = CPListSection(items: [albumsItem, artistsItem, songsItem]) - let template = CPListTemplate(title: "Library", sections: [section]) + let template = CPListTemplate(title: String(localized: "Library"), sections: [section]) template.tabImage = UIImage(systemName: "square.grid.2x2") return template @@ -80,7 +80,7 @@ class CarPlayCoordinator { // MARK: - Albums private func showAlbumsList() { - let loadingTemplate = CPListTemplate(title: "Albums", sections: []) + let loadingTemplate = CPListTemplate(title: String(localized: "Albums"), sections: []) interfaceController.pushTemplate(loadingTemplate, animated: true, completion: nil) AlbumService.shared.getAlbum { [weak self] result in @@ -111,7 +111,7 @@ class CarPlayCoordinator { loadingTemplate.updateSections([CPListSection(items: items)]) case .failure: - let errorItem = CPListItem(text: "Failed to load albums", detailText: "Tap to retry") + let errorItem = CPListItem(text: String(localized: "Failed to load albums"), detailText: String(localized: "Tap to retry")) errorItem.handler = { [weak self] _, completion in self?.interfaceController.popTemplate(animated: false, completion: nil) self?.showAlbumsList() @@ -165,8 +165,8 @@ class CarPlayCoordinator { template: CPListTemplate, album: Album, isDownloaded: Bool ) { let playAllItem = CPListItem( - text: "Play All", - detailText: "\(album.songs.count) tracks", + text: String(localized: "Play All"), + detailText: String(localized: "\(album.songs.count) tracks"), image: UIImage(systemName: "play.fill")?.withRenderingMode(.alwaysTemplate) ) playAllItem.handler = { [weak self] _, completion in @@ -176,7 +176,7 @@ class CarPlayCoordinator { } let shuffleItem = CPListItem( - text: "Shuffle", + text: String(localized: "Shuffle"), detailText: nil, image: UIImage(systemName: "shuffle")?.withRenderingMode(.alwaysTemplate) ) @@ -202,7 +202,7 @@ class CarPlayCoordinator { } let trackSection = CPListSection( items: trackItems, - header: "Tracks", + header: String(localized: "Tracks"), sectionIndexTitle: nil ) @@ -214,7 +214,7 @@ class CarPlayCoordinator { private var filterAlbumArtistOnly = true private func showArtistsList() { - let loadingTemplate = CPListTemplate(title: "Artists", sections: []) + let loadingTemplate = CPListTemplate(title: String(localized: "Artists"), sections: []) interfaceController.pushTemplate(loadingTemplate, animated: true, completion: nil) AlbumService.shared.getArtists { [weak self] result in @@ -228,7 +228,7 @@ class CarPlayCoordinator { let items = filteredArtists.map { artist -> CPListItem in let item = CPListItem( text: artist.name, - detailText: "\(artist.albumCount) albums" + detailText: String(localized: "\(artist.albumCount) albums") ) item.handler = { [weak self] _, completion in self?.showArtistAlbums(artist: artist) @@ -239,7 +239,7 @@ class CarPlayCoordinator { loadingTemplate.updateSections([CPListSection(items: items)]) case .failure: - let errorItem = CPListItem(text: "Failed to load artists", detailText: "Tap to retry") + let errorItem = CPListItem(text: String(localized: "Failed to load artists"), detailText: String(localized: "Tap to retry")) errorItem.handler = { [weak self] _, completion in self?.interfaceController.popTemplate(animated: false, completion: nil) self?.showArtistsList() @@ -261,7 +261,7 @@ class CarPlayCoordinator { switch result { case .success(let albums): let radioItem = CPListItem( - text: "Play Artist Radio", + text: String(localized: "Play Artist Radio"), detailText: nil, image: UIImage(systemName: "dot.radiowaves.up.forward") ) @@ -271,7 +271,7 @@ class CarPlayCoordinator { } let topSongsItem = CPListItem( - text: "Play Top Songs", + text: String(localized: "Play Top Songs"), detailText: nil, image: UIImage(systemName: "star.fill") ) @@ -304,7 +304,7 @@ class CarPlayCoordinator { } let albumSection = CPListSection( items: albumItems, - header: "Albums", + header: String(localized: "Albums"), sectionIndexTitle: nil ) @@ -313,7 +313,7 @@ class CarPlayCoordinator { case .failure: loadingTemplate.updateSections([ CPListSection(items: [ - CPListItem(text: "Failed to load albums", detailText: nil) + CPListItem(text: String(localized: "Failed to load albums"), detailText: nil) ]) ]) } @@ -331,16 +331,16 @@ class CarPlayCoordinator { case .success(let songs) where !songs.isEmpty: let playable = RadioEntity( id: artist.id, - name: "\(artist.name) Radio", + name: String(localized: "\(artist.name) Radio"), songs: songs, artist: artist.name ) self.playerVM.playItem(item: playable, isFromLocal: false) self.showNowPlaying() case .success: - self.showErrorTemplate(title: "No Radio Available", message: "No similar songs found for \(artist.name).") + self.showErrorTemplate(title: String(localized: "No Radio Available"), message: String(localized: "No similar songs found for \(artist.name).")) case .failure: - self.showErrorTemplate(title: "Radio Unavailable", message: "Could not load radio for \(artist.name).") + self.showErrorTemplate(title: String(localized: "Radio Unavailable"), message: String(localized: "Could not load radio for \(artist.name).")) } } } @@ -354,16 +354,16 @@ class CarPlayCoordinator { case .success(let songs) where !songs.isEmpty: let playable = RadioEntity( id: artist.id, - name: "\(artist.name) Top Songs", + name: String(localized: "\(artist.name) Top Songs"), songs: songs, artist: artist.name ) self.playerVM.playItem(item: playable, isFromLocal: false) self.showNowPlaying() case .success: - self.showErrorTemplate(title: "No Top Songs", message: "No top songs found for \(artist.name).") + self.showErrorTemplate(title: String(localized: "No Top Songs"), message: String(localized: "No top songs found for \(artist.name).")) case .failure: - self.showErrorTemplate(title: "Unavailable", message: "Could not load top songs for \(artist.name).") + self.showErrorTemplate(title: String(localized: "Unavailable"), message: String(localized: "Could not load top songs for \(artist.name).")) } } } @@ -378,7 +378,7 @@ class CarPlayCoordinator { // MARK: - Songs private func showSongsList() { - let loadingTemplate = CPListTemplate(title: "Songs", sections: []) + let loadingTemplate = CPListTemplate(title: String(localized: "Songs"), sections: []) interfaceController.pushTemplate(loadingTemplate, animated: true, completion: nil) AlbumService.shared.getAllSongs { [weak self] result in @@ -393,7 +393,7 @@ class CarPlayCoordinator { ) item.handler = { [weak self] _, completion in guard let self = self else { return } - let allTracks = Playlist(name: "All Tracks", songs: songs) + let allTracks = Playlist(name: String(localized: "All Tracks"), songs: songs) self.playerVM.playBySong(idx: idx, item: allTracks, isFromLocal: false) self.showNowPlaying() completion() @@ -403,7 +403,7 @@ class CarPlayCoordinator { loadingTemplate.updateSections([CPListSection(items: items)]) case .failure: - let errorItem = CPListItem(text: "Failed to load songs", detailText: "Tap to retry") + let errorItem = CPListItem(text: String(localized: "Failed to load songs"), detailText: String(localized: "Tap to retry")) errorItem.handler = { [weak self] _, completion in self?.interfaceController.popTemplate(animated: false, completion: nil) self?.showSongsList() @@ -418,10 +418,10 @@ class CarPlayCoordinator { // MARK: - Playlists Tab private func makePlaylistsTab() -> CPListTemplate { - let loadingItem = CPListItem(text: "Loading playlists…", detailText: nil) + let loadingItem = CPListItem(text: String(localized: "Loading playlists…"), detailText: nil) loadingItem.isEnabled = false let template = CPListTemplate( - title: "Playlists", sections: [CPListSection(items: [loadingItem])]) + title: String(localized: "Playlists"), sections: [CPListSection(items: [loadingItem])]) template.tabImage = UIImage(systemName: "music.note.list") AlbumService.shared.getPlaylists { [weak self] result in @@ -445,7 +445,7 @@ class CarPlayCoordinator { case .failure: template.updateSections([ CPListSection(items: [ - CPListItem(text: "Failed to load playlists", detailText: nil) + CPListItem(text: String(localized: "Failed to load playlists"), detailText: nil) ]) ]) } @@ -486,8 +486,8 @@ class CarPlayCoordinator { template: CPListTemplate, playlist: Playlist, isDownloaded: Bool ) { let playAllItem = CPListItem( - text: "Play All", - detailText: "\(playlist.songs.count) tracks", + text: String(localized: "Play All"), + detailText: String(localized: "\(playlist.songs.count) tracks"), image: UIImage(systemName: "play.fill") ) playAllItem.handler = { [weak self] _, completion in @@ -497,7 +497,7 @@ class CarPlayCoordinator { } let shuffleItem = CPListItem( - text: "Shuffle", + text: String(localized: "Shuffle"), detailText: nil, image: UIImage(systemName: "shuffle") ) @@ -523,7 +523,7 @@ class CarPlayCoordinator { } let trackSection = CPListSection( items: trackItems, - header: "Tracks", + header: String(localized: "Tracks"), sectionIndexTitle: nil ) @@ -533,10 +533,10 @@ class CarPlayCoordinator { // MARK: - Radio Tab private func makeRadioTab() -> CPListTemplate { - let loadingItem = CPListItem(text: "Loading stations…", detailText: nil) + let loadingItem = CPListItem(text: String(localized: "Loading stations…"), detailText: nil) loadingItem.isEnabled = false let template = CPListTemplate( - title: "Radio", sections: [CPListSection(items: [loadingItem])]) + title: String(localized: "Radio"), sections: [CPListSection(items: [loadingItem])]) template.tabImage = UIImage(systemName: "radio") RadioService.shared.getAllRadios { [weak self] result in @@ -547,7 +547,7 @@ class CarPlayCoordinator { if radios.isEmpty { template.updateSections([ CPListSection(items: [ - CPListItem(text: "No radio stations", detailText: nil) + CPListItem(text: String(localized: "No radio stations"), detailText: nil) ]) ]) return @@ -571,7 +571,7 @@ class CarPlayCoordinator { case .failure: template.updateSections([ CPListSection(items: [ - CPListItem(text: "Failed to load radios", detailText: nil) + CPListItem(text: String(localized: "Failed to load radios"), detailText: nil) ]) ]) } @@ -584,10 +584,10 @@ class CarPlayCoordinator { // MARK: - Downloads Tab private func makeDownloadsTab() -> CPListTemplate { - let loadingItem = CPListItem(text: "Loading downloads…", detailText: nil) + let loadingItem = CPListItem(text: String(localized: "Loading downloads…"), detailText: nil) loadingItem.isEnabled = false let template = CPListTemplate( - title: "Downloads", sections: [CPListSection(items: [loadingItem])]) + title: String(localized: "Downloads"), sections: [CPListSection(items: [loadingItem])]) template.tabImage = UIImage(systemName: "arrow.down.circle") AlbumService.shared.getDownloadedAlbum { [weak self] result in @@ -602,7 +602,7 @@ class CarPlayCoordinator { if filtered.isEmpty { template.updateSections([ CPListSection(items: [ - CPListItem(text: "No downloads", detailText: "Download music from the app") + CPListItem(text: String(localized: "No downloads"), detailText: String(localized: "Download music from the app")) ]) ]) return @@ -633,7 +633,7 @@ class CarPlayCoordinator { case .failure: template.updateSections([ CPListSection(items: [ - CPListItem(text: "No downloads available", detailText: nil) + CPListItem(text: String(localized: "No downloads available"), detailText: nil) ]) ]) } diff --git a/flo/CarPlay/CarPlayNowPlayingManager.swift b/flo/CarPlay/CarPlayNowPlayingManager.swift index ad86a32..e3b51fd 100644 --- a/flo/CarPlay/CarPlayNowPlayingManager.swift +++ b/flo/CarPlay/CarPlayNowPlayingManager.swift @@ -22,7 +22,7 @@ class CarPlayNowPlayingManager: NSObject { nowPlaying.add(self) nowPlaying.isUpNextButtonEnabled = true - nowPlaying.upNextTitle = "Up Next" + nowPlaying.upNextTitle = String(localized: "Up Next") updateButtons(on: nowPlaying) @@ -91,7 +91,7 @@ extension CarPlayNowPlayingManager: CPNowPlayingTemplateObserver { guard idx > activeIdx else { return nil } let item = CPListItem( - text: entity.songName ?? "Unknown", + text: entity.songName ?? String(localized: "Unknown"), detailText: entity.artistName ?? "" ) item.handler = { [weak self] _, completion in @@ -102,15 +102,15 @@ extension CarPlayNowPlayingManager: CPNowPlayingTemplateObserver { } if upcomingItems.isEmpty { - let emptyItem = CPListItem(text: "No upcoming tracks", detailText: nil) + let emptyItem = CPListItem(text: String(localized: "No upcoming tracks"), detailText: nil) let template = CPListTemplate( - title: "Up Next", + title: String(localized: "Up Next"), sections: [CPListSection(items: [emptyItem])] ) interfaceController.pushTemplate(template, animated: true, completion: nil) } else { let template = CPListTemplate( - title: "Up Next", + title: String(localized: "Up Next"), sections: [CPListSection(items: upcomingItems)] ) interfaceController.pushTemplate(template, animated: true, completion: nil) diff --git a/flo/Resources/Localizable.xcstrings b/flo/Resources/Localizable.xcstrings index 40bf73f..f82f494 100644 --- a/flo/Resources/Localizable.xcstrings +++ b/flo/Resources/Localizable.xcstrings @@ -127,6 +127,26 @@ } } }, + "%@ Radio" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "%@-Radio" + } + } + } + }, + "%@ Top Songs" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "%@ Top-Songs" + } + } + } + }, "%@%@" : { "localizations" : { "de" : { @@ -183,6 +203,26 @@ }, "%lld songs" : { + }, + "%lld albums" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "%lld Alben" + } + } + } + }, + "%lld tracks" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "%lld Titel" + } + } + } }, "•" : { "localizations" : { @@ -366,6 +406,26 @@ } } }, + "Albums" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Alben" + } + } + } + }, + "All Tracks" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Alle Titel" + } + } + } + }, "Alternate app icons are not supported on this device." : { "localizations" : { "de" : { @@ -670,6 +730,26 @@ } } }, + "Could not load radio for %@." : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Radio für %@ konnte nicht geladen werden." + } + } + } + }, + "Could not load top songs for %@." : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Top-Songs für %@ konnten nicht geladen werden." + } + } + } + }, "Currently the output format is MP3 due to compatibility issues; however, MP3 is less efficient in streaming at lower bitrates compared to modern codecs like Opus." : { "localizations" : { "de" : { @@ -796,6 +876,16 @@ } } }, + "Download music from the app" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Lade Musik aus der App herunter" + } + } + } + }, "Download Queue" : { "localizations" : { "de" : { @@ -966,6 +1056,56 @@ } } }, + "Failed to load albums" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Alben konnten nicht geladen werden" + } + } + } + }, + "Failed to load artists" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Künstler konnten nicht geladen werden" + } + } + } + }, + "Failed to load playlists" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Playlists konnten nicht geladen werden" + } + } + } + }, + "Failed to load radios" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Radios konnten nicht geladen werden" + } + } + } + }, + "Failed to load songs" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Songs konnten nicht geladen werden" + } + } + } + }, "flo will store your server URL, username, and password in the Keychain with no biometric protection. If you enable this, flo will try to 'refresh' the auth token—by logging you in automatically—every time you open flo so you'll never log out unless you do it explicitly (it will also reset this option). Logging in via OAuth will reset this option." : { "localizations" : { "de" : { @@ -1290,6 +1430,36 @@ } } }, + "Loading downloads…" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Downloads werden geladen…" + } + } + } + }, + "Loading playlists…" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Playlists werden geladen…" + } + } + } + }, + "Loading stations…" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Sender werden geladen…" + } + } + } + }, "Local Storage" : { "localizations" : { "de" : { @@ -1525,6 +1695,26 @@ } } }, + "No downloads" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine Downloads" + } + } + } + }, + "No downloads available" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine Downloads verfügbar" + } + } + } + }, "No lyrics available" : { "localizations" : { "de" : { @@ -1541,6 +1731,26 @@ } } }, + "No Radio Available" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Kein Radio verfügbar" + } + } + } + }, + "No radio stations" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine Radiosender" + } + } + } + }, "No radios available" : { "localizations" : { "de" : { @@ -1573,6 +1783,46 @@ } } }, + "No similar songs found for %@." : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine ähnlichen Songs für %@ gefunden." + } + } + } + }, + "No Top Songs" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine Top-Songs" + } + } + } + }, + "No top songs found for %@." : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine Top-Songs für %@ gefunden." + } + } + } + }, + "No upcoming tracks" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Keine weiteren Titel" + } + } + } + }, "Off" : { }, @@ -1676,6 +1926,16 @@ } } }, + "Play All" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Alle abspielen" + } + } + } + }, "Play Artist Radio" : { "localizations" : { "de" : { @@ -1822,6 +2082,26 @@ } } }, + "Radio" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Radio" + } + } + } + }, + "Radio Unavailable" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Radio nicht verfügbar" + } + } + } + }, "Radios" : { "localizations" : { "de" : { @@ -2311,6 +2591,16 @@ } } }, + "Tap to retry" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Zum Wiederholen tippen" + } + } + } + }, "Thank you for supporting flo!" : { "extractionState" : "stale", "localizations" : { @@ -2563,6 +2853,16 @@ } } }, + "Tracks" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Titel" + } + } + } + }, "Troubleshoot" : { "localizations" : { "de" : { @@ -2639,6 +2939,36 @@ } } }, + "Unavailable" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Nicht verfügbar" + } + } + } + }, + "Unknown" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Unbekannt" + } + } + } + }, + "Up Next" : { + "localizations" : { + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Warteschlange" + } + } + } + }, "Use this if your server is behind OAuth2-Proxy or Identity-Aware Proxy" : { "comment" : "A piece of text explaining the purpose of the IAP login button.", "isCommentAutoGenerated" : true, -- knotmirror 0.0.1