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://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-2025
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/16297206.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
2021-05-22 uni-app charts All In One
2020-05-22 Azure & FaaS in Action
2020-05-22 css & focus-within & pseudo class
2020-05-22 HTML5 & canvas fingerprinting
2019-05-22 vue & npm & components & plugins
2019-05-22 CSS3 Animation & linear-gradient & css3 var & @keyframes
2019-05-22 iOS effect & swiper delete components