Scenario: I have a requirement in localization where I need to have values in a string irrespective of their order. An example could be considered as below:
1st language: {username} is {age} old.
2nd language Age {age} is of {username}.
Positional Specifier: To achieve this we have something called as positional specifiers. A discussion on this could be found here. I tried including positional specifiers in an example code as follows:
// Prints "Time is cruel"
let output = String(format: "%1$@ %2$@ %3$@", "Time", "is", "cruel")
// Prints "Time" but ideally should print the 3rd argument i.e "cruel".
let output1 = NSString(format: "%3$@", "Time", "is", "cruel")
Is there a way to achieve the functionality above? Can it be done via positional specifiers and if can what am I missing?