Skip to content

Commit

Permalink
Set the 'Accept-Language' header with user's preferred languages.
Browse files Browse the repository at this point in the history
  • Loading branch information
jompu committed Mar 9, 2024
1 parent 3825d86 commit 2dd105d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Palace/Network/TPPNetworkExecutor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,15 @@ extension TPPNetworkExecutor {
headers.forEach { urlRequest.setValue($0.value, forHTTPHeaderField: $0.key) }
}

urlRequest.setValue("", forHTTPHeaderField: "Accept-Language")
var preferredLocalizations:String = Bundle.main.preferredLocalizations[0]
if Bundle.main.preferredLocalizations.count > 1 {
preferredLocalizations += ", \(Bundle.main.preferredLocalizations[1]);q=0.9"
}
if Bundle.main.preferredLocalizations.count > 2 {
preferredLocalizations += ", \(Bundle.main.preferredLocalizations[2]);q=0.8"
}

urlRequest.setValue(preferredLocalizations, forHTTPHeaderField: "Accept-Language")
return urlRequest
}

Expand Down

0 comments on commit 2dd105d

Please sign in to comment.