Slide 1

Slide 1 text

LOCALIZATION IS HARD

Slide 2

Slide 2 text

BEFORE

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

2016

Slide 6

Slide 6 text

INSTANT DISTRIBUTION

Slide 7

Slide 7 text

Unless processing

Slide 8

Slide 8 text

150+ COUNTRIES

Slide 9

Slide 9 text

RESPONSIBILITY + EXPECTATION

Slide 10

Slide 10 text

DOWNLOADS + PROMOTION

Slide 11

Slide 11 text

?

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

NSLOCALIZEDSTRING ALL THE THINGS!!!!

Slide 14

Slide 14 text

let localizedString = NSLocalizedString("dot.swift.localizedString", comment: “NSLocalizedString OMG")

Slide 15

Slide 15 text

NOT ENOUGH

Slide 16

Slide 16 text

EXAMPLES PRACTICAL TIPS

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

Currency

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

let cash = 3.50 let cashString = String(format: "€%.2f", arguments: [cash]) €3.50 3,50 € X

Slide 22

Slide 22 text

NSNumberFormatter

Slide 23

Slide 23 text

let numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = .CurrencyStyle numberFormatter.currencyCode = "EUR" let cashString = numberFormatter.stringFromNumber(3.50) 3,50 €

Slide 24

Slide 24 text

NSNumberFormatter DecimalStyle CurrencyStyle PercentStyle ScientificStyle SpellOutStyle OrdinalStyle CurrencyISOCodeStyle CurrencyPluralStyle CurrencyAccountingStyle Use NSNumberFormatter every time you are including a Double or Float in a string

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Long Words

Slide 28

Slide 28 text

Rindfleischetikettier ungsueberwachungs aufgabenuebertragu ngsgesetz

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Mock up UI by doubling all strings. Auto layout helps.

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Capitalization

Slide 35

Slide 35 text

let turkey = "Türkiye" let TURKEY = turkey.uppercaseString TÜRKIYE TÜRKİYE X

Slide 36

Slide 36 text

.localizedUppercaseString (iOS9+)

Slide 37

Slide 37 text

let turkey = "Türkiye" let TURKEY = turkey.localizedUppercaseString TÜRKİYE

Slide 38

Slide 38 text

.uppercaseStringWith Locale() (iOS6+)

Slide 39

Slide 39 text

When changing string capitalization, always use the localized variation localizedUppercaseString() localizedLowercaseString() localizedCapitalizedString()

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

Plurals

Slide 43

Slide 43 text

if n == 1 { secondString = "\(n) second" } else { secondString = "\(n) seconds" } X

Slide 44

Slide 44 text

ends in 1, excluding 11: 1, 21, 31, 41, 51, 61, 71, 81, 91, 101, 121 … ends in 2-4, excluding 12-14: 2, 3, 4, 22, 23, 24, 32, 33, 34, 42 … everything else: 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17 …

Slide 45

Slide 45 text

is 1: 1 is 2: 2 is 3-6: 3, 4, 5, 6 is 7-10: 7, 8, 9, 10 everything else: 0, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 …

Slide 46

Slide 46 text

.stringsdict (iOS7+)

Slide 47

Slide 47 text

dot.swift.plural NSStringLocalizedFormatKey %#@items@ items NSStringFormatSpecTypeKey NSStringPluralRuleType NSStringFormatValueTypeKey d one Установ. для %d выбранных друзей few Установ. для %d выбранных друзей other Установ. для %d выбранных друзей

Slide 48

Slide 48 text

One, two, few, many, other

Slide 49

Slide 49 text

let localizedString = NSLocalizedString("dot.swift.plural", comment: "Установ. для %d выбранных друзей") let pluralString = String.localizedStringWithFormat(localizedString, [number])

Slide 50

Slide 50 text

Use .stringsdict for plural localized strings.

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

Address

Slide 54

Slide 54 text

Roy Marmelstein The Stage Dot.Swift Théâtre des Variétés 8 boulevard Montmartre 75002 Paris France X

Slide 55

Slide 55 text

75002 Paris 8 boulevard Montmartre Théâtre des Variétés Dot.Swift The Stage Roy Marmelstein

Slide 56

Slide 56 text

CNPostalAddressFormatter (iOS9+)

Slide 57

Slide 57 text

let postalFormatter = CNPostalAddressFormatter() let postalAddress = CNMutablePostalAddress() postalAddress.street = "8 boulevard Montmartre" postalAddress.city = "Paris" postalAddress.state = "Ile de France" postalAddress.postalCode = "75002" postalAddress.country = "France" postalAddress.ISOCountryCode = "FR" let addressString = postalFormatter.stringFromPostalAddress(postalAddress)

Slide 58

Slide 58 text

Address formatter is hidden in Contacts. Use it when displaying addresses.

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Distance + weight

Slide 62

Slide 62 text

Inch, foot, yard, mile. Ounce, pound.

Slide 63

Slide 63 text

MKDistanceFormatter

Slide 64

Slide 64 text

let distance: CLLocationDistance = 100.0 // in Meters let distanceFormatter = MKDistanceFormatter() let localDistance = distanceFormatter.stringFromDistance(distance) 350 feet

Slide 65

Slide 65 text

NSMassFormatter

Slide 66

Slide 66 text

let weight = 66.0 // in Kg let massFormatter = NSMassFormatter() massFormatter.forPersonMassUse = true let localWeight = massFormatter.stringFromKilograms(weight) 147.71 lb

Slide 67

Slide 67 text

Distance formatter is hidden in MapKit. NSMassFormatter can handle all weights.

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

DIDN’T DISCUSS Left to right. Better with iOS9. A lot of work.

Slide 70

Slide 70 text

WHAT’S MISSING • Gender • Combination locales / phone • Misc differences (Chinese - no initials, French “ !“) • NS~

Slide 71

Slide 71 text

NS = Not Swift-y

Slide 72

Slide 72 text

github.com/marmelroy/Format github.com/marmelroy/ Localize-Swift github.com/AliSoftware/ SwiftGen

Slide 73

Slide 73 text

THE BIG PICTURE

Slide 74

Slide 74 text

Test Driven Development

Slide 75

Slide 75 text

Localization Driven Development

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

@marmelroy