I found out how. I was able to do it creating a dictionary of the words I need it and making them localized
Here is how:
import Foundation
class LensStructFilter: Identifiable {
var description: String
init(description: String) {
self.description = description
}
var localizedDescription: String {
var result = description
let terms: [String: LocalizedStringResource] = [
"Focal": "Focal",
"Abertura Máxima": "Abertura Máxima",
"Bocal": "Bocal",
"Cobertura": "Cobertura",
"Diâmetro Frontal": "Diâmetro Frontal",
"Peso": "Peso",
"Foco Mínimo": "Foco Mínimo"
]
for (originalTerm, resource) in terms {
let localizedTerm = String(localized: resource)
result = result.replacingOccurrences(of: originalTerm, with: localizedTerm)
}
return result
}
}
Then on the ContentView where you want to use the description just change description to localizedDescription.
If there is another way please let me know.
Thanks
Topic:
Programming Languages
SubTopic:
Swift
Tags: