MoathOthman / MOLH

Localization helper for iOS apps mainly focusing on the LTR/RTL issue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

set Default Language to Arabic not working right on first run

oenama opened this issue · comments

on didFinishLaunchingWithOptions

       MOLH.reset()
       MOLHLanguage.setDefaultLanguage("ar")
       MOLH.shared.activate(true)

UITextField, UITextView, UINavigationController's swipe gesture for back are not flipped right on the first run.
and I did uncheck 'Respect language direction' in one or two places in storyboard, but it was flipped to left as if I didn't uncheck this option.

I tried to change semanticContentAttribute, but it didn't work either :

UITextField.appearance().semanticContentAttribute = .forceRightToLeft
UINavigationBar.appearance().semanticContentAttribute = .forceRightToLeft
UITextView.appearance().semanticContentAttribute = .forceRightToLeft

is that normal on first run? any thoughts on it?

@MoathOthman

@oenama you can call reset() function after MOLH.shared.activate(true) , that should fix it for you,, the reason for the previous behaviour is that the root is already set when you call

  MOLH.reset()
       MOLHLanguage.setDefaultLanguage("ar")
       MOLH.shared.activate(true)

let me know how it goes with you

@oenama you can call reset() function after MOLH.shared.activate(true) , that should fix it for you,, the reason for the previous behaviour is that the root is already set when you call

  MOLH.reset()
       MOLHLanguage.setDefaultLanguage("ar")
       MOLH.shared.activate(true)

let me know how it goes with you

same issue at first run.
@MoathOthman

Can you try the demo project and compare the results

I've tested it on the demo project, added what you suggested, UITextField flipped correctly, but still, UINavigationController's swipe gesture not flipped to right on first run.

https://youtu.be/RXyFiy8OEq4

I tried it in the demo , it seems fine, clone the latest code.

the code looks like this

 MOLHFont.shared.arabic = UIFont(name: "Courier", size: 13)!
        MOLHLanguage.setDefaultLanguage("ar")
        MOLH.shared.activate(true)
        MOLH.shared.specialKeyWords = ["Cancel","Done"]
        reset()

@oenama

for UINavigationController's back button, I meant the swipe gesture itself

on first run --> https://www.dropbox.com/s/md5l0n1phj3sfhz/01.mov?dl=0
the normal/ defualt behaviour for RTL --> https://www.dropbox.com/s/7m3g8u582zr5r18/02.mov?dl=0

@MoathOthman

I see, thats weird

I'm facing the same issue, after the first run all the alignment is good but the first install and run is not activated. Any updates on this issue?

am have the same problem also in iPhone v 14.0.1

@oenama I am terribly sorry for the late reply, got really busy and forgot about this issue. for the navigation issue its now fixed 👍 in version 1.4.3
@AbuMandour u facing the same issue or the default language not working?
@omar1taha sorry for the late reply, the keypoint here is to call reset after setting the default language, check the code above in this thread

@MoathOthman when I set default language to Arabic first time some alignment didn't apply in the right way but it fixed once close and reopen

@AbuMandour hey, can you provide example e.g. screenshots of the ui elements not working.

in AppDelegate I do this

        MOLHLanguage.setDefaultLanguage("ar")
        MOLH.shared.activate(true)

and in any controller label direction goes to ltr just in the first run and with labels which load from API
134728416_395307324882374_4707758817411621812_n

@MoathOthman I have the same issue, application in the first launch alignment is wrong and i have to terminate the app and reopen again

@AbuMandour @Hzza3 hey guys, can you check this issue #64, you need to se the tags for the labels.

same issue here

@ASamirbadran
have you tried
~MOLHLanguage.setDefaultLanguage("ar") MOLH.shared.activate(true)

@MoathOthman yes and problem still exist
Note : iam using swiftgen in my app

@ASamirBadranIbtikar what did you try? what was the result exactly? and what do you expect?
cam you provide sample screenshot or any info to help us here, if you can reproduce it in a sample code it will be great.
i have not tried swiftgen but i don;t think it will hurt unless it does swizzling or something on the run time. have you checked this #64