moathothman / molh Goto Github PK
View Code? Open in Web Editor NEWLocalization helper for iOS apps mainly focusing on the LTR/RTL issue
License: MIT License
Localization helper for iOS apps mainly focusing on the LTR/RTL issue
License: MIT License
I have view controller with tableview and collectionview included so in cellForItemfor indexpath I grabbed out the item and use property observer to fill in cell components
var store: Store? {
didSet {
storeNameLbl.text = store?.name.localized
if let url = store?.logoURL {
storeImage.contentMode = .scaleAspectFill
storeImage.sd_imageIndicator = SDWebImageActivityIndicator.grayLarge
storeImage.sd_imageIndicator?.startAnimatingIndicator()
storeImage.sd_setImage(with: url)
}
}
}
in func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
cell.store = self.stores[indexPath.row]
}
so all things changes correctly except tableview cells labels and collectionview labels
Hi @MoathOthman, firstly thanks for this great library,
There is a problem in the pod example, when change language to be arabic, image view in first ViewController not mirrored, if we set image view with tag = -1 in second view controller works fine, I see that if controller in navigation controller so it will loop on subviews in a navigation controller rather than a controller, I modified mirroringviewDidLoad method to handle.
This is my code:
@objc func mirroringviewDidLoad() {
mirroringviewDidLoad()
if UIApplication.shared.userInterfaceLayoutDirection == .rightToLeft {
if self is UINavigationController {
if let viewController = (self as! UINavigationController).viewControllers.first {
loopThroughSubViewAndFlipTheImageIfItsNeeded(viewController.view.subviews)
}
} else {
loopThroughSubViewAndFlipTheImageIfItsNeeded(self.view.subviews)
}
}
// Do any additional setup after loading the view.
}
when i switch language then not change UIMenuController
looks that switching the language does not affect menu controller.
Hi,
In your class MOLHLanguage, the RTL language array contains the "fr" language, you should remove it, as you know the fr isn't a RTL language,
Best Regards.
Hi there..
is there is a way i can set the default language of my app to Arabic rather than English?
Thanks in advance.
I’m trying to setup molh in objective c project
The project also have swift files but I can’t import molh classes in app.
Any solution?
The app is getting crashed on .reset() function. You are using delegate.window there but "window" has been moved to SceneDelegate in iOS 13.
UIView.transition(with: ((delegate.window)!)!, duration: 0.5, options: transition, animations: {}) { (f) in }
So, I tried to change it to sceneDelegate.window but it is still getting crashed.
Here is the screenshot for your reference: https://imgur.com/ZuPr4RW
Any workaround for now? Please let me know.
Regards,
After downloading your awesome pod I faced problem where I can't add Action connection for button from storyboard I get only outlet and collection outlet connections , But After searching I get the error is that in MOLHFontLocalizableViews.swift file you conforms MOLHFontable protocol and after delete conform of protocol the action connect return again , so please check this issue.
Thanks
Is it okay to use .forceRightToLeft for right to left language instead of localize the app ??
When Change Language from english to Arabic Or reverse UIAlertViewController does not localized unless i restart the app please i need fix i faced this issue and tried alot but can not find solution.
`let activityViewController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil)
if let avc = activityViewController.popoverPresentationController {
avc.sourceView = sView
}
sender.present(activityViewController, animated: true, completion: nil)`
I try to change the language to Arabic from edit schema but then RTL is not working on change language button click.Is there any way to set the default language to Arabic when the app installed for the first time.
While switching the language to Arabic, I need a specific UIView and the UIControls inside it not to be flipped. I had tried setting the tag as -1. But it didn't worked. How to make it out?
can you please update this for supporting swift 5?
I have problem when i active swizzling by this line
MOLH.shared.activate(true)
with some collection view or table view selection give me this error
2018-05-17 12:48:19.391146+0200 TestApp[3370:61813] -[UIButton _tvUpdateContentBackdropView]: unrecognized selector sent to instance 0x7f9993f36460
2018-05-17 12:48:19.409001+0200 TestApp[3370:61813] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton _tvUpdateContentBackdropView]: unrecognized selector sent to instance 0x7f9993f36460'
*** First throw call stack:
(
0 CoreFoundation 0x000000010957f12b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x0000000108c13f41 objc_exception_throw + 48
2 CoreFoundation 0x0000000109600024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 UIKit 0x000000010ad20f51 -[UIResponder doesNotRecognizeSelector:] + 295
4 CoreFoundation 0x0000000109501f78 forwarding + 1432
5 CoreFoundation 0x0000000109501958 _CF_forwarding_prep_0 + 120
6 UIKit 0x000000010b81be88 -[UITextField layoutSubviews] + 264
7 MOLH 0x00000001084ef881 _T0So9UIControlC4MOLHE18cstmlayoutSubviewsyyF + 33
8 MOLH 0x00000001084ef8c4 _T0So9UIControlC4MOLHE18cstmlayoutSubviewsyyFTo + 36
9 UIKit 0x000000010af7d81c -[UINib instantiateWithOwner:options:] + 2425
10 UIKit 0x000000010ac943ff -[UIViewController _loadViewFromNibNamed:bundle:] + 383
11 UIKit 0x000000010ac94d2b -[UIViewController loadView] + 177
12 UIKit 0x000000010ac9505c -[UIViewController loadViewIfRequired] + 195
13 UIKit 0x000000010ac958b9 -[UIViewController view] + 27
14 UIKit 0x000000010acc794a -[UINavigationController _startCustomTransition:] + 954
15 UIKit 0x000000010acde3b4 -[UINavigationController _startDeferredTransitionIfNeeded:] + 686
16 UIKit 0x000000010acdf6d3 -[UINavigationController __viewWillLayoutSubviews] + 150
17 UIKit 0x000000010af3a4e2 -[UILayoutContainerView layoutSubviews] + 231
18 UIKit 0x000000010abbea6d -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1439
19 QuartzCore 0x000000010a92761c -[CALayer layoutSublayers] + 159
20 QuartzCore 0x000000010a92b7ad _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
21 QuartzCore 0x000000010a8b286c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 364
22 QuartzCore 0x000000010a8df946 _ZN2CA11Transaction6commitEv + 500
23 QuartzCore 0x000000010a8e0694 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
24 CoreFoundation 0x0000000109521c07 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 23
25 CoreFoundation 0x0000000109521b5e __CFRunLoopDoObservers + 430
26 CoreFoundation 0x0000000109506124 __CFRunLoopRun + 1572
27 CoreFoundation 0x0000000109505889 CFRunLoopRunSpecific + 409
28 GraphicsServices 0x00000001121059c6 GSEventRunModal + 62
29 UIKit 0x000000010aaed5d6 UIApplicationMain + 159
30 Aoun 0x0000000107d8c247 main + 55
31 libdyld.dylib 0x000000010ea51d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
but with menu tableView not get this error
and when i comment this line in active method
swizzle(class:UIControl.self, sel: #selector(UIControl.awakeFromNib), override: #selector(UIControl.cstmlayoutSubviews))
the problem was solving , but what will happen when this line is still commented ?
I tried to use the Kurdish language ckb-IQ in my app and when I switch to this language some characters are not connected to each other, and when I used ku it is connected, so after doing some debugs and when I added ku to the iSRTLLanguage() it behave same as ckb-IQ so I guess when we forceRightToLeft for Kurdish language it is corrupting the text.
First, I thought it was an Xcode issue so I created this StackOverflow question
https://stackoverflow.com/questions/59967897/xcode-kurdish-localization-issue
i have used your library and its working just awesome!
but my problem is that i need to restart to see the language change .. how to to see language change without a restart just like your demo?
i have two buttons arabic and english .. when clicked on arabic i want to change language to arabic and same with english ...
so i cannot use MOLH.setLanguageTo(MOLHLanguage.currentAppleLanguage() == "en" ? "ar" : "en")
i tried MOLH.setLanguageTo("en") but it didn't do anything ... how to do it?
Hello, some people asked me to change the animation transition when switching language....
I managed to make it as easy as
MOLH.resetWithCrossDissolve()
please make this a feature available for all :) , thanks.
the simplest way is to extend MOLH with a new reset function.... and call it
MOLH.resetWithCrossDissolve()
for example
extension MOLH {
open class func resetWithCrossDissolve() {
let transition = UIViewAnimationOptions.transitionCrossDissolve
if let delegate = UIApplication.shared.delegate {
if delegate is MOLHResetable {
(delegate as!MOLHResetable).reset()
}
UIView.transition(with: ((delegate.window)!)!, duration: 0.5, options: transition, animations: {}) { (f) in
}
}
}
}
I tried using the maximumLocalizableTag option for stackview, and it never worked, I can't prevent it from flipping, i also looked up MOLH and didn't see any integration with stackviews, How can i prevent MOLH from flipping a stackview ? not even setting semanticContentAttribute works.
form medium :
Really it helped localize my app beautyfully but the issue isthat system inbuilt classes like Bar Button Item,UIPrinter Window the text language in that only changes when app is relaunced like if change language to spanish then also the inbuilt classes language will be english but if we launch app again then it will chage to spanish. Any solution for that will be great.
When call " MOLHFontLocalizableLabel().updateFont()" it's calling the function successfully but the label's font doesn't change
i have in my view a navigation view ... mostly on all pages ..
strangely some of these navigation views didn't flip when change language when most of them did flip .. why?
Flip Collection flow layout flow
When we change current Language to another language (english to arabic), it works fine . but now when we change language to previous one.(arabic to english) Its not working fine. UIApplication.isRTL() is false first time, when we change language , UIApplication.isRTL() is now true. but now when we change no matter in which language UIApplication.isRTL() is always true. but when we quit app and start it will change value give false and all wil work good. Can you please update it for Swift 4 or provide me the solution ?
hello
i'm newbee in ios developer. could your please tell me how to loacalize in all these language :- english, arabic, chinese, korean, russian
I have applied the language reset option. But the language change not applied exactly as needed. Change the language using set language option, and the design applied only when i close the app & reopen the app. Also some times Arabic to English change some layout changing from LTR to RTL. But the language text not updated.Keep the same language text.
Label inside the Tableview cell not aligned the correct language Direction. It affect only after restart the app.
I can change language from app but it changed after restart application ,
how to do it without restart message as drawn views not reset to the new localization ?
ref: https://medium.com/@omarhasan9394/great-work-thanks-2cc09eddb632
I have problem when add TextView textAligment right or left no change staill in one direction when switch language
notes:
this might be as the same as with the textfield or related.
acceptance criterea ;
the text input direction should follow the language direction.
placeholder alignment to match the language direction
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?
Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
Hi
I would like to ask about MOLHFontLocalizableViews, how the library deals with two font localization.
is it possible to change the font type as the language of the app change from Arabic to English, keeping the same labels,textFiled..etc text size?
thanks in advance
I use google map and dates and my app when change language my address not change to selected language and also date..
but when restart app its work why ??
So far, it works in conjunction of letting the "Swift Language Version" to be 3.2 even with Swift 4 projects, otherwise I will start seeing compile errors in many library files. However, shall we migrate it to support Swift 4?
we may override layoutsubviews in the extensions instead of swizzling ,
AC
Try that out and if it does not break things , consider using it.
we need yet to make it optional as with swizzling.
issues
Hi,
could you help me, what is the best way to define Arabic as the default language?
I did this in App delegate
MOLH.shared.activate(true)
MOLH.setLanguageTo("ar")
MOLH.reset()
but the problem with the TextView is not RTL, I have justified and centre text attributed alignment
I need to restart the app to see the correct alignment
After setting the following in AppDelegate
MOLHLanguage.setDefaultLanguage("ar")
MOLH.shared.activate(true)
I'm getting the following
print(MOLHLanguage.currentAppleLanguage()) // prints en
print(MOLHLanguage.currentLocaleIdentifier()) // print en_US
Hey moath
Thanks for your awesome library :)
My Project have slide menu and tabbar controller. So My app rootviewcontroller is slide menu and that side menu have center and left view controller.
So when I am trying to change language from app then side menu left and center viewcontroller's alignment is not working. All other viewcontroller's alignment is working fine.
When I relaunch app then left and center viewcontroller's alignment is working fine. but its not working when I call reset function from app.
I thinks that view's are not updating.
Please help me.
Thanks,
Ekta
Hii , thanks for your great work.
I got a performance issue with the pushing of new viewcontrollers after switching the langugaes. The pushing seems to be laggy. I have tried to use the main thread, but the issue is still there. Any solution for this??
When i change language almost everywhere it change but not change on IQKeyboard bar title like cancel, done etc
and not changing for camera like Cancel, Retake, Use Photo etc
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.