You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sources/SwiftBoost/Foundation/Extensions/LocaleExtension.swift
+19-9Lines changed: 19 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -12,19 +12,29 @@ public extension Locale {
12
12
}
13
13
14
14
func localised(in locale:Locale)->String?{
15
-
guardlet currentLanguageCode ={
16
-
if #available(iOS 16,*){
17
-
returnself.language.languageCode?.identifier
18
-
}else{
19
-
returnself.languageCode
20
-
}
21
-
}()else{returnnil}
22
-
guardlet toLanguageCode ={
23
-
if #available(iOS 16,*){
15
+
/**
16
+
Returns the identifier for the language code of the given `Locale`.
17
+
18
+
This method checks for the availability of specific APIs introduced in iOS 16.0 and macOS 13.0 versions or later. If these APIs are available, it returns the `identifier` property of the `languageCode` from the `Locale`. Otherwise, it uses the `languageCode` property directly from the `Locale`.
19
+
20
+
- Parameter locale: The `Locale` for which the language code identifier is required.
21
+
22
+
- Returns: The language code identifier of the given `Locale`. If the specific APIs are unavailable (i.e., the device's OS version is older than iOS 16.0 or macOS 13.0), it returns the language code directly.
0 commit comments