AALocalizationKit
##描述
AALocalizationKit 是一款非常有助于在应用程序中维护多种语言(包括自定义语言字体),并能让你在应用内切换语言的有用工具!
##演示
AALocalizationKit
是一款易于配置的框架,可以方便地在 iOS 应用程序中配置多种语言。
要运行示例项目,请克隆仓库,然后首先从 Example 目录中运行 pod install
##要求
iOS 10.0+
- Xcode 11.0+
- Swift 5+
- 安装
AALocalizationKit
可以使用 CocoaPods、Carthage 或手动安装。
##CocoaPods
AALocalizationKit
可通过 CocoaPods 获得。要安装 CocoaPods,请运行:
$ gem install cocoapods
然后创建一个包含以下内容的 Podfile
最后,运行以下命令来安装它
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '<Your Target Name>' do
pod 'AALocalizationKit'
end
$ pod install
##Carthage
要安装 Carthage,请运行(使用 Homebrew):
$ brew update
$ brew install carthage
然后在 Cartfile 中添加以下行:
github "EngrAhsanAli/AALocalizationKit" "master"
然后,将库导入所有您使用它的文件中
import AALocalizationKit
##手动安装
如果您不希望使用上述任何依赖项管理器,可以手动将 AALocalizationKit
集成到项目中,方法是将 Classes 文件夹中的文件添加到您的项目中。
入门指南
只需在您的iOS应用程序的AppDelegate
中的didFinishLaunchingWithOptions
方法中配置 Lokalizacja,支持的语言即可。
以下是用以下语言支持的示例。
使用方法:
func configureAALK() {
let languageFont: [AALanguage : [UIFont.Weight : String]] = [
.ar : [.regular: "Jomhuria"],
.zhHans : [.regular: "Chibrush"],
.fr : [.regular: "MuchaFrenchCapitals"],
.de : [.regular: "LemonadeStand"],
.en : [.regular: "Roboto-Regular",
.medium: "Roboto-Medium",
.bold: "Roboto-Bold"],
.ja : [.regular: "NotoSerifJP-Regular",
.medium: "NotoSerifJP-Medium",
.bold: "NotoSerifJP-Bold"]
]
AALK.configuration.languageFont = languageFont
AALK.configuration.defaultFont = "Roboto"
}
现在只需更新视图控制器的语言。
let languageNames = AALK.bundleLanguageNames // get all bundle languages
let lang = AALK.languages[index] // where index is the language index for specific langauge
AALK.currentLanguage = lang // Set the language within your application
/// NOW YOU JUST NEED TO RECALL YOUR VIEW OR VIEW CONTROLLER TO SEE THE CHANGES
贡献 & 许可证
AALocalizationKit
受MIT许可证的约束。有关更多信息,请参阅许可证文件。
欢迎提出请求!最好的贡献将包括用于在应用程序生命周期中阻止主线程的已知类的配置或替换。
如果您在应用程序中使用AALocalizationKit
,请联系工程Ahsan Ali发电子邮件。