美文网首页
iOS Xcode 多语言支持

iOS Xcode 多语言支持

作者: 不存在的昵称 | 来源:发表于2024-12-23 17:20 被阅读0次

Xcode 15还是14之后多语言就不用创建LocalString文件了,新的文件是Stirng CataLog,如下图:


image.png

通过使用对应的Api


/// Xcode can read through a project's code to find invocations of
/// `NSLocalizedString(_:tableName:bundle:value:comment:)` and automatically
/// generate the appropriate strings files for the project's base localization.
@available(macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, *)
public func NSLocalizedString(_ key: String, tableName: String? = nil, bundle: Bundle = Bundle.main, value: String = "", comment: String) -> String

Xcode会自动帮我们生成对应的key和Value,如下图:


image.png

注意:不能对该方法封装或宏定义了,只能用这个系统的Api来用。

对于已经存在的项目而言,我们可以让Xcode帮我们把LocalString 文件转成 String CataLog。

image.png

相关文章

网友评论

      本文标题:iOS Xcode 多语言支持

      本文链接:https://www.haomeiwen.com/subject/nqppejtx.html