Questions tagged [localizedstringkey]
8 questions
6
votes
1 answer
Why does the behaviour of LocalizedStringKey depend on whether I pass a string interpolation to its initialiser?
While trying to answer this question, I found a strange behaviour.
Text(LocalizedStringKey("Hello \(Image(systemName: "globe"))"))
displays a globe, but
Text(LocalizedStringKey("Hello {world}".replacingOccurrences(of: "{world}", with:…

Sweeper
- 213,210
- 22
- 193
- 313
3
votes
1 answer
SwiftUI Text and LocalizedStringKey with parameter
I am trying to add a SwiftUI localized Text with parameter. However in the whole app we use a wrapper around localization keys so we have something like this:
static let helloWorldText = NSLocalizedString("helloWorldText", comment: "")
with…

Maciej Zajda
- 165
- 9
1
vote
1 answer
How to make LocalizedStingKey type conform to Codable protocol in Swift?
How to make LocalizedStingKey type conform to Codable protocol in Swift?
A simple Person struct. If do not remove country property, compiler not work.
struct Person: Codable {
let name: String
let age: Int
let description:…

Edwardai
- 491
- 4
- 8
1
vote
0 answers
SwiftUI - LocalizedStringKey interpolation
I have a Localizable.strings with all the text I need. Example:
"Welcome": "Hello there, welcome!!";
To not misspeal the LocalizedStringKey "Welcome" in many parts of the app I created an enum like this:
enum LocalizableKey: LocalizedStringKey {
…

lopes710
- 315
- 1
- 3
- 19
1
vote
0 answers
Multiple placeholders in localization in SwiftUI
I need to have multiple placeholders in the localization text, but having a hard time differentiating them. For example:
English:
"some_currency %@ %@" = "%@ %@"; // 1233454.34 USD
Arabic:
"some_currency %@ %@" = "%@ %@"; // USD…

TruMan1
- 33,665
- 59
- 184
- 335
0
votes
1 answer
Is there any way to get localizations from iOS?
If I show an alert without any buttons, a default button is "OK". In Korean iOS it is "확인" and in Japanese it is "OK" as well.
So if I can refer localizations from iOS, it's much easier to translate my app. If not, I have to translate every my…

ST K
- 69
- 6
0
votes
2 answers
How to sort a array with localized String in SwiftUI
Hi my problem is that i want to sort an array of objects by the object's title property. When i change the title's type from String to LocalizedStringKey i get an error. Is there a way to sort the correct translated string behind the…

Noem
- 19
- 3
-1
votes
1 answer
How to use a string variable with LocalizedStringKey
I'm stuck when trying to use a variable to define a LocalizedStringKey. For example, in the simplified code below, Option 1 returns the translated value from my localizable.strings file but I'm trying to get Option 2 to work. The returned error is…

DHHJ
- 103
- 1
- 12