SwiftUI 國際化 & 本地化 All In One
國際化和本地化
i18n & l10n
i
nternationalization
& l
ocalization
"internationalization".length
// 20 = 1 + 18 + 1
"localization".length
// 12 === 1 + 10 + 1
var body: some View {
ScrollView {
VStack {
// TextField("please input your idea ...", text: $text)
TextField("請輸入你的想法 💡", text: $text)
.padding(.horizontal)
.frame(height: 55)
.background(Color(UIColor.secondarySystemBackground))
.cornerRadius(10)
Button(
action: clickSave,
label: {
// Text("Save".uppercased())
Text("保存".uppercased())
.padding()
.font(.headline)
.frame(height: 55)
.frame(maxWidth: .infinity)
.foregroundColor(.white)
.background(Color.accentColor)
.cornerRadius(10)
}
)
}
.padding(14)
}
.navigationTitle("添加待辦事項 ✍🏻")
// .navigationTitle("Add Item ✍🏻")
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading: customBack)
.alert(isPresented: $showAlert, content: getAlert)
}
SwiftUI i18n
// SwiftUI 國際化 ? language
// NSLocalizedString(<#T##key: String##String#>, comment: <#T##String#>)
// String(localized: <#T##String.LocalizationValue#>)
// SwiftUI 國際化
button.title = NSLocalizedString("Order")
button.title = String(localized: "Order")
// zh-hans
Order = "訂單"
// en-US
Order = "Order"
Localize your SwiftUI app
https://developer.apple.com/videos/play/wwdc2021/10220/
Streamline your localized strings
https://developer.apple.com/videos/play/wwdc2021/10221/
https://developer.apple.com/documentation/swiftui/text/init(_:tablename:bundle:comment:)
https://developer.apple.com/documentation/Xcode/localization
https://developer.apple.com/documentation/foundation/nslocalizedstring
https://developer.apple.com/documentation/foundation/1418095-nslocalizedstring
https://developer.apple.com/documentation/xcode/localizing-strings-that-contain-plurals
https://developer.apple.com/documentation/corespotlight/cslocalizedstring/1616401-localizedstring/
https://www.youtube.com/watch?v=bbGJHSLbzH4
https://developer.apple.com/documentation/swiftui/
refs
https://en.wikipedia.org/wiki/Internationalization_and_localization
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/i18n
https://developer.mozilla.org/en-US/docs/Glossary/Localization
©xgqfrms 2012-2020
www.cnblogs.com/xgqfrms 發佈文章使用:只允許註冊用戶纔可以訪問!
原創文章,版權所有©️xgqfrms, 禁止轉載 🈲️,侵權必究⚠️!