localicious icon indicating copy to clipboard operation
localicious copied to clipboard

Percentages on iOS in strings with vs. without arguments

Open johankool opened this issue 3 years ago • 0 comments

Due to the guard on the number of translationArgs, if a string contains a percentage sign, but not any placeholders, the percentage encoding isn't removed because it isn't used as a String format.

So it the yaml contains '42%', it shows up in Localizable.strings as '42%%' and in the UI as '42%%' too, but '%1{{s}} is 42%' comes true correctly.

Removing the guard fixes it.

        let translationArgs = self.translationArgs ?? []
        guard translationArgs.count > 0 else { return value }

        return String(format: value, arguments: translationArgs)

johankool avatar Feb 18 '21 10:02 johankool