Last active
February 26, 2020 17:32
-
-
Save designatednerd/fdfb916cc4d4ad3f33c25e917a95a2be to your computer and use it in GitHub Desktop.
99 Bottles of Beer On The Playground
This file contains hidden or 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
import Cocoa | |
let beers = 0...99 | |
for beer in beers.reversed() { | |
let initial = String.localizedStringWithFormat(NSLocalizedString("beers_on_wall", comment: ""), beer, beer) | |
let nextStep = String.localizedStringWithFormat(NSLocalizedString("next_step", comment: ""), beer) | |
var nextBeer = beer - 1 | |
if nextBeer < 0 { | |
nextBeer = beers.max()! | |
} | |
let afterNext = String.localizedStringWithFormat(NSLocalizedString("after_next_step", comment: ""), nextBeer) | |
print("\(initial)\n\(nextStep) \(afterNext)\n") | |
} |
This file contains hidden or 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>beers_on_wall</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%#@beers@</string> | |
<key>beers</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>other</key> | |
<string>%d bottles of beer on the wall, %d bottles of beer!</string> | |
<key>one</key> | |
<string>%d bottle of beer on the wall, %d bottle of beer!</string> | |
<key>zero</key> | |
<string>No bottles of beer on the wall, no bottles of beer!</string> | |
</dict> | |
</dict> | |
<key>next_step</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%#@next@</string> | |
<key>next</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>other</key> | |
<string>Take one down, pass it around,</string> | |
<key>one</key> | |
<string>Take one down, pass it around,</string> | |
<key>zero</key> | |
<string>Go to the store and buy more beer,</string> | |
</dict> | |
</dict> | |
<key>after_next_step</key> | |
<dict> | |
<key>NSStringLocalizedFormatKey</key> | |
<string>%#@after_next@</string> | |
<key>after_next</key> | |
<dict> | |
<key>NSStringFormatSpecTypeKey</key> | |
<string>NSStringPluralRuleType</string> | |
<key>NSStringFormatValueTypeKey</key> | |
<string>d</string> | |
<key>other</key> | |
<string>%d bottles of beer on the wall.</string> | |
<key>one</key> | |
<string>%d bottle of beer on the wall.</string> | |
<key>zero</key> | |
<string>no bottles of beer on the wall.</string> | |
</dict> | |
</dict> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I couldn't get it to work in Resources/en.lproj/Localizable.stringsdict or stringsDict ... but it works in the ~/Documents/Shared Playground Data/Localizable.stringsdict. Here's my version
Thanks!