Xcode 15还是14之后多语言就不用创建LocalString文件了,新的文件是Stirng CataLog,如下图:
通过使用对应的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,如下图:
注意:不能对该方法封装或宏定义了,只能用这个系统的Api来用。
对于已经存在的项目而言,我们可以让Xcode帮我们把LocalString 文件转成 String CataLog。