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

Localization.pdf

52d6b8fd288036707ddd50eb6f595cb7?s=47 Aydar
December 14, 2017

 Localization.pdf

Presentation for the Munich iOS Developers Meetup

52d6b8fd288036707ddd50eb6f595cb7?s=128

Aydar

December 14, 2017
Tweet

Transcript

  1. Improve your app localization with .stringsdict Aydar Mukhametzyanov, Freeletics

  2. Agenda 1.The story 2.Handling plurals with .stringsdict 3.Adaptive strings

  3. Who knows what .stringsdict is?

  4. 1.The story 2.Handling plurals with .stringsdict 3.Adaptive strings

  5. !"#$ %&'( The story

  6. The story !"#$ %&'( ) * +

  7. The story Category Count ! * One 1 1 month

    1 miesiąc Few 2-4, 22-24, 32-34,… 2 months 2 miesiące Many 5-19, 100,… 5 months 5 miesięcy Other 0.0-1.5, 10.0 1.5 months 1.5 miesiąca
  8. The story if count == 1 { // one }

    else { // many } !
  9. The story if count >= 5 && count <= 19

    { // many } else if lastDigit == 1 { // one } else if lastDigit > 1 && lastDigit < 5 { // few } else { // many } )
  10. 1.The story 2.Handling plurals with .stringsdict 3.Adaptive strings

  11. Handling plurals { login_button_title: Login, … }

  12. Handling plurals { login_button_title: Login, … days_one: %d day, days_many:

    %d days, … }
  13. Handling plurals { login_button_title: Login, … days_one: %d day, days_many:

    %d days, … } if count == 1 { // Use days_one } else { // Use days_many }
  14. Handling plurals { login_button_title: Login, … days: { one: %d

    day, many: %d days } … }
  15. Handling plurals { login_button_title: Login, … days: { one: %d

    day, many: %d days } … } String.localizedString(key: “days", count: count)
  16. Handling plurals

  17. Handling plurals

  18. Handling plurals Localizable.sctringsdict Key Format Localization Plural cases

  19. Handling plurals

  20. Handling plurals Plural cases: zero, one, two, few, many, other

    http://www.unicode.org/cldr/charts/29/supplemental/language_plural_rules.html
  21. Handling plurals

  22. How to use? Handling plurals

  23. Handling plurals let format = NSLocalizedString("days", comment: "") let string

    = String.localizedStringWithFormat(format, 12) How to use?
  24. Handling plurals let format = NSLocalizedString("days", comment: "") let string

    = String.localizedStringWithFormat(format, 12) New localization doesn’t bring code changes
  25. Handling plurals • Localizable.stringsdict • Specific format for plural rules

    • Available since iOS 7
  26. 1.The story 2.Handling plurals with .stringsdict 3.Adaptive strings

  27. Adaptive strings

  28. Adaptive strings Key “M width available on the screen” (WWDC

    2015, Session 227, 15:06) Localization options
  29. Adaptive strings “M width available on the screen” (WWDC 2015,

    Session 227, 15:06)
  30. How to use? Adaptive strings

  31. Adaptive strings textLabel.text = NSLocalizedString("gdp", comment: "") How to use?

  32. Adaptive strings textLabel.text = NSLocalizedString("gdp", comment: "") New localization doesn’t

    bring code changes
  33. Adaptive strings • Specific format for adaptive strings • Easy

    to start using • Available since iOS 9
  34. Resources • WWDC 2013 Session 219: Making Your App World-Ready

    • WWDC 2015 Session 227: What’s new in Internationalization • WWDC 2017 Session 401: Localizing with Xcode 9 • Demo app: https://github.com/aydarin/localizationdemo Contacts aydar.mukh aydar.mukh@gmail.com aydarin
  35. Demo