Last active
July 3, 2018 11:44
-
-
Save amake/dea90f6eba4a300927ed to your computer and use it in GitHub Desktop.
Advanced Apple .stringsdict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// Place included Localizable.stringsdict in ~/Documents/Shared Playground Data | |
import AppKit | |
import XCPlayground | |
let bundle = NSBundle(URL: XCPlaygroundSharedDataDirectoryURL)! | |
let format = NSLocalizedString("PhotosMoviesRemaining", tableName: nil, bundle: bundle, value: "", comment: "") | |
NSString.localizedStringWithFormat(format, 0, 0) // "Done!" | |
NSString.localizedStringWithFormat(format, 0, 1) // "1 video remaining" | |
NSString.localizedStringWithFormat(format, 0, 2) // "2 videos remaining" | |
NSString.localizedStringWithFormat(format, 1, 0) // "1 photo remaining" | |
NSString.localizedStringWithFormat(format, 2, 0) // "2 photos remaining" | |
NSString.localizedStringWithFormat(format, 1, 1) // "1 photo, 1 video remaining" | |
NSString.localizedStringWithFormat(format, 1, 2) // "1 photo, 2 videos remaining" | |
NSString.localizedStringWithFormat(format, 2, 2) // "2 photos, 2 videos remaining" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>PhotosMoviesRemaining</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%1$#@d_photos_d_movies@</string> | |
<key>d_photos_d_movies</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>zero</key> | |
<string>%2$#@no_photos_d_movies@</string> | |
<key>one</key> | |
<string>%d photo%2$#@delimiter@%2$#@d_movies@ remaining</string> | |
<key>other</key> | |
<string>%d photos%2$#@delimiter@%2$#@d_movies@ remaining</string> | |
</dict> | |
<key>no_photos_d_movies</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>zero</key> | |
<string>Done!</string> | |
<key>other</key> | |
<string>%2$#@d_movies@ remaining</string> | |
</dict> | |
<key>d_movies</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>zero</key> | |
<string></string> | |
<key>one</key> | |
<string>%d video</string> | |
<key>other</key> | |
<string>%d videos</string> | |
</dict> | |
<key>delimiter</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>zero</key> | |
<string></string> | |
<key>other</key> | |
<string>, </string> | |
</dict> | |
</dict> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A
.stringsdict
this complex will be nearly impossible for translators to translate correctly. Instead of this, it's better to separate out your cases and have a bit of branching in your code:0, 0
case ("Done!"
)0, n
case (movies only)n, 0
case (photos only)n, n
case