SlideShare a Scribd company logo
1 of 29
Download to read offline
Avoiding Pitfalls with
Internationalization & Localization
Nashville CocoaHeads - August 26th, 2015
What We’ll Cover
• Internationalization vs Localization
• Content Types
• Text
• Dates
• Numbers
• Images
• Directionality
• Xcode Tips & Tricks
Why do it?
• The App Store is available in over 150 countries.
• 69% of app revenue comes from outside the U.S.
• Some users may speak English, but it may not be
their primary language.
Internationalization
vs
Localization
• Localization is the process of translating your app
into multiple languages.
• Internationalization is the process of making your
app able to adapt to different languages, regions,
and cultures.
Text
Strings Tables
• Translated text is stored in strings tables.
• Localizable.strings
• Key value pairs
• XLIFF format
XLIFF
<file original="InternationalizationExample/Localizable.strings" source-language="en" datatype="plaintext"
target-language="es">
<header>
<tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="6.4" build-num="6E35b"/>
</header>
<body>
<trans-unit id="Invalid Password">
<source>Invalid Password</source>
<target>Contraseña invalida</target>
<note>Title of the alert that is displayed when the user enters an invalid password.</note>
</trans-unit>
<trans-unit id="Please enter a password.">
<source>Please enter a password.</source>
<target>Por favor, introduzca una contraseña .</target>
<note>Instructions displayed when the user enters an invalid password.</note>
</trans-unit>
</body>
</file>
XML Localisation Interchange File Format
NSLocalizedString
• Parameters:
• Key - The key to use in the strings table.
• Comment - Provides context for translators.
<trans-unit id="Invalid Password">
<source>Invalid Password</source>
<target>Contraseña invalida</target>
<note>Title of the alert that is displayed when the user enters
an invalid password.</note>
</trans-unit>
NSLocalizedString(“Invalid Password”, comment: “Title of the alert
that is displayed when the user enters an invalid password.”)
Format Strings
[NSString localizedStringWithFormat:
NSLocalizedString(@“%@ is %d meters tall”, @“Name and
height (in meters) of a mountain”), mountain.name,
mountain.height];
<source>%@ is %d meters tall</source>
<target>%1$@ is %2$d meters tall</target>
<note>Name and height (in meters) of a mountain</note>
NSLocalizedString and DRY
• Don’t copy and paste NSLocalizedString macros/
functions everywhere if they are textually and
semantically the same.
• Instead of creating a constant for the key, create a
constant for the localized string. Otherwise, it won’t
be included in the XLIFF file when exported.
This string won’t get exported:
struct Constants {
struct Localization {
static let OkButtonTitle = "Ok"
}
}
let okButtonTitle = NSLocalizedString(Constants.Localization.OkButtonTitle,
comment: "Title of button to dismiss an alert")
This string will get exported and you only write the
comment once:
struct Constants {
struct Localization {
static let OkButtonTitle = NSLocalizedString("Ok", comment: "Title of
button to dismiss an alert")
}
}
let okButtonTitle = Constants.Localization.OkButtonTitle
Dates
NSDateFormatter
• Avoid format strings for user-visible dates
• Use Apple’s format styles
US English Aug 26, 2015
UK English Aug 26, 2015
Chinese 8⽉月 26, 2015
let df = NSDateFormatter()
df.dateFormat = “MMM d, y”
US English Aug 26, 2015
UK English 26 Aug 2015
Chinese 2015年8⽉月26⽇日
let df = NSDateFormatter()
df.dateStyle = .MediumStyle
Apple’s default styles don’t fit
your need?
let df = NSDateFormatter()
df.setLocalizedDateFormatFromTemplate("MMM d")
Numbers
NSNumberFormatter
• Just like NSDateFormatter, it is locale-sensitive
• NSNumberFormatter:
• +localizedStringFromNumber:numberStyle:
• NSString:
• +localizedStringWithFormat:
US English 1,234.56
France 1 234,56
Arabic ١٬٢٣٤٫٥٦
Currency
When using the currency style, the currency symbol
will change as well. No currency conversion is
performed. ($5 != £5)
Other Units
• NSMassFormatter
• NSEnergyFormatter
• And many more…
US English 44.092 pounds
Italian 20 chilogrammi
let weight = 20.0 // Store weight in metric units
let massFormatter = NSMassFormatter()
massFormatter.unitStyle = .Long
let formatted = massFormatter.stringFromKilograms(weight)
Images
Tips
• Avoid using images with text in them.
• Avoid image based puns. (🐝 Clever)
• Consider regional differences. A red octagon
symbolizes “stop” in the US, but in Japan, stop
signs are triangular.
Accessing Localized
Resources (iOS 9)
Don’t access the directories manually:
let lang = NSLocale.preferredLanguages().firstObject!
let lprojPath = lang.stringByAppendingPathExtension("lproj")
let filePath = NSBundle.mainBundle().pathForResource("stopSign", ofType: "png",
inDirectory: lprojPath)
NSBundle.mainBundle().imageForResource("stopSign")
NSBundle.mainBundle().pathForSoundResource("greeting")
NSBundle.mainBundle().URLForResource("help", withExtension: "pdf")
Use the NSBundle methods:
Directionality
Directionality
• Some languages such as Arabic or Hebrew are read
from right to left.
• AutoLayout leading and trailing constraints
cause views to automatically flip.
• To prevent flipping your UI, use right and left
attributes on your constraints instead of leading
and trailing.
What not to flip
• Video controls and timeline indicators
• Images, unless they communicate a sense of
direction, such as arrows
• Clocks
• Music notes and sheet music
• Graphs (x– and y–axes always appear in the same
orientation)
General Tips
Accessibility
Don’t forget to localize accessibility labels!
Sorting
• Use the “localizedStandardCompare:” selector for
sort descriptors used on user-facing strings. This will
sort according to the language rules of the current
locale.
compare: A, Ä, B, C, a, ä, b, c
localizedCaseInsensitiveCompare: A, a, b, B, c, C, ä, Ä
localizedStandardCompare: a, A, b, B, c, C, ä, Ä
Xcode Tips
Presentation continues in Xcode

More Related Content

What's hot

EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave Cramer
EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave CramerEPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave Cramer
EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave CramerBookNet Canada
 
#eprdctn tools & tips round up
#eprdctn tools & tips round up#eprdctn tools & tips round up
#eprdctn tools & tips round upBookNet Canada
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothBhavsingh Maloth
 
CSS Overview and Examples
CSS Overview and ExamplesCSS Overview and Examples
CSS Overview and ExamplesMouli Kalakota
 
F# type providers
F# type providersF# type providers
F# type providersAntya Dev
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptMarc Huang
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLToni Kolev
 
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris Febres
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris FebresThe beauty behind ebooks: CSS - ebookcraft 2015 - Iris Febres
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris FebresBookNet Canada
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop NotesPamela Fox
 
Web development basics (Part-1)
Web development basics (Part-1)Web development basics (Part-1)
Web development basics (Part-1)Rajat Pratap Singh
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript WorkshopPamela Fox
 
HTML & CSS Workshop Notes
HTML & CSS Workshop NotesHTML & CSS Workshop Notes
HTML & CSS Workshop NotesPamela Fox
 
Html css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers workHtml css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers workAlbino Tonnina
 

What's hot (20)

Web Frameworks
Web FrameworksWeb Frameworks
Web Frameworks
 
EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave Cramer
EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave CramerEPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave Cramer
EPUB vs. WEB: A Cautionary Tale - ebookcraft 2016 - Tzviya Siegman & Dave Cramer
 
#eprdctn tools & tips round up
#eprdctn tools & tips round up#eprdctn tools & tips round up
#eprdctn tools & tips round up
 
Xml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh malothXml dom & sax by bhavsingh maloth
Xml dom & sax by bhavsingh maloth
 
CSS Overview and Examples
CSS Overview and ExamplesCSS Overview and Examples
CSS Overview and Examples
 
Xml processors
Xml processorsXml processors
Xml processors
 
F# type providers
F# type providersF# type providers
F# type providers
 
Andromeda
AndromedaAndromeda
Andromeda
 
Web front end development introduction to html css and javascript
Web front end development introduction to html css and javascriptWeb front end development introduction to html css and javascript
Web front end development introduction to html css and javascript
 
FFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTMLFFW Gabrovo PMG - HTML
FFW Gabrovo PMG - HTML
 
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris Febres
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris FebresThe beauty behind ebooks: CSS - ebookcraft 2015 - Iris Febres
The beauty behind ebooks: CSS - ebookcraft 2015 - Iris Febres
 
Tenacity
TenacityTenacity
Tenacity
 
AJAX Workshop Notes
AJAX Workshop NotesAJAX Workshop Notes
AJAX Workshop Notes
 
Web development basics (Part-1)
Web development basics (Part-1)Web development basics (Part-1)
Web development basics (Part-1)
 
Python assignment help
Python assignment helpPython assignment help
Python assignment help
 
JavaScript Workshop
JavaScript WorkshopJavaScript Workshop
JavaScript Workshop
 
HTML & CSS Workshop Notes
HTML & CSS Workshop NotesHTML & CSS Workshop Notes
HTML & CSS Workshop Notes
 
XML XSLT
XML XSLTXML XSLT
XML XSLT
 
XML and XSLT
XML and XSLTXML and XSLT
XML and XSLT
 
Html css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers workHtml css workshop, lesson 0, how browsers work
Html css workshop, lesson 0, how browsers work
 

Similar to Avoiding Pitfalls with Internationalization & Localization

Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScriptDan Phiffer
 
Software Internationalization Crash Course
Software Internationalization Crash CourseSoftware Internationalization Crash Course
Software Internationalization Crash CourseWill Iverson
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveAxway Appcelerator
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Nelson Glauber Leal
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 OverviewRJ Owen
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoPaul Marden
 
advancedzplmacroprogramming_081820.pptx
advancedzplmacroprogramming_081820.pptxadvancedzplmacroprogramming_081820.pptx
advancedzplmacroprogramming_081820.pptxssuser6a1dbf
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scalascalaconfjp
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaKazuhiro Sera
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller ColumnsJonathan Fine
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...Sang Don Kim
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)Oliver Lin
 

