1

I am trying to return an interpolated String from a business logic thats return only string type.

I have tried few way but are not useful

let value = LocalizedStringKey.init(stringLiteral: "stringKey")
        return ("\(value) \(message)")
LocalizedStringKey(key:"stringKey",
hasFormatting: false, arguments[])

Some suggest to use Text() to get desire result but seems producing similar error

text(storage:SwiftUI.Text.Storage.anyTextStorage(SwiftUI
.(unknown context at $7fff5762368).LocalizedTextStorage),

Am I missing something here ? Or do we have solution !

I_love_vegetables
  • 1,575
  • 5
  • 12
  • 26
NormalGuy
  • 97
  • 14

2 Answers2

0

Probably you wanted this

let value = NSLocalizedString("stringKey", comment: "")
Asperi
  • 228,894
  • 20
  • 464
  • 690
0

What finally worked for me, so answering here (I am using inside Framework)

extension String {
    var getLocaliseValue: String {
        if let frameworkBundle = Bundle(identifier: "com.companyname.FrameworkName") {
          return NSLocalizedString(self, bundle: frameworkBundle, comment: "")
    }
    return ""
}

}

usage :

"key".getLocaliseValue
NormalGuy
  • 97
  • 14