SwiftUI 国际化 & 本地化 All In One
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://devstreaming-cdn.apple.com/videos/wwdc/2021/10221/4/E712C2D5-BD11-435B-8F19-C4ACFD79160A/downloads/wwdc2021-10221_hd.mp4?dl=1
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, 禁止转载 ???,侵权必究??!