Localization not working in presenting UIActivityViewController in swift 5

My app supports both LTR and RTL. It works fine for all cases. If i change app language from app settings then in every screen language is updated and works fine.

When i press share button in app. Below code is executed.Here i want to show share picker in my app's selected language. But it doesn't show it in my app's language.

  let text = NSLocalizedString("I liked this view in app", comment: "")
    // set up activity view controller
    let activityViewController = UIActivityViewController(activityItems: [text, urls], applicationActivities: nil)
    activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash
    
    // exclude some activity types from the list (optional)
    //    activityViewController.excludedActivityTypes = [ UIActivity.ActivityType.airDrop, UIActivity.ActivityType.postToFacebook ]
    
    // present the view controller
    self.present(activityViewController, animated: true, completion: nil)` 

I have tried below code to update share view language change but it didn't work.

   if ( Language.currentLanguage == .arabic) {
        activityViewController.accessibilityLanguage = "ar-SA"
    }
    else{
        activityViewController.accessibilityLanguage = "en-US"

    }

I have also tried below code but it is also not working.

if ( Language.currentLanguage == .arabic) {
        activityViewController.view.semanticContentAttribute = .forceRightToLeft

    }
    else{
        activityViewController.view.semanticContentAttribute = .forceLeftToRight

    }

Anyone could help me with this issue ?

PS For share picker you can refer below screenshot : enter image description here


Solution 1:

A solution which worked for me. Go to your Info.plist and add Localized resources can be mixed with Boolean YES or NO to it, and check the result.

As mentioned in Core Foundation Keys:

CFBundleAllowMixedLocalizations

CFBundleAllowMixedLocalizations (Boolean - iOS, macOS) specifies whether the bundle supports the retrieval of localized strings from frameworks. This key is used primarily by Foundation tools that link to other system frameworks and want to retrieve localized resources from those frameworks.