项目作者: MartinStamenkovski

项目描述 :
Language Manager written in Swift
高级语言: Swift
项目地址: git://github.com/MartinStamenkovski/LGManager.git
创建时间: 2020-03-16T11:59:04Z
项目社区:https://github.com/MartinStamenkovski/LGManager

开源协议:MIT License

下载


LGManager

You can use this class when you need to change language in your application programatically.

Instalation

Just drop the LGManager.swift file into your project.

Usage

  1. LGManager.setLanguage(with: "<#prefix#>")

where prefix is for example “en”.

Simple example with UILabel

  1. let label = UILabel()
  2. label.text = .localize(key: "username")

After you set language you shoud “restart” the application, for example:

  1. LGManager.setLanguage(with: "<#prefix#>")
  2. let storyboard = UIStoryboard(name: "Main", bundle: nil)
  3. let tabController = storyboard.instantiateViewController(withIdentifier: "tabBarController") as! UITabBarController
  4. UIView.transition(with: keyWindow, duration: 0.4, options: [.transitionFlipFromLeft, .curveEaseInOut], animations: {
  5. keyWindow.rootViewController = tabController
  6. keyWindow.makeKeyAndVisible()
  7. }, completion: nil)

License

MIT