I want to display in a watch complication localized text that contains an argument set at runtime, e.g. „Available: 3“, where "3" should be set at runtime.
On iOS, this is easy: One defines a localized format string and insets into this format the actual parameter, like:
let str = String.init(format: NSLocalizedString("TEST", comment:"Test"), 3)
where the Localizable.strings
file contains an entry
"TEST" = "Available: %i";
In watchOS 3, if one wants to update a complication, one can use
func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void)
There, if the right complication type is provided, one could choose a complication template, and set some text, e.g. using:
let modularLargeTemplate = CLKComplicationTemplateModularLargeStandardBody()
modularLargeTemplate.headerImageProvider = CLKImageProvider.init(onePieceImage: UIImage(named: "Complication/Modular")!)
modularLargeTemplate.headerTextProvider = CLKSimpleTextProvider.localizableTextProvider(withStringsFileTextKey: „TEST“)
where a file ckcomplication.strings
contains e.g. an entry
"TEST" = "Available"
In this case, the complication would display „Available“.
The question is, how do I add an actual value, e.g. „3“, to the displayed text?