SwiftyInAppLocalization 1.1.0

SwiftyInAppLocalization 1.1.0

Maintained by janlionly.



InAppLocalization

Version Carthage Compatible License Platform Swift

Description

SwiftyInAppLocalization which supports to switch the language at run time. Compatible with both Swift and Objective-C.

Installation

CocoaPods

pod 'SwiftyInAppLocalization'

Carthage

github "janlionly/InAppLocalization"

Swift Package Manager

.package(url: "https://github.com/janlionly/SwiftyInAppLocalization.git", .upToNextMajor(from: "1.0.0")),

Usage

Before do this, Firstly, you should set your localizations in your Xcode project; Secondly, add Localizable.strings and localize it.

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
  // Set you default language after launching
  InAppLocalization.shared().defaultLanguageCode = "en"
  return true
}

// somewhere you want to change language call "setCurrentLanguageCode", and must reload your view controller.
let ctrl = UIStoryboard(name: "Main", bundle: nil).instantiateInitialViewController()!
InAppLocalization.shared().setCurrentLanguageCode("ja", reload: ctrl) { (view) in
   view.alpha = 0
}

// or set the parameter of 'reload' to nil, then you do reload your view controller by yourself
InAppLocalization.shared().setCurrentLanguageCode(language.languageCode, reload: nil, animation: nil)
// reload your view controller here
// ...

Requirements

  • iOS 8.0+
  • Swift 4.2 to 5.2

Author

Visit my github: janlionly
Contact with me by email: [email protected]

Contribute

I would love you to contribute to SwiftyInAppLocalization

License

SwiftyInAppLocalization is available under the MIT license. See the LICENSE file for more info.