0

I tried a lot of possibilities to specify only "2 digits" after the "." for this Double without success.

I don't know where to add , specifier: "%.2f".

// ContentView.swift
Text(String(format: NSLocalizedString("text [%lf]", comment: "Item"), item.value))

// Localizable.strings
"text [%lf]" = "Item [%lf]";

Do you have an idea where/how to add it? Thanks!

Alexnnd
  • 429
  • 4
  • 13

1 Answers1

0

I'm so dumb! I just had to replace [%lf] by [%.2f] directly in the NSLocalizedString.

// ContentView.swift
Text(String(format: NSLocalizedString("text [%.2f]", comment: "Item"), item.value))

// Localizable.strings
"text [%.2f]" = "Item [%.2f]";
Alexnnd
  • 429
  • 4
  • 13
  • Your solution is good. Just want to add that only the localized string needs to have the %.2lf ("Item [%.2f]") as this is this string that will be used . – Ptit Xav Sep 29 '22 at 13:31