I'm struggling to translate the output of a function which dynamically creates a string to then display on the view.
The function is the following:
func displayDateText(date: Date, weekNumber: Int, season: String, keyDates: [KeyDates.KeyDate: Date]) -> String {
var dateToDisplay = LocalizedStringResource(unicodeScalarLiteral: "")
let weekday = dateUtils.getWeekdayAsString(from: date)
if dateUtils.checkIfDateIsSunday(date: date) {
if (season.contains("season")) {
if weekNumber > 0 {
dateToDisplay = "\(weekday), Week \(weekNumber) of \(season)"
}
} else {
dateToDisplay = "Feria"
}
}
return String(localized: dateToDisplay)
}
Which then I call:
Text(dateCalculations.displayDateText(date: selectedDate, weekNumber: weekNumber, season: season, keyDates: keyDates))
And then I change the locale from english to spanish (I have implemented that elsewhere) and the translations work through the whole app but not here but the strings ("Feria" and "(weekday), Week (weekNumber) of (season)") are loaded into my string catalog correctly but then never used in the translation.
But this approach works when I have a function that only returns plain strings...