Closed eeschimosu closed 8 years ago
It should be called before you ask for the first time for some translation. application:didFinishLaunchingWithOptions:
is the best place.
Just a question: Why is there a need for configuring Swifternalization at all? Couldn't it just configure itself if it wasn't configured yet on the first call of a localizedString
method? I'm thinking about something like this:
public class func localizedString(key: String, stringValue: String, fittingWidth: Int? = nil, defaultValue: String? = nil, comment: String? = nil) -> String {
guard sharedInstance.isConfigured else {
sharedInstance.load(NSBundle.mainBundle())
}
// more code
}
This way configuration would be optional.
@Dschee Indeed, that could work I think. Good catch!
Added configureIfNeeded
method that is called internally but still keeping configure(bundle:)
in case someone want to configure it with different bundle.
Will be available in the next release.
Thanks!
1.3.1 Released.
The method I18n.configure() should be in the didFinishLaunchingWithOptions method of the appDelegate?