Hi All,
I recently decided to remove my localizations for now because I'm requesting content from a lot of different sources (many of which only provides English text.
But with MusicKit I still receive the locale content. So basically I'm wondering if it's possible to set a locale for a MusicCatalogResourceRequest
?
Hello @hiddevdploeg,
MusicKit automatically attempts to load content from the Apple Music catalog using the language supported for the storefront of the user that is the closest match for the language the app is running in.
One of the main factors MusicKit uses to choose the language is the value of preferredLocalizations for the main bundle. If your app and your device are configured in such a way that this property returns an array where the first element is a string that begins with "en"
, and if the Apple Music API Storefront for the value of MusicDataRequest.currentCountryCode contains a value that also begins with "en"
in the supportedLanguageTags
or defaultLanguageTag
attributes, then MusicKit will make sure to request content in English.
We use this sort of heuristic to minimize the chances of mixed language UI appearing in any given app that uses MusicKit.
Beyond this automatic heuristic, and to respond more directly to your question, no, MusicKit doesn't currently have any public API for third-party apps to specify which language tag they would like to use.
Since you're asking this question, I'm guessing our current heuristic is not giving you the results you're hoping for. So to triage this better, we need more information from you.
Please modify your app and add the following lines in a function marked as async throws
:
let mainBundle = Bundle.main
print("Bundle.main.preferredLocalizations = \(mainBundle.preferredLocalizations)")
print("Bundle.main.localizations = \(mainBundle.localizations)")
print("Bundle.main.developmentLocalization = \(String(describing: mainBundle.developmentLocalization))")
let currentCountryCode = try await MusicDataRequest.currentCountryCode
print("MusicDataRequest.currentCountryCode = \(currentCountryCode)")
Then run your app, capture this output, and respond to this thread including a copy of this output.
Please also include a screenshot of what you see in Settings > General > Language & Region, for good measure.
Thanks,