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

アプリが国際化する時

punchdrunker
September 15, 2017

 アプリが国際化する時

punchdrunker

September 15, 2017
Tweet

More Decks by punchdrunker

Other Decks in Technology

Transcript

  1. ෳ਺ܗ Android͸ඪ४ͰPluralରԠ͕؆୯ // plurals.xml <plurals name=“photo_count"> <item quantity=“one”>%1$d photo</item> <item

    quantity=“other”>%1$d photos</item> </plurals> // usage getResources() .getQuantityString(R.plurals.photo, quantity, count) // ஫ҙ: quantity͕0ͷ࣌͸”other”͕ਖ਼͍͠(15෼ϋϚͬͨ) MULTILINGUALIZATION 3 ଟݴޠԽ
  2. ෳ਺ܗ Xcode͸ඪ४ͰPluralରԠ͍ͯ͠Δ͕ɺdictionaryͳͷͰ΍΍μϧ͍ // Localizable.stringsdict <dict> <key>number_of_days</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@value@</string> <key>value</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> </dict> MULTILINGUALIZATION 3 ଟݴޠԽ
  3. ෳ਺ܗ AndroidͬΆ͍ఆٛͰ࢖͑ΔΑ͏ʹͪΐͬͱ࣮ͨ͠૷ // Localizable.strings “photo.one”="%d photo”; “photo.other”="%d photos"; // usage

    func pluralString(key: String, quantity: Int) -> String { let suffix: String if quantity == 1 { suffix = ".one" } else { suffix = ".other" } return NSLocalizedString(key + suffix, comment: "") } // ࣮ࡍʹ͸ࣗલͷFormatter͕͋ΔͷͰɺ // ͍ͦͭʹ౉͢จࣈྻͱͯ͠ར༻ pluralString(key: “photo”, quantity: quantity) MULTILINGUALIZATION 3 ଟݴޠԽ
  4. ςετ RobolectricͷΞϊςʔγϣϯͰϦιʔεͷछྨΛࢦఆͰ͖Δͷ Ͱɺจࣈྻͷςετ͸ָͩͬͨ @Test @Config(qualifiers = “en-port”) // ӳޠ&ॎը໘ public

    void testFormatter() { …. assertEquals(“Newborn”, formatter.getAge(context, 0)) } ͋͘·ͰϦιʔεͷम০ࢠΛݻఆ͢ΔͨΊͷ΋ͰɺLocaleͷ஋͕ ϞοΫ͞ΕΔΘ͚Ͱ͸ͳ͍ɻ LocaleΛऔಘ͢ΔΑ͏ͳॲཧͷ৔߹͸ผ్mock͢Δඞཁ͕͋ Δɻ MULTILINGUALIZATION 3 ଟݴޠԽ
  5. ετΞͷݴޠ MISC 5 ͦͷଞ App Store΋Google Play΋ɺӳޠ൛ͷϦϦʔεΛҰ౓ऴ͑ ͔ͯΒͰͳ͍ͱɺprimary language(σϑΥϧτݴޠ)Λઃఆ Ͱ͖ͳ͔ͬͨɻ

    ϝδϟʔΞοϓσʔτ࣌ʹσϑΥϧτ͸ӳޠͰύʔϯοΈͨ ͍ͳ͜ͱΛ΍Γ͔ͨͬͨΒɺखલͷόʔδϣϯͰӳޠͷܝࡌ ৘ใΛೖΕͯϦϦʔε͓ͯ͘͠ඞཁ͕͋Δɻ