I'm working on an app that has a toggle button to switch between English and Arabic language and should be on the fly. I'm using the method in https://github.com/maximbilan/ios_language_manager and it works fine in all cases except if the storyboard is localized by interface not strings:
Now when I reload the root view controller like this:
func reloadRootVC(){
let delegate : AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
delegate.window?.rootViewController = (storyboard.instantiateInitialViewController())
}
it reload the root with localized strings and in RTL but with the english storyboard not the arabic one.
Tried force loading the arabic one like this:
let storyboard = UIStoryboard(name: "Main", bundle: NSBundle(path: NSBundle.mainBundle().pathForResource(LanguageManager.currentLanguageCode(), ofType: "lproj")!))
but unfortunately it loads the storyboard but with no images. It can't read any resource image.
change the bundle which is used to init the storyboard:
although this change the storyboard based on language but do not load images! :(
I ended up by moving the arabic storyboard outside and name it Main-AR, then adding an extension in
UIStoryboard
to swizzle and initializer of storyboard to add-AR
to the end of the storyboard name if i'm on arabic mode.