使用IBLocalizable直接在界面生成器中本地化您的视图
使用IBLocalizable在界面生成器中轻松本地化您的视图。
使用 ,您可以轻松地本地化视图。只需将界面生成器中显示的新属性设置为您在可本地化 .大多数视图都可以通过这种方式进行本地化。IBLocalizable
Interface Builder
Localizable String
.string file
without 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.extension
Localizable
If your custom view extends from you only need to extend your custom view and implement the .UIView
localizableProperty
For example: lets say that I have a custom view that contains several and a . I will like to localize one of the .UILabel
UIImageView
UILabel
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.Storyboard
Interface Builder
new
Localizable String
Since everything is extension based, should play nice with other libraries or that you are using.IBLocalizable
pods
Build Performance
Since only uses and never , your incremental builds will continue to work. (http://www.openradar.me/20690594IBLocalizable
IBInspectable
IBDesignable
)
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 Project
Login
IBLocalizable
English
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.