I’m running El Capitan 10.11.5 and xCode 7.3.1
I am localizing a Swift application for iOS. Due to the possibility of multiple occurances of the same string in different contexts I don’t want to use the typical form of NSLocalizedString that only takes a key and a comment. For example:
let hello = NSLocalizedString("Hello", comment: "greeting on first view controller”)
I prefer to use the form that allows specification of the a key distring from the value. For example:
let bundle = NSBundle.mainBundle() let hello = NSLocalizedString("initialview.hello", tableName: "Localized", bundle: bundle, value: "Hello", comment: "greeting on first view controller”)
I then run
find ./ -name "*.swift" -print0 | xargs -0 genstrings -o en.lproj
to generate my strings file. The genstrings command emits the follow error:
Bad entry in file .//LocalizationTest/ViewController.swift (line = 29): Argument is not a literal string.
Searching the usual places (like stackoverflow) indicates that this problem has existed for a while, multiple radars have been filed, and there has been no resolution.
What are my options? If I decide to go with the simplified form of NSLocalizedString and to replace redundant strings with identifiers when necessary (like I did in second example above) then how do I subsequently edit the Localized.strings file to update the keyto replace the redundant instance? Is there another way in Swift to use something other than the literal string as the key?
Thanks,
Cliff