mirror of
https://github.com/writeas/writefreely-swiftui-multiplatform.git
synced 2024-11-15 01:11:02 +00:00
Fix deprecation warnings on locale
This commit is contained in:
parent
f0df99c1a8
commit
4f97eb5e93
@ -94,9 +94,16 @@ extension WriteFreelyModel {
|
||||
}
|
||||
|
||||
if post.language == nil {
|
||||
if let languageCode = Locale.current.languageCode {
|
||||
post.language = languageCode
|
||||
post.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
||||
if #available(iOS 16, macOS 13, *) {
|
||||
if let languageCode = Locale.current.language.languageCode?.identifier {
|
||||
post.language = languageCode
|
||||
post.rtl = Locale.Language(identifier: languageCode).characterDirection == .rightToLeft
|
||||
}
|
||||
} else {
|
||||
if let languageCode = Locale.current.languageCode {
|
||||
post.language = languageCode
|
||||
post.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,16 @@ struct PostEditorModel {
|
||||
default:
|
||||
managedPost.appearance = "serif"
|
||||
}
|
||||
if let languageCode = Locale.current.languageCode {
|
||||
managedPost.language = languageCode
|
||||
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
||||
if #available(iOS 16, macOS 13, *) {
|
||||
if let languageCode = Locale.current.language.languageCode?.identifier {
|
||||
managedPost.language = languageCode
|
||||
managedPost.rtl = Locale.Language(identifier: languageCode).characterDirection == .rightToLeft
|
||||
}
|
||||
} else {
|
||||
if let languageCode = Locale.current.languageCode {
|
||||
managedPost.language = languageCode
|
||||
managedPost.rtl = Locale.characterDirection(forLanguage: languageCode) == .rightToLeft
|
||||
}
|
||||
}
|
||||
return managedPost
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user