tomkowz / Swifternalization

Localize iOS apps in a smarter way using JSON files. Swift framework.
MIT License
579 stars 47 forks source link

Where should the I18n.configure() be put? #12

Closed eeschimosu closed 8 years ago

eeschimosu commented 9 years ago

The method I18n.configure() should be in the didFinishLaunchingWithOptions method of the appDelegate?

tomkowz commented 9 years ago

It should be called before you ask for the first time for some translation. application:didFinishLaunchingWithOptions: is the best place.

Jeehut commented 8 years ago

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.

tomkowz commented 8 years ago

@Dschee Indeed, that could work I think. Good catch!

tomkowz commented 8 years ago

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!

tomkowz commented 8 years ago

1.3.1 Released.