Skip to content
This repository was archived by the owner on May 5, 2020. It is now read-only.

Broken UI when device's language is Arabic ( ios 9) #389

Closed
cuongv opened this issue Feb 17, 2016 · 15 comments
Closed

Broken UI when device's language is Arabic ( ios 9) #389

cuongv opened this issue Feb 17, 2016 · 15 comments

Comments

@cuongv
Copy link

cuongv commented Feb 17, 2016

When i change the iphone's language to Arabic, the UI for paypal was mess up!

simulator screen shot feb 17 2016 10 59 04 am

@bluk
Copy link
Contributor

bluk commented Feb 17, 2016

Can you please provide the specific locale (country/region combination) and device you used? Some quick tests on an iPhone 5S and iPhone 6 Plus did not reproduce this error so wondering if there's a more specific combination of settings which results in this behavior.

@cuongv
Copy link
Author

cuongv commented Feb 22, 2016

You need to add more language into your project.(i mean localize your app).I use Arabic language.It happens on both iphone 5 and 6 with ios 9
screen shot 2016-02-22 at 11 46 51 am

@cuongv
Copy link
Author

cuongv commented Feb 23, 2016

@bluk Please check it.Thanks

@bluk
Copy link
Contributor

bluk commented Feb 23, 2016

@cuongv Thanks for the info. I was able to reproduce the issue with the added Arabic localization and changing the device settings. Working towards a fix.

@bluk bluk added the bug label Feb 23, 2016
@bluk
Copy link
Contributor

bluk commented Feb 24, 2016

Just an update but testing various fixes for the right to left language layouts. Hope to have a release out by the end of the week.

@bluk
Copy link
Contributor

bluk commented Feb 25, 2016

Pushed out 2.14.0. If there are any additional issues, please let us know. Thanks.

@bluk bluk closed this as completed Feb 25, 2016
@cuongv
Copy link
Author

cuongv commented Feb 26, 2016

Good job !

@braebot
Copy link
Contributor

braebot commented Feb 26, 2016

👍

@adityaawok
Copy link

Hi @bluk ,

I am facing similar issue when i change the language directly from inside the app from English to Arabic and vice versa. The phone language is not changed and i keep it as English.

This scenario happens when i update the app language on the fly, when i restart my app, PayPalPaymentViewController displays expected view i.e RTL or LTR.

Also similar thing happens when i force PayPal demo app to update views,tableview using UISemanticContentAttributeForceRightToLeft before calling the PayPalPaymentViewController.

Please guide.

@bluk
Copy link
Contributor

bluk commented Oct 13, 2017

@adityaawok The SDK reads the language settings from the phone's language preferences, so unless you change the phone language and re-initialize the SDK, you may not get any changes in the UI. If I'm misunderstanding what the issue is, please open a new issue with more details and the SDK version, iOS version and the exact locale/language settings are you are trying to use. Thanks.

@hasanalbukhari
Copy link

hasanalbukhari commented Oct 14, 2017

According to Apple's guidelines. language shouldn't be changed from inside the app. Apple also doesn't provide an easy way to do it from inside the app in a way to be reflected on the UI direction.

For a full background about this please refer to my stack overflow answer here

The iOS app and also the paypal SDK depends on the following value on the plist file to layout the screens:

<key>CFBundleDevelopmentRegion</key>
<string>en</string>

This value can be accessed as following:
Bundle.main.preferredLocalizations[0]

By changing the AppleLanguages value, app start behaving according to it after an app restart.

UserDefaults.standard.set([lang], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()

Without a restart the UI direction will not get fixed.

Surprisingly, PayPal UI doesn't do the same. even after a restart, layout still messed up!!

In iOS 9 apple provided the following feature to force changing layout direction:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
This can be used for a single view too. not only for all the app views.

I use this to change the app direction without an app restart after I change the language.
I am suggesting that you take that in consideration to fix this issue.

Also, may be to investigate why PayPal UI does not behave according to AppleLanguages value when it get changed even after a restart.

@hasanalbukhari
Copy link

hasanalbukhari commented Oct 14, 2017

I had the folowing when I wrote the previous comment:

<key>CFBundleDevelopmentRegion</key>
<string>ar</string>

The layout wasnt fixed even after an app restart.

but if default language is en. it does get fixed after a restart!!

<key>CFBundleDevelopmentRegion</key>
<string>en</string>

@hasanalbukhari
Copy link

I fixed the issue with a workaround as following:
I change the language as I want in my app and I force direction.
But, before I present the PayPalPaymentViewController I return everything to its default state:

payPalConfiguration.languageOrLocale = app.languageDetails.language
let controller: PayPalPaymentViewController = PayPalPaymentViewController(payment: payment, configuration: payPalConfiguration, delegate: self)!
UserDefaults.standard.set(["en"], forKey: "AppleLanguages")
UserDefaults.standard.synchronize()
UIView.appearance().semanticContentAttribute = .forceLeftToRight
present(controller, animated: true, completion: nil)

on payPalPaymentViewController didComplete completedPayment and and payPalPaymentDidCancel I return it as I need:

UserDefaults.standard.set([app.languageDetails.language], forKey: "AppleLanguages")
        UserDefaults.standard.synchronize()
        if app.languageDetails.isArabic() {
            UIView.appearance().semanticContentAttribute = .forceRightToLeft
        } else {
            UIView.appearance().semanticContentAttribute = .forceLeftToRight
        }

I use this in the plist:
CFBundleDevelopmentRegion
en

And on app launch I change the default to ar if its the first app launch:
UserDefaults.standard.set(["ar"], forKey: "AppleLanguages")

PayPal is changing the layout direction based on languageOrLocale. but, when the app launguage and the app direction is forced against what is the app original language "CFBundleDevelopmentRegion". PayPal UI start to mess up. Therefore, I return everything to its origins before presenting PayPal controller.

@xiaoleih41
Copy link

This SDK has been deprecated. Please check here for more detail.

@User2004
Copy link

User2004 commented Dec 26, 2018

https://webappcodes.com/change-right-to-left-view-when-change-language-in-ios

This link code are working fine. it's just a one line code for set your app in mirror view.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants