I encountered a localization problem today. At first I translated a string
like this.

let count = 10
> let says = NSLocalizedString("It runs \(count) times", comment: "run
> times")


I couldn't get the translation taking effect.

So I open the setting "Localization Debugging" in scheme and get this error:

[strings] ERROR, It runs 10 times not found in table Localizable of bundle
> CFBundle 0x100c01c40 ... (executable, loaded)
> IT RUNS 10 TIMES


I began to realize that` \(count)` was not dealed well in localization. The
compiler calculated the full string then looking for the translation,
instead of looking for the translation first.

I managed to replace my code with

let newSays = String.localizedStringWithFormat(NSLocalizedString("It runs
> %d times", comment: "new run times"), count)


However, I still thing it would be better if we could use \(foo) directly,
as it is more Swift style. Any idea why this can't happen?

Zhaoxin
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to