超轻量级库,可帮助您本地化字符串,甚至可以直接在情节提要中本地化

翻译

CI 状态 版本 许可证 平台

商标

若要运行示例项目,请克隆存储库,然后首先从示例目录运行。pod install

要求

iOS 9 或更高版本。斯威夫特 5.

安装

Translatio可通过CocoaPods获得。要安装它,只需将以下行添加到您的 Podfile 中:

pod "Translatio"

用法

法典

Translatio 为 String 对象提供了 2 个新增功能:

  • localized财产
  • localized(withBundle:tableName)方法

They can both be used easily in code, this is an example :

let hello = "UI.Home.Hello".localized
let anotherHello = "UI.Home.Hello".localized(withBundle: Bundle.main, tableName: "Labels")

Interface Builder (storyboard and xib)

Translatio adds extensions to all the most common UI elements such as UIButton, UITextField, UITextView, UILabel, UIBarButtonItem, UINavigationItem. The extensions provide an property that can be modified directly in the storyboard. This gives a very big advantage in localizing interface files.@IBInspectable

Logo

As you can see the UILabel now has a Localizable Text property that can be modified directly in the IB.

Author

Andrea Mario Lufino, andrealufino.me.

License

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

GitHub

https://github.com/andrealufino/Translatio