Home > Net >  SwiftUI localization doesn't work shows only keys Xcode
SwiftUI localization doesn't work shows only keys Xcode

Time:01-28

i am working on app using SwiftUI in Xcode, and i want to localise it, but i have an issue. I already done all steps from youtube video

  1. Added localizations in Project -> info -> localizations
  2. Created 2 localization files
  3. Filled it like "hll" = "Hello"; etc.

and when i build an app i have only keys instead values (hll instead Hello), so i tried Text("hll") and Text(LocalizedStringKey("hll")). What am i missing?

CodePudding user response:

Make sure you have the Localizable.strings file in your project. There is where LocalizedStringKey looks for the keys/values as a default.

https://developer.apple.com/documentation/swiftui/localizedstringkey

If you want to define a different file use the

Text(LocalizedStringKey, tableName: String?, bundle: Bundle?, comment: StaticString?)

initializer and the tableName should match your .strings file name.

  •  Tags:  
  • Related