After changing language from English to arabic the application has a delay in the navigation, the implication implemented with Combine and there is a Language Manager file when changing the language it do some changing directions,
I tried to remove the implemented localization and add LanguageManager_iOS library to handle it but the same issue happens,
here example of using combine
var page = CurrentValueSubject<Int, Never>(1)
private var bindings = Set<AnyCancellable>()
var hasMorePages = CurrentValueSubject<Bool, Never>(true)
private var provider: CommunityAPIProtocol?
provider?.getForYouPosts(page: page.value, search: search, categoryId: categoryId).receive(on: RunLoop.main)
.sink(receiveCompletion: requestCompletionHandler, receiveValue: {[weak self] in
if let data = $0.data?.docs {
if self?.page.value == 1 {
self?.posts.value = data
} else {
self?.posts.value.append(contentsOf: data)
}
}
self?.hasMorePages.value = $0.data?.hasNextPage ?? false
}).store(in: &bindings)
this is an example of methods in Localization file
// set language for localization
func setLanguage(language: Language, reloadApp: Bool = false) -> Void {
UserDefaults.standard.set(language.rawValue, forKey: languageKey)
let path: String? = Bundle.main.path(forResource: language.rawValue, ofType: "lproj")
if path == nil {
//in case the language does not exists
resetLocalization()
}
else {
bundle = Bundle(path: path!)
}
UserDefaults.standard.synchronize()
resetApp(reloadApp: reloadApp)
}
// reset app for the new lang
private func resetApp(reloadApp: Bool) {
let dir = getLanguageDirection()
let semantic: UISemanticContentAttribute = dir == .leftToRight ? .forceLeftToRight : .forceRightToLeft
UITabBar.appearance().semanticContentAttribute = semantic
UIView.appearance().semanticContentAttribute = semantic
UINavigationBar.appearance().semanticContentAttribute = semantic
UIPageControl.appearance().semanticContentAttribute = .forceLeftToRight
UICollectionView.appearance().semanticContentAttribute = semantic
UITextView.appearance().textAlignment = dir == .leftToRight ? .left : .right
UITextField.appearance().textAlignment = dir == .leftToRight ? .left : .right
UISearchBar.appearance().semanticContentAttribute = semantic
UISwitch.appearance().semanticContentAttribute = .forceLeftToRight
UIPageControl.appearance().semanticContentAttribute = semantic
delegate?.resetApp(reloadApp: reloadApp)
}