我需要在不同的應用程式中經常本地化相同的短語,如“無廣告”。有什么方法可以添加我經常本地化的單詞/短語,以便 Xcode 自動本地化它們?
uj5u.com熱心網友回復:
使用功能
func NSLocalizedString(
key: String,
tableName: String? = default,
bundle: NSBundle = default,
value: String = default,
comment: String) -> String
在您的專案中創建一個與默認格式相同的字串檔案 (Localizable.strings)。然后您可以添加不同語言的本地化。
使用它(假設你的包中的檔案名是 myCommonsStrings.strings :
let noAdd = NSLocalizedString(key: "NoAdd",
tableName: "myCommonsStrings",
comment: "No add string”)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/351974.html
