Skip to content

Commit

Permalink
Silence warning about locale.languageCode
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlokhorst committed Dec 11, 2022
1 parent 1eccd23 commit b553d78
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Sources/RswiftResources/Integrations/Bundle+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@ extension Bundle {
.map { Foundation.Locale(identifier: $0) }
.prefix(1)
.flatMap { locale -> [String] in
let language: String?
if #available(macOS 13, iOS 16, tvOS 16, watchOS 9, *) {
language = locale.language.languageCode?.identifier
} else {
language = locale.languageCode
}
if hostingBundle.localizations.contains(locale.identifier) {
if let language = locale.languageCode, hostingBundle.localizations.contains(language) {
if let language = language, hostingBundle.localizations.contains(language) {
return [locale.identifier, language]
} else {
return [locale.identifier]
}
} else if let language = locale.languageCode, hostingBundle.localizations.contains(language) {
} else if let language = language, hostingBundle.localizations.contains(language) {
return [language]
} else {
return []
Expand Down

0 comments on commit b553d78

Please sign in to comment.