Hello,
When you change the language, there is a ObserveCurrentLocaleDidChange method, then you can get the language and determine if it is Arabic and change the UI by setting UIView.Appearance.SemanticContentAttribute
.
About how to use this notification, refer to https://learn.microsoft.com/en-us/dotnet/api/foundation.nslocale.currentlocaledidchangenotification?view=xamarin-ios-sdk-12#remarks
About setSemanticContentAttribute
, refer to the following code:
using System.Runtime.InteropServices;
using ObjCRuntime;//namespace
[DllImport(ObjCRuntime.Constants.ObjectiveCLibrary, EntryPoint = "objc_msgSend")]
internal extern static IntPtr IntPtr_objc_msgSend(IntPtr receiver, IntPtr selector, UISemanticContentAttribute arg1);
// add to your notification method
IntPtr_objc_msgSend(UIView.Appearance.Handle, selector.Handle, isArabic ? UISemanticContentAttribute.ForceRightToLeft : UISemanticContentAttribute.ForceLeftToRight);
I'm not sure how did you change the language, if you change language in Settings, it's better to restart the application for the changes to take effect.
As @Paliwal, Vishal (Cognizant) said , " in some default UIPrintInteractionController and WKWebView is not showing the correct language without app restart."
From the Apple Doc we can see we have to guide users to the system settings for language selection when we want to change the language.
UIApplication.SharedApplication.OpenUrl(new NSUrl(UIApplication.OpenSettingsUrlString));
Best Regards,
Wenyan Zhang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.