Similar to Avoiding Pitfalls with Internationalization & Localization (20)

React native
React nativeReact native
React native
 
Tml for Objective C
Tml for Objective CTml for Objective C
Tml for Objective C
 
Intro to appcelerator
Intro to appceleratorIntro to appcelerator
Intro to appcelerator
 
Intro to JavaScript
Intro to JavaScriptIntro to JavaScript
Intro to JavaScript
 
Software Internationalization Crash Course
Software Internationalization Crash CourseSoftware Internationalization Crash Course
Software Internationalization Crash Course
 
Ingo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep DiveIngo Muschenetz: Titanium Studio Deep Dive
Ingo Muschenetz: Titanium Studio Deep Dive
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Flex 4 Overview
Flex 4 OverviewFlex 4 Overview
Flex 4 Overview
 
Multi Lingual Websites In Umbraco
Multi Lingual Websites In UmbracoMulti Lingual Websites In Umbraco
Multi Lingual Websites In Umbraco
 
advancedzplmacroprogramming_081820.pptx
advancedzplmacroprogramming_081820.pptxadvancedzplmacroprogramming_081820.pptx
advancedzplmacroprogramming_081820.pptx
 
Solid and Sustainable Development in Scala
Solid and Sustainable Development in ScalaSolid and Sustainable Development in Scala
Solid and Sustainable Development in Scala
 
