ӳޠ൛ϦϦʔεલʹ͓͖͍ͬͯͨ͜ͱ!Potatotips 20@horimislime
View Slide
@horimislimeגࣜձࣾτϨλ
ӳޠԽ• ݴޠϦιʔε͚ͯΔ͠େৎͩΖɾɾ• ͳΜͯࣄͳ͍• Localizableͷ͍ํΛϛεΔͱେม• ͍͔ͭདྷΔӳޠ൛ʹࠓ͔Βඋ͑Α͏
NSLocalizedString
class Customer {var firstName: String!var lastName: String!}String.localizedStringWithFormat("%@ %@༷",customer.lastName, customer.firstName)
NSPersonNameComponentsclass Customer {var name: NSPersonNameComponents!...}let formatter = NSPersonNameComponentsFormatter()formatter.style = .Mediumformatter.stringFromPersonNameComponents(customer.name)// -> "Soichiro Horimi"
NSPersonNameComponents& Formatterlet customer = Customer()customer.name.familyName = "Horimi"customer.name.givenName = "Soichiro"customer.name.nameSuffix = "Mr."let formatter = NSPersonNameComponentsFormatter()formatter.style = .Longformatter.stringFromPersonNameComponents(customer.name)// -> "Soichiro Horimi Mr."
NSPersonNameComponents& Formatter• @available(iOS 9.0, *)• ಠࣗͷComponentsͱFormatterΛ༻ҙ• কདྷతʹࠩ͠ସ͍͑ͨɾɾ
String.localizedStringWithFormat(NSLocalizedString("%d໊༷", comment: "͝༧ਓ"),reservation.guests.count)/* ͝༧ਓ */"%d໊༷" = "%d Guests";
stringsdictString.localizedStringWithFormat(NSLocalizedString("%d໊༷", comment: "͝༧ਓ"),reservation.guests.count)%d໊༷NSStringLocalizedFormatKey%#@[email protected]daysNSStringFormatSpecTypeKeyNSStringPluralRuleTypeNSStringFormatValueTypeKeydone%d Guestother%d Guests୯ෳ
NSDateIntervalFormatter• iOS >= 8.0label.text = String.localizedStringWithFormat("%@ - %@",begin, end)
NSDateIntervalFormatter• iOS >= 8.0label.text = String.localizedStringWithFormat("%@ - %@",begin, end)let formatter = NSDateIntervalFormatter()label.text = formatter.stringFromDate(begin, toDate: end)
NSDateIntervalFormatter stringsdictNSPersonNameComponents
FormatterΛ͍͜ͳͦ͏• Localizable.strings͋͘·Ͱݴޠཧ• LocaleʹԠͨ͡୯ҐදهͷΓସ͑☓• ͦͷPlaceholderɺຊʹඞཁʁࢀߟ: NSFormatter Class Reference
ը૾Ϧιʔε• Background Imageʹෆ͖• ΞΠίϯ͖UIButtonͰ͍ͨ͘ͳΔ͕…• LocaleʹΑͬͯίʔυ্Ͱذ͕ඞཁ - Asset CatalogͷLocalize͑͞Ͱ͖Εɾɾ
ւ֎൛ϦϦʔεɺͦͷઌ• શػೳͷ༁͕ऴྃɺΊͰͨ͠• ͳΜͯ͜ͱͳ͍• Ή͠ΖϦϦʔεຖͷ༁࡞ۀ͕ॏՙʹ…• ։ൃεϐʔυΛམͱͣ͞ʹ༁ΛਐΊ͍ͨ
༁ࢧԉαʔϏε• Crowdin• XLIFFΛॻ͖ग़ͯ͠Ξοϓϩʔυ͢ΔͷΈ• ֎෦༁ऀͱͷڠۀ͕ḿΔ
༁ࢧԉαʔϏε• ༁ϦιʔεΛUPͯ͠ɺਐḿ͕ཧͰ͖Δ• ༁࿙ΕΛՄࢹԽͰ͖Δ• API࿈ܞ
ཧະ༁text ݁Ռ
ݱ࣮• దͳϦιʔεཧͱࣗಈԽ• ͦΕͰɺݴޠ͕ଟ͍ͱେม• ଞݴޠԽΑΓແݴޠԽ - ݴ༿ແ͠ʹΘΔUI
·ͱΊ• FormatterΛ͏·͘׆༻͢Δ - Localizableʹ٧ΊࠐΈա͗ͳ͍• ը૾Ϧιʔεߟ͑ͷ• ϦϦʔεޙ͏·ࣗ͘ಈԽ͍͚ͯ͠Δͱྑ͍• ͱ͍͑ແݴޠͳUI͕Πνόϯͷཧ
͋Γ͕ͱ͏͍͟͝·ͨ͠(ΤϯδχΞืूத!)