Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: K-pop with a verse in Korean gets the translate menu, and any song can
My-Name-Is-Jeffa74efe48e2d0
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex 09aa3724..16667da2 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -134,7 +134,7 @@ Shared:Intelligence's model (iOS 26 where it is on and speaks the language; permissive guardrails for changingthe user's own text, 12 lines a session, greedy and capped at 60 tokens a line, exactly one string a line by a generation schema; Translate retried once, as its first ask can fail while it loads), both inOnDeviceTranslation.swift, the frameworks weak linked; and by Gemini on the user's own key (Keychain),- whose prompt and menu item say the lyrics go to Google. The translate items show only for a song NaturalLanguage finds in another language than the Lyrics page's (or the iPhone's): one distinct line in five it is at least 80% sure of, not the whole song's guess (short lines sway that: Havana reads as Dutch), so songs half in English count and a repeated chorus weighs as one line; Translate on iPhone translates from the language most of those lines are in and leaves lines already in the target as they are. Apple Intelligence's lines show and are saved a batch at a time, only lines without a translation are sent, and a batch it turns down is skipped (asking again sends only those lines). Every finished translation is kept by SavedTranslations.m in Caches/Vitrine/Translations, one JSON file a song and language mapping each line's text to its translation, the newest 200, applied when the song's lines are next shown; the Lyrics page's Saved translations row counts them and deletes them. Gemini's reply read and checked on the Mac+ whose prompt and menu item say the lyrics go to Google. The translate items show for every song with Translate any song on (SGKeyLyricsTranslateEverySong, off), else only for a song NaturalLanguage finds in another language than the Lyrics page's (or the iPhone's): one distinct line in five it is at least 80% sure of, or two in another script (a verse in Hangul among English), not the whole song's guess (short lines sway that: Havana reads as Dutch), so songs half in English count and a repeated chorus weighs as one line; Translate on iPhone translates from the language most of those lines are in and leaves lines already in the target as they are. Apple Intelligence's lines show and are saved a batch at a time, only lines without a translation are sent, and a batch it turns down is skipped (asking again sends only those lines). Every finished translation is kept by SavedTranslations.m in Caches/Vitrine/Translations, one JSON file a song and language mapping each line's text to its translation, the newest 200, applied when the song's lines are next shown; the Lyrics page's Saved translations row counts them and deletes them. Gemini's reply read and checked on the Macagainst harness/lyrics-translation/LockScreenLyrics/ the line being sung in the system's now playing, and on iOS 26 the lyrics as the lock screen'sfull-screen artwork (LyricsArtwork.x): a new artwork ID per line, its 3:4 H.264 clip (the line and thediff --git a/tweak/Sources/App/Pages.m b/tweak/Sources/App/Pages.mindex daba3f68..1148b4f6 100644--- a/tweak/Sources/App/Pages.m+++ b/tweak/Sources/App/Pages.m@@ -119,7 +119,7 @@ static UIViewController *lyricsPage(void) {SGSwitchRow(@"Hide the controls", @"A few seconds after the last touch, the lyrics take the whole player", SGRKeyLyricsAutoHide),SGSwitchRow(@"Landscape lyrics", @"Turn the phone with the lyrics open", SGRKeyLyricsLandscape)]),timing,- SGSection(@"Translation", @[SGLyricsTranslationLanguageRow(), SGGeminiKeyRow(), SGSavedTranslationsRow()]),+ SGSection(@"Translation", @[SGLyricsTranslationLanguageRow(), SGTranslateEverySongRow(), SGGeminiKeyRow(), SGSavedTranslationsRow()]),SGSection(nil, @[SGLyricsMeaningsRow()]),]];} else {diff --git a/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m b/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.mindex 354fc806..44fe367a 100644--- a/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m+++ b/tweak/Sources/Redesigned/Lyrics/SGRKaraokeView.m@@ -1724,16 +1724,18 @@ static NSArray<NSString *> *textsOf(NSArray<SGKaraokeLine *> *lines) {return texts;}-// Whether one distinct line in five is, with the recognizer at least 80% sure, in a language other than `language`:-// K-pop and other songs half in English count, and a chorus sung eight times weighs as one line. The whole song's-// guess is not asked: short lines sway it (it reads Havana, all "ooh na-na", as Dutch), and an unsure line does not-// count either way. A song with no line it is sure of counts as foreign, too little to tell.+// Whether a song is in a language other than `language`, line by line: one distinct line in five, or two lines in+// another script (Hangul, kana, Han among English, for K-pop with only a verse in Korean), with the recognizer at+// least 80% sure of each. A chorus sung eight times weighs as one line. The whole song's guess is not asked: short+// lines sway it (it reads Havana, all "ooh na-na", as Dutch), and an unsure line counts neither way. A song with no+// line it is sure of counts as foreign, too little to tell.static BOOL inAnotherLanguage(NSArray<SGKaraokeLine *> *lines, NSString *language) {NSString *(^code)(NSString *) = ^NSString *(NSString *tag) {return [tag componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"-_"]].firstObject.lowercaseString;};NSString *target = code(language);- NSUInteger distinct = 0, sure = 0, foreign = 0;+ NSString *targetScript = [NSOrthography defaultOrthographyForLanguage:language].dominantScript;+ NSUInteger distinct = 0, sure = 0, foreign = 0, otherScript = 0;NSMutableSet<NSString *> *seen = [NSMutableSet set];NLLanguageRecognizer *recognizer = [NLLanguageRecognizer new];for (SGKaraokeLine *line in lines) {@@ -1747,9 +1749,11 @@ static BOOL inAnotherLanguage(NSArray<SGKaraokeLine *> *lines, NSString *languagNLLanguage found = guess.allKeys.firstObject;if (!found || guess[found].doubleValue < 0.8) continue;sure++;- if (![code(found) isEqualToString:target]) foreign++;+ if ([code(found) isEqualToString:target]) continue;+ foreign++;+ if (![[NSOrthography defaultOrthographyForLanguage:found].dominantScript isEqualToString:targetScript]) otherScript++;}- return !sure || foreign * 5 >= MAX(distinct, 5);+ return !sure || foreign * 5 >= MAX(distinct, 5) || otherScript >= 2;}// Whether a line with words is still without a translation.@@ -1865,7 +1869,7 @@ static BOOL anyUntranslated(NSArray<SGKaraokeLine *> *lines) {BOOL gemini = SGGeminiKeySet(), onDevice = SGOnDeviceTranslation.translationAvailable;BOOL intelligence = [SGOnDeviceTranslation appleIntelligenceAvailable:language];// A translator is offered only for a song in another language than the one it would translate into.- BOOL translatable = _foreign && _untranslated && (gemini || onDevice || intelligence);+ BOOL translatable = (_foreign || SGHidden(SGKeyLyricsTranslateEverySong)) && _untranslated && (gemini || onDevice || intelligence);BOOL offered = _lines && !_sample && (_hasSpoken || _hasTranslation || translatable);if (!offered) {_extrasBox.hidden = YES;diff --git a/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.h b/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.hindex 88f7893c..3e39f9e0 100644--- a/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.h+++ b/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.h@@ -7,6 +7,10 @@BOOL SGGeminiKeySet(void);+// On: the translate menu is offered for every song, not only those found in another language.+#define SGKeyLyricsTranslateEverySong @"spotifyglass.lyrics.translateEverySong"+SGModRow *SGTranslateEverySongRow(void);+// One translation per line, in order, or nil and a message to show. Main queue. The same song in the// same language is asked once a launch.void SGLyricsTranslateWithGemini(NSString *trackID, NSArray<SGKaraokeLine *> *lines, NSString *languageTag,diff --git a/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.m b/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.mindex ae8bf35c..f9939ceb 100644--- a/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.m+++ b/tweak/Sources/Shared/LyricsTranslation/LyricsTranslation.m@@ -196,6 +196,11 @@ static void askForKey(void) {[SGTopController() presentViewController:alert animated:YES completion:nil];}+SGModRow *SGTranslateEverySongRow(void) {+ return SGOptionRow(@"Translate any song", @"The lyrics' translate menu for songs that already read as your language",+ SGKeyLyricsTranslateEverySong);+}+SGModRow *SGGeminiKeyRow(void) {return SGStatActionRow(@"Gemini API key", @"Translate any song from the lyrics' corner menu",^NSString *{ return SGGeminiKeySet() ? @"Set" : @"Off"; }, ^{ askForKey(); });