Solid And Sustainable Development in Scala
Solid And Sustainable Development in ScalaSolid And Sustainable Development in Scala
Solid And Sustainable Development in Scala
 
DSLs in JavaScript
DSLs in JavaScriptDSLs in JavaScript
DSLs in JavaScript
 
JavaScript Miller Columns
JavaScript Miller ColumnsJavaScript Miller Columns
JavaScript Miller Columns
 
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
[Td 2015] what is new in visual c++ 2015 and future directions(ulzii luvsanba...
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
iOS Programming - MCV (Delegate/Protocols/Property&Syntax)
 

Recently uploaded

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Avoiding Pitfalls with Internationalization & Localization

  • 1. Avoiding Pitfalls with Internationalization & Localization Nashville CocoaHeads - August 26th, 2015
  • 2. What We’ll Cover • Internationalization vs Localization • Content Types • Text • Dates • Numbers • Images • Directionality • Xcode Tips & Tricks
  • 3. Why do it? • The App Store is available in over 150 countries. • 69% of app revenue comes from outside the U.S. • Some users may speak English, but it may not be their primary language.
  • 4. Internationalization vs Localization • Localization is the process of translating your app into multiple languages. • Internationalization is the process of making your app able to adapt to different languages, regions, and cultures.
  • 6. Strings Tables • Translated text is stored in strings tables. • Localizable.strings • Key value pairs • XLIFF format
  • 7. XLIFF <file original="InternationalizationExample/Localizable.strings" source-language="en" datatype="plaintext" target-language="es"> <header> <tool tool-id="com.apple.dt.xcode" tool-name="Xcode" tool-version="6.4" build-num="6E35b"/> </header> <body> <trans-unit id="Invalid Password"> <source>Invalid Password</source> <target>Contraseña invalida</target> <note>Title of the alert that is displayed when the user enters an invalid password.</note> </trans-unit> <trans-unit id="Please enter a password."> <source>Please enter a password.</source> <target>Por favor, introduzca una contraseña .</target> <note>Instructions displayed when the user enters an invalid password.</note> </trans-unit> </body> </file> XML Localisation Interchange File Format
  • 8. NSLocalizedString • Parameters: • Key - The key to use in the strings table. • Comment - Provides context for translators. <trans-unit id="Invalid Password"> <source>Invalid Password</source> <target>Contraseña invalida</target> <note>Title of the alert that is displayed when the user enters an invalid password.</note> </trans-unit> NSLocalizedString(“Invalid Password”, comment: “Title of the alert that is displayed when the user enters an invalid password.”)
  • 9. Format Strings [NSString localizedStringWithFormat: NSLocalizedString(@“%@ is %d meters tall”, @“Name and height (in meters) of a mountain”), mountain.name, mountain.height]; <source>%@ is %d meters tall</source> <target>%1$@ is %2$d meters tall</target> <note>Name and height (in meters) of a mountain</note>
  • 10. NSLocalizedString and DRY • Don’t copy and paste NSLocalizedString macros/ functions everywhere if they are textually and semantically the same. • Instead of creating a constant for the key, create a constant for the localized string. Otherwise, it won’t be included in the XLIFF file when exported.
  • 11. This string won’t get exported: struct Constants { struct Localization { static let OkButtonTitle = "Ok" } } let okButtonTitle = NSLocalizedString(Constants.Localization.OkButtonTitle, comment: "Title of button to dismiss an alert") This string will get exported and you only write the comment once: struct Constants { struct Localization { static let OkButtonTitle = NSLocalizedString("Ok", comment: "Title of button to dismiss an alert") } } let okButtonTitle = Constants.Localization.OkButtonTitle
  • 12. Dates
  • 13. NSDateFormatter • Avoid format strings for user-visible dates • Use Apple’s format styles
  • 14. US English Aug 26, 2015 UK English Aug 26, 2015 Chinese 8⽉月 26, 2015 let df = NSDateFormatter() df.dateFormat = “MMM d, y” US English Aug 26, 2015 UK English 26 Aug 2015 Chinese 2015年8⽉月26⽇日 let df = NSDateFormatter() df.dateStyle = .MediumStyle
  • 15. Apple’s default styles don’t fit your need? let df = NSDateFormatter() df.setLocalizedDateFormatFromTemplate("MMM d")
  • 17. NSNumberFormatter • Just like NSDateFormatter, it is locale-sensitive • NSNumberFormatter: • +localizedStringFromNumber:numberStyle: • NSString: • +localizedStringWithFormat: US English 1,234.56 France 1 234,56 Arabic ١٬٢٣٤٫٥٦
  • 18. Currency When using the currency style, the currency symbol will change as well. No currency conversion is performed. ($5 != £5)
  • 19. Other Units • NSMassFormatter • NSEnergyFormatter • And many more… US English 44.092 pounds Italian 20 chilogrammi let weight = 20.0 // Store weight in metric units let massFormatter = NSMassFormatter() massFormatter.unitStyle = .Long let formatted = massFormatter.stringFromKilograms(weight)
  • 21. Tips • Avoid using images with text in them. • Avoid image based puns. (🐝 Clever) • Consider regional differences. A red octagon symbolizes “stop” in the US, but in Japan, stop signs are triangular.
  • 22. Accessing Localized Resources (iOS 9) Don’t access the directories manually: let lang = NSLocale.preferredLanguages().firstObject! let lprojPath = lang.stringByAppendingPathExtension("lproj") let filePath = NSBundle.mainBundle().pathForResource("stopSign", ofType: "png", inDirectory: lprojPath) NSBundle.mainBundle().imageForResource("stopSign") NSBundle.mainBundle().pathForSoundResource("greeting") NSBundle.mainBundle().URLForResource("help", withExtension: "pdf") Use the NSBundle methods:
  • 24. Directionality • Some languages such as Arabic or Hebrew are read from right to left. • AutoLayout leading and trailing constraints cause views to automatically flip. • To prevent flipping your UI, use right and left attributes on your constraints instead of leading and trailing.
  • 25. What not to flip • Video controls and timeline indicators • Images, unless they communicate a sense of direction, such as arrows • Clocks • Music notes and sheet music • Graphs (x– and y–axes always appear in the same orientation)
  • 27. Accessibility Don’t forget to localize accessibility labels!
  • 28. Sorting • Use the “localizedStandardCompare:” selector for sort descriptors used on user-facing strings. This will sort according to the language rules of the current locale. compare: A, Ä, B, C, a, ä, b, c localizedCaseInsensitiveCompare: A, a, b, B, c, C, ä, Ä localizedStandardCompare: a, A, b, B, c, C, ä, Ä