MoathOthman / MOLH

Localization helper for iOS apps mainly focusing on the LTR/RTL issue
MIT License
117 stars 36 forks source link

converting language from ar to eng or reverse #17

Closed lamatat closed 6 years ago

lamatat commented 6 years ago

am getting this error when changing the language to eng from ar

screen shot 2018-05-29 at 1 44 29 pm

what is this error and how to solve it please?

thanks in advance..

lamatat commented 6 years ago

any news about this? @MoathOthman

MoathOthman commented 6 years ago

Hey let me check it later on tonight .

Sent from my iPhone

On May 30, 2018, at 2:39 PM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

any news about this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#issuecomment-393129622, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNh9tE3NFei_YxkLN9VQGo7EnSqgFwks5t3oTtgaJpZM4URQXh.

MoathOthman commented 6 years ago

If you can give me more info about the environment, Have you tried the demo project? Can you reproduce the issue there?

Sent from my iPhone

On May 30, 2018, at 2:39 PM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

any news about this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#issuecomment-393129622, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNh9tE3NFei_YxkLN9VQGo7EnSqgFwks5t3oTtgaJpZM4URQXh.

lamatat commented 6 years ago

yes i did tried it .. i will try doing that and let you know ..

lamatat commented 6 years ago

i just tried but didn't know how to do it x_x but i think this happened when i used MOLHLanguage.isArabic()

MoathOthman commented 6 years ago

What happens if you use isRTL instead

Sent from my iPhone

On May 30, 2018, at 2:49 PM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

i just tried but didn't know how to do it x_x but i think this happened when i used MOLHLanguage.isArabic()

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#issuecomment-393132170, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNh-4bAjH0vpzgKFoDPd79UA0r_03pks5t3odKgaJpZM4URQXh.

lamatat commented 6 years ago

got same error ...

trie to comment them all .. and worked without errors .. so the problem is really from MOLHLanguage.isArabic() and MOLHLanguage.isRTL()

but i need to know if its arabic or not so i need to use one of them :(

if you please can help me solve this

thanks in advance!

MoathOthman commented 6 years ago

what are the languages you are supporting and how many?

Sent from my iPhone

On May 30, 2018, at 3:00 PM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

got same error ...

trie to comment them all .. and worked without errors .. so the problem is really from MOLHLanguage.isArabic() and MOLHLanguage.isRTL()

but i need to know if its arabic or not so i need to use one of them :(

if you please can help me solve this

thanks in advance!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#issuecomment-393134959, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNhwRcoM1sPpxtOmphPM_nbN7CwIikks5t3onjgaJpZM4URQXh.

lamatat commented 6 years ago

just two .. english and arabic

MoathOthman commented 6 years ago

can you replace the function with this /// get current Apple language public class func currentAppleLanguage() -> String { let userdef = UserDefaults.standard let langArray = userdef.object(forKey: APPLE_LANGUAGE_KEY) as! NSArray let current = langArray.firstObject as! String let currentWithoutLocale = current.substring(to: current.index(current.startIndex, offsetBy: 2)) return currentWithoutLocale }

lamatat commented 6 years ago

screen shot 2018-05-30 at 3 25 48 pm

got the same error in next function ...

MoathOthman commented 6 years ago

Ok then please use the latest commit then , the release is not updated apparently . U can do that on your podfile

Sent from my iPhone

On May 30, 2018, at 3:26 PM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

[screen shot 2018-05-30 at 3 25 48 pm]https://user-images.githubusercontent.com/39458325/40719930-c1d0794c-641d-11e8-81a4-1e638f537a77.png

got the same error in next function ...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#issuecomment-393142201, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNhzrj8QDUcovmyiW63pCm19kedjqPks5t3o_zgaJpZM4URQXh.

lamatat commented 6 years ago

you mean just to do pod update? or do you have a version number to add in podfile? sorry i didn't really get what do you mean x_x

MoathOthman commented 6 years ago

@lamatat you can use pod 'MOLH',:git => 'https://github.com/MoathOthman/MOLH.git'

lamatat commented 6 years ago

i got this [!] Unable to find a specification for 'MOLH'.

MoathOthman commented 6 years ago

@lamatat

i got this [!] Unable to find a specification for 'MOLH'.

its fixed now , thanx for pointing it out. please try again.

lamatat commented 6 years ago

am getting the same error even after updating the pod

screen shot 2018-05-31 at 11 32 19 am

MoathOthman commented 6 years ago

@lamatat can you debug it , print the result of userdef.object(forkey: ....)

lamatat commented 6 years ago

got this: Optional(<__NSSingleObjectArrayI 0x125d6bd70>( ar ) ) before crashing...

MoathOthman commented 6 years ago

NSSingleObjectArray!, interesting , I think you have only one language for the device which is arabic, right? , if you go to settings app -> general -> languages , you should see one language, right?

lamatat commented 6 years ago

no there's 2 .. english and arabic

lamatat commented 6 years ago

sorry i was running the app with arabic language x_x now changed it to system language and got this: Optional(<__NSCFArray 0x13de224a0>( ar, en ) )

MoathOthman commented 6 years ago

@lamatat do you still get the crash then?

lamatat commented 6 years ago

yes i do same crash as the screenshot above

MoathOthman commented 6 years ago

mmmm, thats really weird. is there any environment factors you have, did you try it on device while not in debug mode? I updated the code to swift 4 , can you pod install again and try?

lamatat commented 6 years ago

same :( please help me solve this T_T

lamatat commented 6 years ago

found out something ... this is only happens when used in: class TextField: UITextField for example... any idea?

MoathOthman commented 6 years ago

@lamatat since textfield functionality is not that perfect, comment out the line where its swizzled .. swizzle(class:UITextField.self, sel: #selector(UITextField.layoutSubviews), override: #selector(UITextField.cstmlayoutSubviews))

lamatat commented 6 years ago

just found something ... this has nothing to do with your library ... because i have tried: let pre = Locale.preferredLanguages.first if pre == "ar"{ ...... } and got the same error! which is really wired!

sorry for all the trouble but it has nothing to do with your awesome library :) i have another question i will open new issue if you please can check it out .. thanks

MoathOthman commented 6 years ago

Thnx for letting me know , please tell us what was the issue when u find the solution. Thnx

Sent from my iPhone

On Jun 5, 2018, at 9:58 AM, lamatat notifications@github.com<mailto:notifications@github.com> wrote:

Closed #17https://github.com/MoathOthman/MOLH/issues/17.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/MoathOthman/MOLH/issues/17#event-1662925542, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABHNh_9jneTy-hfokGFTWQg8EA6wuyGaks5t5iwQgaJpZM4URQXh.

lamatat commented 6 years ago

sure.. thanks you :)!