Page 1
#WWDC17
© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.
Joaquim Lobo Silva, Internationalization Software Engineer
•Localization Best Practices on tvOS • Session 248
App Frameworks
Page 3
•Text •Layout and images •Exporting and testing
Page 4
•Text •Layout and images •Exporting and testing
Page 6
Text
Strings in Storyboards are localizable by default
Page 7
Text
Strings in Storyboards are localizable by default
In code, wrap strings with NSLocalizedString() calls
Page 8
Text
Strings in Storyboards are localizable by default
In code, wrap strings with NSLocalizedString() calls
Comments are extremely useful
Page 9
Text
Strings in Storyboards are localizable by default
In code, wrap strings with NSLocalizedString() calls
Comments are extremely usefullet instruction = NSLocalizedString("Subscribe", comment: "Button title, start subscription")
Page 10
Text
Strings in Storyboards are localizable by default
In code, wrap strings with NSLocalizedString() calls
Comments are extremely useful
Page 11
Text
Strings in Storyboards are localizable by default
In code, wrap strings with NSLocalizedString() calls
Comments are extremely useful
Page 13
Text
Not everything needs to be a localized string literal
Page 14
Text
Not everything needs to be a localized string literal
Formatters for numbers, dates and date intervals, units, etc.
Page 15
Text
Not everything needs to be a localized string literal
Formatters for numbers, dates and date intervals, units, etc.
let formatter = DateFormatter()
Page 16
Text
Not everything needs to be a localized string literal
Formatters for numbers, dates and date intervals, units, etc.
let formatter = DateFormatter()
formatter.timeStyle = .shortlet string = formatter.string(from: date) // 9:41 AM
Page 17
Text
Not everything needs to be a localized string literal
Formatters for numbers, dates and date intervals, units, etc.
let formatter = DateFormatter()
formatter.timeStyle = .shortlet string = formatter.string(from: date) // 9:41 AM
Measurements and Units WWDC 2016
Internationalization Best Practices WWDC 2016
Page 19
Remote Content
Remote text should match your app's language
Page 20
Remote Content
Remote text should match your app's language• e.g. media content and descriptions
Page 21
Remote Content
Remote text should match your app's language• e.g. media content and descriptions
APIs to determine best language to display
Page 22
Remote Content
Remote text should match your app's language• e.g. media content and descriptions
APIs to determine best language to display
Considers regional variants and appropriate fallbacks
Page 23
Remote Content
Remote text should match your app's language• e.g. media content and descriptions
APIs to determine best language to display
Considers regional variants and appropriate fallbacks
Locale.preferredLanguages bundle.localizations bundle.preferredLocalizations
es-MX en, en-GB, es-ES, es-419, zh-Hans es-419
zh-CN en, es, fr, ja, ko, zh-Hans, zh-Hant zh-Hans
Page 24
// Get the localization the app is currently launched in
let currentLocalization = Bundle.main.preferredLocalizations.first
// Get best localization match from a list of available localizations
let available = myServerSupportedLanguages()
let matchedLocalization = Bundle.preferredLocalizations(from: available).first
Page 25
// Get the localization the app is currently launched in
let currentLocalization = Bundle.main.preferredLocalizations.first
// Get best localization match from a list of available localizations
let available = myServerSupportedLanguages()
let matchedLocalization = Bundle.preferredLocalizations(from: available).first
Page 26
// Get the localization the app is currently launched in
let currentLocalization = Bundle.main.preferredLocalizations.first
// Get best localization match from a list of available localizations
let available = myServerSupportedLanguages()
let matchedLocalization = Bundle.preferredLocalizations(from: available).first
Page 27
Text Summary
Use strings in Storyboards
Use NSLocalizedString
Use formatters
Use Bundle APIs to determine language for remote content
Page 28
•Text •Layout and images •Exporting and testing
Page 30
Layout
Adapt for…
Page 31
Layout
Adapt for…• Different translation lengths
Page 32
Layout
Adapt for…• Different translation lengths
BackupEnglish
Page 33
Layout
Adapt for…• Different translation lengths
Backup VarmuuskopiointiEnglish Finnish
Page 34
Layout
Adapt for…• Different translation lengths
• Script directionality
Backup VarmuuskopiointiEnglish Finnish
Page 35
Layout
Adapt for…• Different translation lengths
• Script directionality
Backup VarmuuskopiointiEnglish Finnish
HelloEnglish
Page 36
Layout
Adapt for…• Different translation lengths
• Script directionality
Backup VarmuuskopiointiEnglish Finnish
Hello مرحبًاEnglish Arabic
Page 38
Layout in UIKit
UIStackView
Page 39
Layout in UIKit
UIStackView
1
23 4
Page 40
Layout in UIKit
UIStackView
1
23 4
Left-to-Right
Page 41
Layout in UIKit
UIStackView
1
23 4
Left-to-Right
Auto Layout: Leading/trailing constraints
Page 42
Layout in UIKit
UIStackView
1
23 4
Left-to-Right
Auto Layout: Leading/trailing constraints• Leading resolves to left in left-to-right, right in right-to-left
Page 43
Layout in UIKit
UIStackView
Right-to-Left
1
234
Auto Layout: Leading/trailing constraints • Leading resolves to left in left-to-right, right in right-to-left
Page 44
Layout in UIKit
UIStackView
Right-to-Left
1
234
Auto Layout: Leading/trailing constraints • Leading resolves to left in left-to-right, right in right-to-left
Page 45
Layout in TVMLKitNEW
Page 46
Templates do all the work
Layout in TVMLKitNEW
Page 47
Templates do all the work
For custom positioning:
Layout in TVMLKitNEW
Page 48
Templates do all the work
For custom positioning:• leading and trailing tv-position and tv-align
Layout in TVMLKitNEW
Page 49
Templates do all the work
For custom positioning:• leading and trailing tv-position and tv-align
- leading resolves to left in left-to-right, right in right-to-left
Layout in TVMLKitNEW
Page 50
Templates do all the work
For custom positioning:• leading and trailing tv-position and tv-align
- leading resolves to left in left-to-right, right in right-to-left• @(media layout-direction: rtl) media queries for margins and padding
Layout in TVMLKitNEW
Page 51
Templates do all the work
For custom positioning:• leading and trailing tv-position and tv-align
- leading resolves to left in left-to-right, right in right-to-left• @(media layout-direction: rtl) media queries for margins and padding
Layout in TVMLKit
Advances in TVMLKit Grand Ballroom B Tuesday 11:20AM
NEW
Page 54
Images
Universal Mirrored
Page 55
Images
Universal Mirrored
Page 56
Images
Universal Mirrored Dedicated
Page 57
Images
Universal Mirrored Dedicated
Page 58
Images
Universal Mirrored Dedicated
Page 61
Images
What’s New in International User Interfaces WWDC 2016
Page 62
Layout and Images Summary
UIKit • UIStackView • Auto Layout
TVMLKit • Templates • New direction APIs
Page 63
•Text •Layout and images •Exporting and testing
Page 64
Adding Languages to Your Project
Page 65
Adding Languages to Your Project
Page 66
Exporting Your Localizable Content
Page 67
Importing Translated Content
Page 69
Testing
Xcode has several features for testing and verification
Page 70
Testing
Xcode has several features for testing and verification
Even if you don't speak the language!
Page 71
Testing
Xcode has several features for testing and verification
Even if you don't speak the language!• Localizability static analyzer
Page 72
Testing
Xcode has several features for testing and verification
Even if you don't speak the language! • Localizability static analyzer • Pseudolanguages
Page 74
Testing
Xcode has several features for testing and verification
Even if you don't speak the language! • Localizability static analyzer • Pseudolanguages
Localizing with Xcode 9 Grand Ballroom B Tuesday 10:20AM
Page 75
Project Setup Summary
Add supported languages to your project
Export and import localizable content
Static analyzer and runtime pseudolanguages
Page 76
More Informationhttps://developer.apple.com/wwdc17/248
Page 77
Localizing with Xcode 9 Grand Ballroom B Tuesday 10:20AM
Advances in TVMLKit Grand Ballroom B Tuesday 11:20AM
Internationalization Best Practices WWDC 2016
What’s New in International User Interfaces WWDC 2016
Measurements and Units WWDC 2016
Related Sessions