My server sends tokens representing strings. I map the token to a message to present to the user. This means that rather than using (in my case) the English version of the string as a key I use a different value. For example:
let _ = NSLocalizedString(“keystring", tableName: "Localizable", bundle: NSBundle.mainBundle(), value: “Tell us your thoughts", comment: "statically localized”)
I would then like use NSLocalizedString to retrieve the English version, the same as any other language. For example:
let key = “keystring”
let message = NSLocalizedString(key, comment: “”)
If I hand-craft a Localized.strings file like the following:
/ statically localized */
“keystring" = “Tell us your thoughts”;
then this works. The problem is that only in the first (Swift) case does the string get included in the generated XLIFF. In this case the translation at run-time doesn’t work, the return value from NSLocalizedString is the key itself. In the second case the lookup works but the string is not put in the XLIFF for translation.
My question is how to localize a string which has a key other than the value itself and later look it up. While the initial Swift invocation shown above does return the localized value, I am looking up the string based on a server value and therefore cannot structure my code this way.
Thanks,
Cliff