What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let...
Transcript of What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let...
![Page 1: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/1.jpg)
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
#WWDC15App Frameworks
What’s New in InternationalizationSession 227
Nat Hillard Frameworks, Internationalization
![Page 2: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/2.jpg)
OverviewOverview
![Page 3: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/3.jpg)
![Page 4: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/4.jpg)
69%of Apple revenue is international
![Page 5: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/5.jpg)
Other 69%
US 31%
Worldwide App Store Sales
![Page 6: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/6.jpg)
Others 28%
China 16% Japan
25%
US 31%
Worldwide App Store Sales
![Page 7: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/7.jpg)
Outline
LocalizationFormattingHandling TextLayout
![Page 8: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/8.jpg)
LocalizationFormattingHandling TextLayout
![Page 9: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/9.jpg)
LocalizationFormattingHandling TextLayout
![Page 10: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/10.jpg)
LocalizationMaking your app speak your customer’s language
![Page 11: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/11.jpg)
LocalizationLanguage and region settings
Specify primary languageSpecify ordeing of preferred languagesSpecify region independently
![Page 12: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/12.jpg)
LocalizationLanguage and region settings
![Page 13: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/13.jpg)
LocalizationLanguage and region settings
![Page 14: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/14.jpg)
LocalizationLanguage and region settings
Advanced Topics in Internationalization WWDC14
![Page 15: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/15.jpg)
LocalizationNumber Systems
![Page 16: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/16.jpg)
![Page 17: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/17.jpg)
![Page 18: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/18.jpg)
![Page 19: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/19.jpg)
![Page 20: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/20.jpg)
LocalizationKeyboards
Indic Keyboards
• Hindi (Latin),a.k.a. “Hinglish”
• Hindi (Transliteration)• Punjabi• Telugu• Gujarati
Predictive Typing for
• Korean• Mexican Spanish• Russian• Turkish
![Page 21: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/21.jpg)
LocalizationKeyboards
Indic Keyboards
• Hindi (Latin),a.k.a. “Hinglish”
• Hindi (Transliteration)• Punjabi• Telugu• Gujarati
Predictive Typing for
• Korean• Mexican Spanish• Russian• Turkish
![Page 22: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/22.jpg)
LocalizationKeyboards
Indic Keyboards
• Hindi (Latin),a.k.a. “Hinglish”
• Hindi (Transliteration)• Punjabi• Telugu• Gujarati
Predictive Typing for
• Korean• Mexican Spanish• Russian• Turkish
![Page 23: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/23.jpg)
LocalizationString Translation
![Page 24: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/24.jpg)
LocalizationString Translation
/* Wristwatch */ "watch" = "Uhr";
de.lproj/Localizable.strings:
![Page 25: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/25.jpg)
LocalizationString Translation
/* Wristwatch */ "watch" = "Uhr";
de.lproj/Localizable.strings:
Stored in lproj subdirectories of your bundle:./Contents/Resources/
en.lproj/Localizable.strings
de.lproj/
Localizable.strings
Localizing With Xcode 6 WWDC14
![Page 26: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/26.jpg)
LocalizationString Translation
![Page 27: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/27.jpg)
LocalizationString Translation
To get simple localized string:func NSLocalizedString( key : String tableName: String? = "Localizable", bundle: NSBundle = NSBundle.mainBundle(), value: String = "", comment: String) -> String
![Page 28: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/28.jpg)
LocalizationString Translation
To get simple localized string:func NSLocalizedString( key : String tableName: String? = "Localizable", bundle: NSBundle = NSBundle.mainBundle(), value: String = "", comment: String) -> String
To get localized formatted string:String.localizedStringWithFormat(format: NSString, args: CVarArgType…)
![Page 29: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/29.jpg)
LocalizationString Translation
To get simple localized string:func NSLocalizedString( key : String tableName: String? = "Localizable", bundle: NSBundle = NSBundle.mainBundle(), value: String = "", comment: String) -> String
Together:String.localizedStringWithFormat(NSLocalizedString("%@ %d", comment:…), …)
To get localized formatted string:String.localizedStringWithFormat(format: NSString, args: CVarArgType…)
![Page 30: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/30.jpg)
LocalizationString Translation
![Page 31: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/31.jpg)
LocalizationString Translation
var str = String.localizedStringWithFormat( NSLocalizedString("Location: %@", comment: "User’s Location"),
location)
![Page 32: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/32.jpg)
LocalizationString Translation
var str = String.localizedStringWithFormat( NSLocalizedString("Location: %@", comment: "User’s Location"),
location)
en.lproj/Localizable.strings: "Location: %@" = "Location: %@";
ja.lproj/Localizable.strings: "Location: %@" = "場所:%@";
![Page 33: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/33.jpg)
LocalizationString Translation
Location: San FranciscoEnglish
var str = String.localizedStringWithFormat( NSLocalizedString("Location: %@", comment: "User’s Location"),
location)
en.lproj/Localizable.strings: "Location: %@" = "Location: %@";
ja.lproj/Localizable.strings: "Location: %@" = "場所:%@";
![Page 34: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/34.jpg)
LocalizationString Translation
Location: San FranciscoEnglish
場所:サンフランシスコJapanese
var str = String.localizedStringWithFormat( NSLocalizedString("Location: %@", comment: "User’s Location"),
location)
en.lproj/Localizable.strings: "Location: %@" = "Location: %@";
ja.lproj/Localizable.strings: "Location: %@" = "場所:%@";
![Page 35: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/35.jpg)
LocalizationReordering
![Page 36: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/36.jpg)
LocalizationReordering
let str = String.localizedStringWithFormat( NSLocalizedString("copy %@’s %@", comment: "copying item from user"),
"hairForce1", "photos")
![Page 37: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/37.jpg)
LocalizationReordering
let str = String.localizedStringWithFormat( NSLocalizedString("copy %@’s %@", comment: "copying item from user"),
"hairForce1", "photos")en.lproj
"Copy %@’s %@" = "Copying %@’s %@"; de.lproj
"Copy %@’s %@" = "%@ von %@ kopieren";
![Page 38: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/38.jpg)
LocalizationReordering
let str = String.localizedStringWithFormat( NSLocalizedString("copy %@’s %@", comment: "copying item from user"),
"hairForce1", "photos")en.lproj
"Copy %@’s %@" = "Copying %@’s %@"; de.lproj
"Copy %@’s %@" = "%@ von %@ kopieren";
English Copying hairForce1’s photos
![Page 39: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/39.jpg)
LocalizationReordering
German hairForce1 von photos kopieren (Copy HairForce1 from photos)
let str = String.localizedStringWithFormat( NSLocalizedString("copy %@’s %@", comment: "copying item from user"),
"hairForce1", "photos")en.lproj
"Copy %@’s %@" = "Copying %@’s %@"; de.lproj
"Copy %@’s %@" = "%@ von %@ kopieren";
English Copying hairForce1’s photos
![Page 40: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/40.jpg)
LocalizationReordering
German photos von hairForce1 kopieren
en.lproj "Copy %@’s %@" = "Copying %@’s %@";
de.lproj "Copy %@’s %@" = "%$2@ von %$1@ kopieren";
let str = String.localizedStringWithFormat( NSLocalizedString("copy %@’s %@", comment: "copying item from user"),
"hairForce1", "photos")
English Copying hairForce1’s photos
![Page 41: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/41.jpg)
LocalizationDon’t access the directories yourself
![Page 42: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/42.jpg)
LocalizationDon’t access the directories yourself
let lang = NSLocale.preferredLanguages().firstObject! let lprojPath = lang.stringByAppendingPathExtension("lproj") let filePath = NSBundle.mainBundle().pathForResource("stopSign", ofType: "png", inDirectory: lprojPath)
![Page 43: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/43.jpg)
LocalizationDon’t access the directories yourself
let lang = NSLocale.preferredLanguages().firstObject! let lprojPath = lang.stringByAppendingPathExtension("lproj") let filePath = NSBundle.mainBundle().pathForResource("stopSign", ofType: "png", inDirectory: lprojPath)
Bundle only has es.lproj
![Page 44: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/44.jpg)
LocalizationDon’t access the directories yourself
let lang = NSLocale.preferredLanguages().firstObject! let lprojPath = lang.stringByAppendingPathExtension("lproj") let filePath = NSBundle.mainBundle().pathForResource("stopSign", ofType: "png", inDirectory: lprojPath)
Bundle only has es.lproj
Nothing Here!es-MX (Mexican Spanish)
![Page 45: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/45.jpg)
LocalizationDon’t access the directories yourself
NSBundle.mainBundle().imageForResource("stopSign") NSBundle.mainBundle().pathForSoundResource("greeting") NSBundle.mainBundle().URLForResource("help", withExtension: "pdf")
es-MX (Mexican Spanish)
Bundle only has es.lproj
![Page 46: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/46.jpg)
LocalizationPluralizationif numDays == 1 { daysString = String.localizedStringWithFormat( NSLocalizedString("%d day remaining", comment: "Single day remaining" numDays) } else { daysString = String.localizedStringWithFormat( NSLocalizedString("%d days remaining", comment: "number of days remaining"), numDays) }
![Page 47: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/47.jpg)
LocalizationPluralizationif numDays == 1 { daysString = String.localizedStringWithFormat( NSLocalizedString("%d day remaining", comment: "Single day remaining" numDays) } else { daysString = String.localizedStringWithFormat( NSLocalizedString("%d days remaining", comment: "number of days remaining"), numDays) }
1 day remaining 5 days remaining
English
![Page 48: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/48.jpg)
LocalizationPluralizationif numDays == 1 { daysString = String.localizedStringWithFormat( NSLocalizedString("%d day remaining", comment: "Single day remaining" numDays) } else { daysString = String.localizedStringWithFormat( NSLocalizedString("%d days remaining", comment: "number of days remaining"), numDays) }
остается 1 день остается 5 дня
Russian1 day remaining 5 days remaining
English
![Page 49: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/49.jpg)
Localizationstringsdict
![Page 50: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/50.jpg)
Localizationstringsdict
<key>%d day(s) remaining</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@days@</string> <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d day remaining</string> <key>other</key> <string>%d days remaining</string> </dict> </dict>
![Page 51: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/51.jpg)
Localizationstringsdict <key>%d day(s) remaining</key>
<dict> <key>NSStringLocalizedFormatKey</key> <string>%#@days@</string> <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>остается %d день</string> <key>few</key> <string>остается %d дня</string>
<key>many</key> <string>остается %d дней</string>
<key>other</key> <string>остается %d дня</string> </dict> </dict>
<key>%d day(s) remaining</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@days@</string> <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d day remaining</string> <key>other</key> <string>%d days remaining</string> </dict> </dict>
![Page 52: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/52.jpg)
Localizationstringsdict <key>%d day(s) remaining</key>
<dict> <key>NSStringLocalizedFormatKey</key> <string>%#@days@</string> <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>остается %d день</string> <key>few</key> <string>остается %d дня</string>
<key>many</key> <string>остается %d дней</string>
<key>other</key> <string>остается %d дня</string> </dict> </dict>
<key>%d day(s) remaining</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@days@</string> <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d day remaining</string> <key>other</key> <string>%d days remaining</string> </dict> </dict>
Internationalization and Localization Guide Appendix C Stringsdict File Format
![Page 53: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/53.jpg)
LocalizationPluralization
![Page 54: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/54.jpg)
LocalizationPluralization
for x in [1,2,5] { let formatted = String.localizedStringWithFormat(
NSLocalizedString("%d day(s) remaining", comment: "number of days remaining until watch release"), x) }
![Page 55: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/55.jpg)
LocalizationPluralization
for x in [1,2,5] { let formatted = String.localizedStringWithFormat(
NSLocalizedString("%d day(s) remaining", comment: "number of days remaining until watch release"), x) }
1 day remaining 2 days remaining 5 days remaining
English
![Page 56: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/56.jpg)
LocalizationPluralization
for x in [1,2,5] { let formatted = String.localizedStringWithFormat(
NSLocalizedString("%d day(s) remaining", comment: "number of days remaining until watch release"), x) }
остается 1 день остается 2 дня остается 5 дней
Russian1 day remaining 2 days remaining 5 days remaining
English
![Page 57: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/57.jpg)
LocalizationVariableWidth
![Page 58: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/58.jpg)
LocalizationVariableWidth
![Page 59: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/59.jpg)
![Page 60: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/60.jpg)
![Page 61: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/61.jpg)
![Page 62: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/62.jpg)
Localization
<key>Welcome</key> <dict> <key>NSStringVariableWidthRuleType</key> <dict> <key>20</key> <string>Hi</string> <key>25</key> <string>Welcome</string> <key>50</key> <string>Welcome to the store!</string> </dict> </dict>
VariableWidth
![Page 63: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/63.jpg)
LocalizationVariableWidth
![Page 64: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/64.jpg)
LocalizationVariableWidth
self.label = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 65: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/65.jpg)
LocalizationVariableWidth
self.label = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 66: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/66.jpg)
LocalizationVariableWidth
self.label = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 67: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/67.jpg)
LocalizationVariableWidth
self.label = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 68: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/68.jpg)
LocalizationVariableWidth
![Page 69: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/69.jpg)
LocalizationVariableWidth
let widthFormattedString = formatted.variantFittingPresentationWidth(20)
let formatted = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 70: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/70.jpg)
LocalizationVariableWidth
Hi
let widthFormattedString = formatted.variantFittingPresentationWidth(20)
let formatted = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 71: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/71.jpg)
LocalizationVariableWidth
Welcome
let widthFormattedString = formatted.variantFittingPresentationWidth(25)
let formatted = NSLocalizedString("Welcome", comment: "Welcomes the user")
![Page 72: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/72.jpg)
LocalizationVariableWidth
Welcome to the store!
let widthFormattedString = formatted.variantFittingPresentationWidth(50)
let formatted = NSLocalizedString("Welcome", comment: "Welcomes the user");
![Page 73: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/73.jpg)
LocalizationFormattingHandling TextLayout
![Page 74: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/74.jpg)
LocalizationFormattingHandling TextLayout
![Page 75: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/75.jpg)
FormattingNumbers, Dates, Times, and Names
![Page 76: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/76.jpg)
FormattingNumbers
![Page 77: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/77.jpg)
FormattingNumbers
let pi = String(format: "%.3f", M_PI)
![Page 78: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/78.jpg)
FormattingNumbers
let pi = String(format: "%.3f", M_PI)
English
3.142
![Page 79: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/79.jpg)
FormattingNumbers
German
3.142
let pi = String(format: "%.3f", M_PI)
English
3.142
![Page 80: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/80.jpg)
FormattingNumbers
German
3.142
let pi = String(format: "%.3f", M_PI)
"Three Thousand One Hundred Forty Two"
English
3.142
![Page 81: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/81.jpg)
FormattingNumbers
let pi = String.localizedStringWithFormat("%.3f", M_PI)
3.142
English German
3,142
![Page 82: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/82.jpg)
FormattingNumbers
let pi = String.localizedStringWithFormat("%.3f", M_PI)
3.142
English German
3,142
![Page 83: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/83.jpg)
FormattingNumbers
Input Style Output
-42 .CurrencyStyle -$42.00
-42 .CurrencyISOCodeStyle -USD42.00
-42 .CurrencyPluralStyle -42.00 US dollars
-42 .CurrencyAccountingStyle ($42.00)
42 .OrdinalStyle 42nd
formatter.stringFromNumber(x)!
![Page 84: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/84.jpg)
FormattingDates
![Page 85: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/85.jpg)
FormattingDates
let date = String(format: "%d/%d/%d, %d:%d%d", 6, 12, 2015, 9, 0, 0)
![Page 86: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/86.jpg)
FormattingDates
let date = String(format: "%d/%d/%d, %d:%d%d", 6, 12, 2015, 9, 0, 0)
English (US)
6/12/2015, 9:00
![Page 87: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/87.jpg)
FormattingDates
let date = String(format: "%d/%d/%d, %d:%d%d", 6, 12, 2015, 9, 0, 0)
English (US)
6/12/2015, 9:00
Italian (Italy)
6/12/2015, 9:00
![Page 88: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/88.jpg)
FormattingDates
let df = NSDateFormatter() df.dateFormat = "MM/dd/yyyy, h:mm a" print(df.stringFromDate(NSDate()))
English (US)
06/12/2015, 9:00 AM
Italian (Italy)
06/12/2015, 9:00 AM
![Page 89: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/89.jpg)
FormattingDates
English (US)
06/12/2015, 9:00 AM
Italian (Italy)
12/06/2015, 09:00
let df = NSDateFormatter() df.dateStyle = .ShortStyle df.timeStyle = .ShortStyle print(df.stringFromDate(NSDate()))
![Page 90: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/90.jpg)
FormattingDates
English (US)
06/12/2015, 9:00 AM
Italian (Italy)
12/06/2015, 09:00
let df = NSDateFormatter() df.dateStyle = .ShortStyle df.timeStyle = .ShortStyle print(df.stringFromDate(NSDate()))
![Page 91: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/91.jpg)
FormattingDates
English (US)
06/12/2015, 9:00:00 AM
Italian (Italy)
12/06/2015, 09:00:00
let df = NSDateFormatter() df.setLocalizedDateFormatFromTemplate("yyyyMMddjjmmss") print(df.stringFromDate(NSDate()))
![Page 92: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/92.jpg)
FormattingDates
English (US)
06/12/2015, 9:00:00 AM
Italian (Italy)
12/06/2015, 09:00:00
let df = NSDateFormatter() df.setLocalizedDateFormatFromTemplate("yyyyMMddjjmmss") print(df.stringFromDate(NSDate()))
![Page 93: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/93.jpg)
FormattingUnits
![Page 94: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/94.jpg)
FormattingUnits
let weight = String.localizedStringWithFormat( NSLocalizedString("%d pounds", comment: "Weight"), 6)
![Page 95: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/95.jpg)
FormattingUnits
let weight = String.localizedStringWithFormat( NSLocalizedString("%d pounds", comment: "Weight"), 6)
it.lproj/Localizable.strings"%d pounds" = "%d chilogrammi"
![Page 96: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/96.jpg)
FormattingUnits
let weight = String.localizedStringWithFormat( NSLocalizedString("%d pounds", comment: "Weight"), 6)
it.lproj/Localizable.strings"%d pounds" = "%d chilogrammi"
English (US)
6 pounds
![Page 97: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/97.jpg)
FormattingUnits
let weight = String.localizedStringWithFormat( NSLocalizedString("%d pounds", comment: "Weight"), 6)
it.lproj/Localizable.strings"%d pounds" = "%d chilogrammi"
Italian (Italy)
6 chilogrammi
English (US)
6 pounds
![Page 98: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/98.jpg)
FormattingUnits
let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)
Italian (Italy)
20 chilogrammi
English (US)
44.092 pounds
![Page 99: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/99.jpg)
FormattingUnits
let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)
Italian (Italy)
20 chilogrammi
English (US)
44.092 pounds
![Page 100: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/100.jpg)
FormattingNames
![Page 101: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/101.jpg)
FormattingNames
Grace
![Page 102: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/102.jpg)
FormattingNames
Grace Murray
![Page 103: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/103.jpg)
FormattingNames
Grace Murray Hopper
![Page 104: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/104.jpg)
FormattingNames
Grace Murray Hopper
⺩王
![Page 105: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/105.jpg)
FormattingNames
Grace Murray Hopper
⺩王冬
![Page 106: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/106.jpg)
FormattingNames
Grace Murray Hopper
龄⺩王冬
![Page 107: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/107.jpg)
FormattingNames
Grace Murray Hopper
first middle last
龄⺩王冬
![Page 108: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/108.jpg)
FormattingNames
龄⺩王 冬
first middle last
Grace Murray Hopper
![Page 109: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/109.jpg)
FormattingNames
龄⺩王 冬
first middle last
Grace Murray Hopper
![Page 110: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/110.jpg)
FormattingNames
龄⺩王 冬
"last"
first middle last
Grace Murray Hopper
![Page 111: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/111.jpg)
FormattingNames
龄⺩王 冬
"last"
first middle last
Grace Murray Hopper
![Page 112: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/112.jpg)
FormattingNames
龄⺩王 冬
"last" "middle"
first middle last
Grace Murray Hopper
![Page 113: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/113.jpg)
FormattingNames
龄⺩王 冬
"last" "middle"
first middle last
Grace Murray Hopper
![Page 114: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/114.jpg)
FormattingNames
龄⺩王 冬
"last" "middle" "first"
first middle last
Grace Murray Hopper
![Page 115: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/115.jpg)
FormattingNames
![Page 116: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/116.jpg)
FormattingNames
NSPersonNameComponents
![Page 117: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/117.jpg)
FormattingNames
NSPersonNameComponentsFormatter
NSPersonNameComponents
![Page 118: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/118.jpg)
FormattingNames
![Page 119: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/119.jpg)
FormattingNames
English:let components = NSPersonNameComponents() components.givenName = "Grace" components.middleName = "Murray" components.familyName = "Hopper"
![Page 120: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/120.jpg)
FormattingNames
let components = NSPersonNameComponents() components.givenName = "Фёдор" // Fyodor components.middleName = "Михайлович" // Mikhailovich components.familyName = "Достоевский" // Dostoyevsky
Russian:
English:let components = NSPersonNameComponents() components.givenName = "Grace" components.middleName = "Murray" components.familyName = "Hopper"
![Page 121: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/121.jpg)
FormattingNames
![Page 122: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/122.jpg)
let formatter = NSPersonNameComponentsFormatter() formatter.style = .Short formatter.stringFromPersonNameComponents(components)
FormattingNames
![Page 123: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/123.jpg)
English Name Russian Name
.Default Grace Hopper Фёдор Достоевский
.Long Grace Murray Hopper Фёдор Михайлович Достоевский
.Medium Grace Hopper Фёдор Достоевский
.Short Grace Ф Достоевский
.Abbreviated GMH Ф Достоевский
FormattingNames
![Page 124: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/124.jpg)
LocalizationFormattingHandling TextLayout
![Page 125: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/125.jpg)
LocalizationFormattingHandling TextLayout
![Page 126: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/126.jpg)
Handling TextCharacters, Case Changes, Searching, and Transforms
![Page 127: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/127.jpg)
Handling TextWhat is a character?
How many characters is ! ?
![Page 128: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/128.jpg)
Handling TextWhat is a character?
How many characters is ! ?
![Page 129: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/129.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
![Page 130: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/130.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) +
![Page 131: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/131.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +
![Page 132: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/132.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +
![Page 133: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/133.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
![Page 134: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/134.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
![Page 135: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/135.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
U+200D (ZERO WIDTH JOINER) +
![Page 136: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/136.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
U+200D (ZERO WIDTH JOINER) +
U+1F468 (MAN) 👨
![Page 137: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/137.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
U+200D (ZERO WIDTH JOINER) +
U+1F468 (MAN) 👨
![Page 138: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/138.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
U+200D (ZERO WIDTH JOINER) +
U+1F468 (MAN) 👨8?
![Page 139: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/139.jpg)
Handling TextWhat is a character?
How many characters is ! ?U+1F468 (MAN) 👨 +
U+200D (ZERO WIDTH JOINER) + U+2764 (HEAVY BLACK HEART) ❤ +U+FE0F (VARIATION SELECTOR-16) +U+200D (ZERO WIDTH JOINER) +
U+1F48B (KISS MARK)💋 +
U+200D (ZERO WIDTH JOINER) +
U+1F468 (MAN) 👨8?
![Page 140: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/140.jpg)
Handling TextEnumeration: Incorrect
![Page 141: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/141.jpg)
Handling TextEnumeration: Incorrect
NSString *str = @"test !"; for(int i = 0; i < str.length; i++) {
NSLog(@"%C",[str characterAtIndex:i]); }
![Page 142: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/142.jpg)
Handling TextEnumeration: Incorrect
NSString *str = @"test !"; for(int i = 0; i < str.length; i++) {
NSLog(@"%C",[str characterAtIndex:i]); }
t e s t ? ? ? ? ❤ ? ? ?
![Page 143: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/143.jpg)
Handling TextEnumeration: Swift
test !
let str = "test !" str.enumerateSubstringsInRange(str.startIndex ..< str.endIndex, options: .ByComposedCharacterSequences) { (substring, substringRange, enclosingRange, stop) -> () in print("\(substring)") }
![Page 144: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/144.jpg)
Handling TextEnumeration: Swift
test !
let str = "test !" str.enumerateSubstringsInRange(str.startIndex ..< str.endIndex, options: .ByComposedCharacterSequences) { (substring, substringRange, enclosingRange, stop) -> () in print("\(substring)") }
![Page 145: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/145.jpg)
Handling TextCase changes
![Page 146: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/146.jpg)
Handling TextCase changes
let str = "istanbul" print(str.capitalizedString)
![Page 147: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/147.jpg)
Handling TextCase changes
let str = "istanbul" print(str.capitalizedString)
Istanbul
![Page 148: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/148.jpg)
Handling TextCase changes
let str = "istanbul" print(str.localizedCapitalizedString)
İstanbul
![Page 149: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/149.jpg)
Handling TextCase changes
let str = "istanbul" print(str.localizedCapitalizedString)
İstanbul
![Page 150: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/150.jpg)
Handling TextCase changes
![Page 151: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/151.jpg)
Handling TextCase changes
let str = "istanbul" print(str.localizedUppercaseString) print(str.localizedLowercaseString) print(str.localizedCapitalizedString)
![Page 152: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/152.jpg)
Handling TextCase changes
let str = "istanbul" print(str.localizedUppercaseString) print(str.localizedLowercaseString) print(str.localizedCapitalizedString)
İSTANBUListanbulİstanbul
![Page 153: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/153.jpg)
Handling TextSearching
![Page 154: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/154.jpg)
Handling TextSearching
let str = "Über" print(str.rangeOfString("uber"))
![Page 155: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/155.jpg)
Handling TextSearching
let str = "Über" print(str.rangeOfString("uber"))
nil
![Page 156: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/156.jpg)
Handling TextSearching
true0..<4
let str = "Über" print(str.localizedStandardRangeOfString("uber")) print(str.localizedStandardContainsString("uber"))
![Page 157: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/157.jpg)
Handling TextSearching
true0..<4
let str = "Über" print(str.localizedStandardRangeOfString("uber")) print(str.localizedStandardContainsString("uber"))
![Page 158: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/158.jpg)
Handling TextString APIs: Transforms
Transforms:• Uppercase/lowercase• Unicode normalization • Script to Script conversion / transliteration
Formerly only CF-level
![Page 159: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/159.jpg)
Handling TextString APIs: Transliteration
![Page 160: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/160.jpg)
Handling TextString APIs: Transliteration
let transliterated = "👍".stringByApplyingTransform(NSStringTransformToXMLHex, reverse: false) print(transliterated)
![Page 161: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/161.jpg)
Handling TextString APIs: Transliteration
let transliterated = "👍".stringByApplyingTransform(NSStringTransformToXMLHex, reverse: false) print(transliterated)
👍
![Page 162: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/162.jpg)
LocalizationFormattingHandling TextLayout
![Page 163: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/163.jpg)
LocalizationFormattingHandling TextLayout
![Page 164: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/164.jpg)
LayoutDisplaying International UI
![Page 165: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/165.jpg)
LayoutAuto Layout
![Page 166: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/166.jpg)
LayoutAuto Layout
![Page 167: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/167.jpg)
LayoutAuto Layout
![Page 168: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/168.jpg)
LayoutAuto Layout
![Page 169: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/169.jpg)
LayoutAuto Layout
ειδc
![Page 170: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/170.jpg)
LayoutAuto Layout
![Page 171: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/171.jpg)
LayoutAuto Layout
ειδοποιήσεων
![Page 172: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/172.jpg)
LayoutAuto Layout
Mysteries of Auto Layout, Part 1 Presidio Thursday 11:00 AM
Mysteries of Auto Layout, Part 2 Presidio Thursday 1:30 PM
![Page 173: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/173.jpg)
LayoutDynamic Type
![Page 174: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/174.jpg)
![Page 175: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/175.jpg)
![Page 176: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/176.jpg)
LayoutRight-to-Left
![Page 177: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/177.jpg)
![Page 178: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/178.jpg)
LayoutRight-to-Left
New UIKit Support for International User Interfaces Nob Hill Thursday 2:30 PM
![Page 179: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/179.jpg)
Summary
Pay attention to • Localization• Formatting• Handling Text• Layout
Use “localized” variants and standard viewsInternationalization opens the world to your application
![Page 180: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/180.jpg)
More Information
DocumentationInternationalization and Localization Guidehttp://developer.apple.com/libraryTechnical SupportApple Developer Forumshttp://developer.apple.com/forumsGeneral InquiriesPaul Marcos, App Frameworks [email protected]
![Page 181: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/181.jpg)
Related Sessions and Lab
What’s New in Cocoa Presidio Tuesday 1:30 PM
New UIKit Support for International User Interfaces Nob Hill Thursday 2:30 PM
Mysteries of Auto Layout, Part 1 Presidio Thursday 11:00 AM
Mysteries of Auto Layout, Part 2 Presidio Thursday 1:30 PM
Internationalization Lab Frameworks Lab A Friday 11:00 AM
![Page 182: What’s New in Internationalization...let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)](https://reader035.fdocuments.in/reader035/viewer/2022071420/61197fbefb93a82f493670ed/html5/thumbnails/182.jpg)