使用IBLocalizable直接在界面生成器中本地化您的视图

IB可健康化

使用IBLocalizable在界面生成器中轻松本地化您的视图。

codecov.io 语言 兼容可可豆荚 棒 GitHub 许可证

使用 ,您可以轻松地本地化视图。只需将界面生成器中显示的新属性设置为您在可本地化 .大多数视图都可以通过这种方式进行本地化。IBLocalizableInterface BuilderLocalizable String.string filewithout a single line of code

安装

迅捷包管理器

添加到您的.Package(url: "https://github.com/PiXeL16/IBLocalizable.git",majorVersion: 1)Package.swift

可可豆荚

添加到您的 Podfile。pod 'IBLocalizable'

迦太基

添加到您的购物车文件。github "PiXeL16/IBLocalizable"

手动安装

  • 请注意,通过CocoaPods或迦太基安装要简单得多,建议使用。

下载并放入您的项目。/IBLocalizable

支持的视图

  • UILabel
  • 伊布顿
  • UI导航项(导航标题)
  • UIBarItem (BarButton, TabBarItem, etc)
  • UITextField
  • UITextView
  • UISearchBar

Supporting custom views

Custom views can be supported easily. Just create an and implement the Protocol.extensionLocalizable

If your custom view extends from you only need to extend your custom view and implement the .UIViewlocalizableProperty

For example: lets say that I have a custom view that contains several and a . I will like to localize one of the .UILabelUIImageViewUILabel

import UIKit
extension MyCustomView {

    public override var localizableProperty: String?{

        get{
            return self.label.text
        }
        set{
            self.label.text = newValue
        }
    }
}

Thats it! ? .

Usage

After the package its installed simply open your or . All of the supported views will show a property.StoryboardInterface BuildernewLocalizable String

interfaceBuilder

Since everything is extension based, should play nice with other libraries or that you are using.IBLocalizablepods

Build Performance

Since only uses and never , your incremental builds will continue to work. (http://www.openradar.me/20690594IBLocalizableIBInspectableIBDesignable)

Sample Project

In the you can find a sample project of a simple view controller. All of this is automatically localizable in English and Spanish by just using .Xcode ProjectLoginIBLocalizable

English

english

Spanish

spanish

To do

  • Support more views (TableView Cells, etc)
  • Improve sample project.

Author

Chris Jimenez – http://code.chrisjimenez.net, @chrisjimeneznat

? Donate

If you want to buy me a beer, you can donate to my coin addresses below:

BTC

1BeGBew4CBdLgUSmvoyiU1LrM99GpkXgkj

ETH

0xa59a3793E3Cb5f3B1AdE6887783D225EDf67192d

LTC

Ld6FB3Tqjf6B8iz9Gn9sMr7BnowAjSUXaV

License

IBLocalizable is released under the MIT license. See LICENSE for details.

GitHub

https://github.com/PiXeL16/IBLocalizable