xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

SwiftUI 国际化 & 本地化 All In One

SwiftUI 国际化 & 本地化 All In One

国际化和本地化

i18n & l10n

internationalization & localization

"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-2025

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @   xgqfrms  阅读(937)  评论(4编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .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
点击右上角即可分享
微信分享提示