Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ios-internationalization

 ios-internationalization

horimislime

August 11, 2015
Tweet

More Decks by horimislime

Other Decks in Programming

Transcript

  1. class Customer { var firstName: String! var lastName: String! }

    String.localizedStringWithFormat( "%@ %@༷", customer.lastName, customer.firstName )
  2. class Customer { var firstName: String! var lastName: String! }

    String.localizedStringWithFormat( "%@ %@༷", customer.lastName, customer.firstName )
  3. NSPersonNameComponents class Customer { var name: NSPersonNameComponents! ... } let

    formatter = NSPersonNameComponentsFormatter() formatter.style = .Medium formatter.stringFromPersonNameComponents(customer.name) // -> "Soichiro Horimi"
  4. NSPersonNameComponents & Formatter let customer = Customer() customer.name.familyName = "Horimi"

    customer.name.givenName = "Soichiro" customer.name.nameSuffix = "Mr." let formatter = NSPersonNameComponentsFormatter() formatter.style = .Long formatter.stringFromPersonNameComponents(customer.name) // -> "Soichiro Horimi Mr."
  5. stringsdict String.localizedStringWithFormat( NSLocalizedString("%d໊༷", comment: "͝༧໿ਓ਺"), reservation.guests.count) <key>%d໊༷</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@Guests@</string>

    <key>days</key> <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>%d Guest</string> <key>other</key> <string>%d Guests</string> </dict> </dict> ୯਺ ෳ਺
  6. NSDateIntervalFormatter • iOS >= 8.0 label.text = String.localizedStringWithFormat( "%@ -

    %@", begin, end) let formatter = NSDateIntervalFormatter() label.text = formatter.stringFromDate(begin, toDate: end)