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. ӳޠ൛ϦϦʔεલʹ
    ஌͓͖͍ͬͯͨ͜ͱ!
    Potatotips 20
    @horimislime

    View full-size slide

  2. @horimislime
    גࣜձࣾτϨλ

    View full-size slide

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

    View full-size slide

  4. NSLocalizedString

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  7. NSPersonNameComponents
    class Customer {
    var name: NSPersonNameComponents!
    ...
    }
    let formatter = NSPersonNameComponentsFormatter()
    formatter.style = .Medium
    formatter.stringFromPersonNameComponents(customer.name)
    // -> "Soichiro Horimi"

    View full-size slide

  8. 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."

    View full-size slide

  9. NSPersonNameComponents
    & Formatter
    • @available(iOS 9.0, *)
    • ಠࣗͷComponentsͱFormatterΛ༻ҙ
    • কདྷతʹࠩ͠ସ͍͑ͨɾɾ

    View full-size slide


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

    View full-size slide


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

    View full-size slide

  12. stringsdict
    String.localizedStringWithFormat(
    NSLocalizedString("%d໊༷", comment: "͝༧໿ਓ਺"),
    reservation.guests.count)
    %d໊༷

    NSStringLocalizedFormatKey
    %#@Guests@
    days

    NSStringFormatSpecTypeKey
    NSStringPluralRuleType
    NSStringFormatValueTypeKey
    d
    one
    %d Guest
    other
    %d Guests


    ୯਺
    ෳ਺

    View full-size slide

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

    View full-size slide

  14. NSDateIntervalFormatter
    • iOS >= 8.0
    label.text = String.localizedStringWithFormat(
    "%@ - %@",
    begin, end)
    let formatter = NSDateIntervalFormatter()
    label.text = formatter.stringFromDate(begin, toDate: end)

    View full-size slide

  15. NSDateIntervalFormatter stringsdict
    NSPersonNameComponents

    View full-size slide

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

    View full-size slide

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

    - Asset CatalogͷLocalize͑͞Ͱ͖Ε͹ɾɾ

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

  21. ཧ૝
    ະ຋༁text ݁Ռ

    View full-size slide

  22. ݱ࣮
    • ద੾ͳϦιʔε؅ཧͱࣗಈԽ
    • ͦΕͰ΋ɺݴޠ਺͕ଟ͍ͱେม
    • ଞݴޠԽΑΓແݴޠԽ

    - ݴ༿ແ͠ʹ఻ΘΔUI΁

    View full-size slide

  23. ·ͱΊ
    • FormatterΛ͏·͘׆༻͢Δ

    - Localizableʹ٧ΊࠐΈա͗ͳ͍
    • ը૾Ϧιʔε͸ߟ͑΋ͷ
    • ϦϦʔεޙ͸͏·ࣗ͘ಈԽ͍͚ͯ͠Δͱྑ͍
    • ͱ͸͍͑ແݴޠͳUI͕Πνόϯͷཧ૝

    View full-size slide

  24. ͋Γ͕ͱ͏͍͟͝·ͨ͠
    (ΤϯδχΞืूத!)

    View full-size slide