Jp4Real Jp4Real - 7 months ago 9
Swift Question

Swift app translation does not work with a string showing a var

I'm trying to translate my app but it is not currently working for a single line! Here's my code:

mailVC.setMessageBody(NSLocalizedString("Your Flight Hazard Index Score : \((totalScore as NSNumber).stringValue) <br /> <br />Canadian Helicopters Limited", comment: ""), isHTML: true)


and it is translated in localized.strings like this:

"Your Flight Hazard Index Score : \((totalScore as NSNumber).stringValue) <br /> <br />Canadian Helicopters Limited"="Votre Résultat d'évaluation du risque : \((totalScore as NSNumber).stringValue) <br /> <br />Hélicoptères Canadiens Limitée";


Any ideas?

Answer

I have an answer, for those who might need it one day,

what I've done is made a var containing all my strings, then added that var to my set.MessageBody. take a look :

var emailtext = NSLocalizedString("Your Flight Hazard Index Score : "), comment : "");
emailtext += "\(totalscore)";
// and so on...

and here is my set.MessageBody

mailVC.setMessageBody("\(emailtext)"), isHTML: true)

that way I'm able to add as many other values and var and strings I want to my email

thanks !