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

ios-internationalization

 ios-internationalization

503b1ca28b167b0d94a5992aad1a57b1?s=128

horimislime

August 11, 2015
Tweet

Transcript

  1. ӳޠ൛ϦϦʔεલʹ ஌͓͖͍ͬͯͨ͜ͱ! Potatotips 20 @horimislime

  2. @horimislime גࣜձࣾτϨλ

  3. None
  4. None
  5. None
  6. ӳޠԽ • ݴޠϦιʔε෼͚ͯΔ͠େৎ෉ͩΖɾɾ • ͳΜͯࣄ͸ͳ͍ • Localizableͷ࢖͍ํΛϛεΔͱେม • ͍͔ͭདྷΔӳޠ൛ʹࠓ͔Βඋ͑Α͏

  7. NSLocalizedString

  8. None
  9. None
  10. class Customer { var firstName: String! var lastName: String! }

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

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

    formatter = NSPersonNameComponentsFormatter() formatter.style = .Medium formatter.stringFromPersonNameComponents(customer.name) // -> "Soichiro Horimi"
  14. None
  15. 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."
  16. NSPersonNameComponents & Formatter • @available(iOS 9.0, *) • ಠࣗͷComponentsͱFormatterΛ༻ҙ •

    কདྷతʹࠩ͠ସ͍͑ͨɾɾ
  17. None
  18. ਺ String.localizedStringWithFormat( NSLocalizedString("%d໊༷", comment: "͝༧໿ਓ਺"), reservation.guests.count) /* ͝༧໿ਓ਺ */ "%d໊༷"

    = "%d Guests";
  19. ਺ String.localizedStringWithFormat( NSLocalizedString("%d໊༷", comment: "͝༧໿ਓ਺"), reservation.guests.count) /* ͝༧໿ਓ਺ */ "%d໊༷"

    = "%d Guests";
  20. 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> ୯਺ ෳ਺
  21. None
  22. NSDateIntervalFormatter • iOS >= 8.0 label.text = String.localizedStringWithFormat( "%@ -

    %@", begin, end)
  23. NSDateIntervalFormatter • iOS >= 8.0 label.text = String.localizedStringWithFormat( "%@ -

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

  25. FormatterΛ࢖͍͜ͳͦ͏ • Localizable.strings͸͋͘·Ͱݴޠ؅ཧ • LocaleʹԠͨ͡୯Ґ΍දهͷ੾Γସ͑͸☓ • ͦͷPlaceholderɺຊ౰ʹඞཁʁ ࢀߟ: NSFormatter Class

    Reference
  26. ը૾Ϧιʔε • Background Imageʹ͸ෆ޲͖ • ΞΠίϯ෇͖UIButtonͰ͸࢖͍ͨ͘ͳΔ͕… • LocaleʹΑͬͯίʔυ্Ͱ෼ذ͕ඞཁ
 - Asset

    CatalogͷLocalize͑͞Ͱ͖Ε͹ɾɾ
  27. ւ֎൛ϦϦʔεɺͦͷઌ • શػೳͷ຋༁͕ऴྃɺΊͰͨ͠ • ͳΜͯ͜ͱ΋ͳ͍ • Ή͠ΖϦϦʔεຖͷ຋༁࡞ۀ͕ॏՙʹ… • ։ൃεϐʔυΛམͱͣ͞ʹ຋༁ΛਐΊ͍ͨ

  28. ຋༁ࢧԉαʔϏε • Crowdin • XLIFFΛॻ͖ग़ͯ͠Ξοϓϩʔυ͢ΔͷΈ • ֎෦຋༁ऀͱͷڠۀ͕ḿΔ

  29. ຋༁ࢧԉαʔϏε • ຋༁ϦιʔεΛUPͯ͠ɺਐḿ͕؅ཧͰ͖Δ • ຋༁࿙ΕΛՄࢹԽͰ͖Δ • API࿈ܞ΋

  30. ཧ૝ ະ຋༁text ݁Ռ

  31. ݱ࣮ • ద੾ͳϦιʔε؅ཧͱࣗಈԽ • ͦΕͰ΋ɺݴޠ਺͕ଟ͍ͱେม • ଞݴޠԽΑΓແݴޠԽ
 - ݴ༿ແ͠ʹ఻ΘΔUI΁

  32. ·ͱΊ • FormatterΛ͏·͘׆༻͢Δ
 - Localizableʹ٧ΊࠐΈա͗ͳ͍ • ը૾Ϧιʔε͸ߟ͑΋ͷ • ϦϦʔεޙ͸͏·ࣗ͘ಈԽ͍͚ͯ͠Δͱྑ͍ •

    ͱ͸͍͑ແݴޠͳUI͕Πνόϯͷཧ૝
  33. ͋Γ͕ͱ͏͍͟͝·ͨ͠ (ΤϯδχΞืूத!)