Skip to content

Commit

Permalink
Fix incorrect app language code detection on modern OSes
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeehut committed May 18, 2024
1 parent 1dd9b98 commit c8dcc83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/TelemetryClient/Signal.swift
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ extension DefaultSignalPayload {
/// The language identifier the app is currently running in. This represents the language the system (or the user) has chosen for the app to run in.
static var appLanguage: String {
if #available(iOS 16, macOS 13, tvOS 16, visionOS 1, watchOS 9, *) {
return Locale.current.language.minimalIdentifier
return Locale.current.language.languageCode?.identifier ?? Locale.current.identifier.components(separatedBy: .init(charactersIn: "-_"))[0]
} else {
return Locale.current.languageCode ?? Locale.current.identifier.components(separatedBy: .init(charactersIn: "-_"))[0]
}
Expand Down

0 comments on commit c8dcc83

Please sign in to comment.