Add better support for Swift string localization
| Originator: | davbeck | ||
| Number: | rdar://20732896 | Date Originated: | 28-Apr-2015 01:02 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Swift 1.2 |
| Classification: | Enhancement | Reproducible: | Always |
Summary: Swift has really cool string interpolation. It makes code much much easier to read. But, when using localized strings, if you try to use an interpolated variable, it will break localization. genstrings will pull out the variable names with the string. But when the app runs and looks up the string, it will combine the string before looking in the table and will not find any localized strings. Ideally, we would be able to have [NSString localizedStringWithFormat:] integrated directly with NSLocalizedString and genstrings. So you could do the following: NSLocalizedString(“\(photosCount) PHOTOS”, comment: “The label for the number of photos.”) And genstrings would create a strings file with: /* The label for the number of photos.*/ “%ld photos" = “%ld photos"; And localizedStringWithFormat would be called automatically to produce: “3,482 PHOTOS” Instead, if you do that now, genstrings will produce: /* The label for the number of photos.*/ “\(photosCount) PHOTOS" = “\(photosCount) PHOTOS"; And the string would end up being: “3482 PHOTOS” And it would never be localized because it wouldn’t look up localizations until after it has substituted the number.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!