Adding a small sample below, since it took me a while to determine the formatting of the Localizable.strings file.
An example of adding variables to a localized string:
In code:
let myVar: String = "My Var" String(format: NSLocalizedString("translated_key %@", comment: "Comment"), myVar)
In the Localizable.strings file:
"translated_key %@" = "My var is: %@";
Of course, the %@ on the right side can be replaced:
"translated_key %@" = "My var is: %@"; "translated_key %@" = "%@ is my var"; "translated_key %@" = "I use %@ as my var";
In addition, %@ can be replaced with %d for int or %f for float.
source share