Platformsios 8.0, requires ARC

Build Status
Pod version
Carthage Compatible
Platform info



WBLanguage is a high level LanguageKit. It provides a High Level API set international language for your app.


  • Less time to switch the language
  • Set the language more convenient
  • Supported languages: English/French/Italian/German/Russian/Chinese-Hans/Chinese-Hant
  • Subsequent can add more national languages


WBLanguage supports multiple methods for installing the library in a project.


CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries like WBAlamofire in your projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.2.0+ is required to build WBLanguage.


To integrate WBLanguage into your Xcode project using CocoaPods, specify it in your Podfile:

source ''
platform :ios, '8.0'

target 'TargetName' do

pod 'WBLanguage'


Then, run the following command:

$ pod install


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate WBLanguage into your Xcode project using Carthage, specify it in your Cartfile:

github "JsonBin/WBLanguage"

Run carthage to build the framework and drag the built WBLanguage.framework into your Xcode project.


  • iOS 8+
  • Xcode 9.0+
  • Swift 4.0+
WBLanguage VersionMinimum iOS TargetNote
1.xiOS 8Xcode 9+ is required.

you must create a ‘Language.bundle’ resources in your project to hold the international language.


WBLanguageManager class

We can set WBLanguageManager’s property at the beggining of app launching, the sample is below:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        WBLanguageManager.duration = 2.0
        return true

if you want to set a new language, you can use setLanguage(_:) to update the UI. And it will automatically save the language of your choice.


you can use textForKey(_:, value:) to get the local text from *.lproj.

let string = WBLanguageManager.textForKey("key")

WBLanguage class

WBLanguage supports serializing and deserializing any custom type as long as it conforms to the WBLanguageProtocol protocol.

public extension WBLanguageProtocol {
    public var lt: WBLanguage<Self> {
        return WBLanguage(self)

extension `yourCustom` : WBLanguageProtocol {}

Note: WBLanguageProtocol is a protocol that WBLanguage uses internally to directly. So you need to complete the language setting.

For example:

private func setLanguagePicker(
    _ object: NSObject,
    Selector selector: String,
    Picker picker: WBLanguagePicker?
) {
    object.languagePickers[selector] = picker
    object.performLanguage(selector, Picker: picker)

public extension WBLanguage where T : UILabel {
    public func setPicker(_ picker: WBLanguageTextPicker?) {
        setLanguagePicker(value, Selector: "setText:", Picker: picker)
    public func setAttributedPicker(_ picker: WBLanguageDictionaryPicker?) {
        setLanguagePicker(value, Selector: "setAttributedText:", Picker: picker)
    public var picker: WBLanguageTextPicker? {
        set{ setLanguagePicker(value, Selector: "setText:", Picker: newValue) }
        get{ return getLanguagePicker(value, Selector: "setText:") as? WBLanguageTextPicker }
    public var attributedPicker: WBLanguageDictionaryPicker? {
        set{ setLanguagePicker(value, Selector: "setAttributedText:", Picker: newValue) }
        get{ return getLanguagePicker(value, Selector: "setAttributedText:") as? WBLanguageDictionaryPicker }



let label = UILabel() = "Label"

UILabel can use *.lt.picker or *.lt.setPicker(_:) to load text.

Of course, if you want to add attributes to the font, you can use WBLanguageDictionaryPicker or WBLanguageManager.textForKey("key")

to take out the text first and then add attributes.

use WBLanguageDictionaryPicker: = WBLanguageDictionaryPicker(dicts: ["picker": "Label", NSAttributedStringKey.foregroundColor:, NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17)])


if let text = WBLanguageManager.textForKey("Label") {
    let att = NSAttributedString(string: text, attributes: [.font: UIFont.boldSystemFont(ofSize: 17), .foregroundColor:])
    label.attributedText = att


The use of the UITextField and UILabel is same, just more placeholder:

let textfield = UITextField() = "Label"

attribute picker: = WBLanguageDictionaryPicker(dicts: ["picker": "Label", NSAttributedStringKey.foregroundColor:, NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17)])


let button = UIButton(type: .system)"Button", forState: .normal)

attribute text:

let picker = WBLanguageDictionaryPicker(dicts: ["picker": "Button", NSAttributedStringKey.foregroundColor:, NSAttributedStringKey.font: UIFont.boldSystemFont(ofSize: 17), NSAttributedStringKey.strikethroughStyle:NSUnderlineStyle.styleDouble.rawValue]), forState: .normal)


let segment = UISegmentedControl(items: ["","","","",""])"English", forSegmentAt: 0)"Russian", forSegmentAt: 1)"French", forSegmentAt: 2)"Italian", forSegmentAt: 3)"German", forSegmentAt: 4)

UISegmentedControl just has one method to set text picker.


WBLanguage is available under the MIT License. See the LICENSE file for more info.

Latest podspec

    "name": "WBLanguage",
    "version": "1.1.01",
    "license": "MIT",
    "summary": "In your project, you can easy to change the language with swift.",
    "homepage": "",
    "authors": {
        "JsonBin": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.1.01"
    "platforms": {
        "ios": "8.0"
    "source_files": "Source/*.swift",
    "requires_arc": true

Pin It on Pinterest

Share This