I\'m trying to localize my app using NSLocalizedString. When i import the XLIFF file, most works like a charm but something do not and some string is not localized. I have n
Here is an extension I use in String, it adds a localizeWithFormat function with variable arguments,
extension String:{
func localizeWithFormat(arguments: CVarArg...) -> String{
return String(format: self.localized, arguments: arguments)
}
var localized: String{
return Bundle.main.localizedString(forKey: self, value: nil, table: "StandardLocalizations")
}
}
Usage:
let siriCalendarText = "AnyCalendar"
let localizedText = "LTo use Siri with my app, please set %@ as the default list on your device reminders settings".localizeWithFormat(arguments: siriCalendarTitle)
Just be careful not to use the same function and property names that String has. I normally use a 3 letter prefix for all my framework functions.