Slide 1

Slide 1 text

Fearless Internationalization and Localization Across the Nations Siena Aguayo Software Engineer at Indiegogo @sienatime

Slide 2

Slide 2 text

● What are l10n and i18n? Overview ● Why should I care? ● How do I internationalize my Android app? ● What other cool things can I do?

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

What are l10n and i18n?

Slide 6

Slide 6 text

localization internationalization 01 02 03 04 05 06 07 08 09 10 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18

Slide 7

Slide 7 text

Localization ● Translating content into target languages ● Displaying data (dates, numbers, currencies, etc.) according to target region ● Adjusting branding according to target culture BUSINESS

Slide 8

Slide 8 text

Internationalization ● Preparing your app for localized content ○ Defining alternate resource files ○ Using number and date formatters ○ Designing flexible layouts ENGINEERING

Slide 9

Slide 9 text

localization internationalization not just translation™

Slide 10

Slide 10 text

Why should I care?

Slide 11

Slide 11 text

EMPATHY

Slide 12

Slide 12 text

Android peeps made with androidify.com Android is everywhere!

Slide 13

Slide 13 text

From a technical perspective... ● Separation of concerns ● Organization & readability

Slide 14

Slide 14 text

ya ain’t gonna need it

Slide 15

Slide 15 text

How do I internationalize my Android app?

Slide 16

Slide 16 text

How do I prepare my Android app for localized content?

Slide 17

Slide 17 text

What content is localizable? ● Strings ● Numbers and currency ● Dates and time ● Images with text on them (avoid) ● Audio and video files

Slide 18

Slide 18 text

Resource Files Java Strings Images Audio Video Numbers Currency Dates Time

Slide 19

Slide 19 text

Resource Files ● Have a set of default resources ● Define alternates as you need them res values strings.xml

Slide 20

Slide 20 text

Strings ● Don’t hardcode strings that face the user ● Use position placeholders %1$s %2$s ● Provide context for your translators to help make their job easier I need to %s interpolate %s I need to %1$s interpolate %2$s

Slide 21

Slide 21 text

Android Is on Your Side

Slide 22

Slide 22 text

Indiegogo Hey, Don’t Translate This Helpful lint errors

Slide 23

Slide 23 text

Ended on %s XML Is Extensible

Slide 24

Slide 24 text

Numbers & Currencies import java.text.NumberFormat; NumberFormat numberFormat = NumberFormat.getInstance(); textView.setText(numberFormat.format(36965));

Slide 25

Slide 25 text

strings.xml %s friend %s friends Plurals beware of %d *.java res.getQuantityString( R.plurals.number_of_fb_friends, count, numberFormat.format(count) );

Slide 26

Slide 26 text

Dates & Time // DateFormat.getDateFormat (short) // DateFormat.getMediumDateFormat // DateFormat.getLongDateFormat en_US short: 8/23/2015 medium: Aug 23, 2015 long: August 23, 2015 ja_JP short: 2015/08/23 medium: 2015/08/23 long: 2015年8月23日 DateFormat dateFormatter = DateFormat.getDateFormat(context); Date now = new Date(); dateFormatter.format(now);

Slide 27

Slide 27 text

Custom Date Formats: API 18+ String formatString = DateFormat.getBestDateTimePattern( Locale.getDefault(), "MMMMyyyy" ); SimpleDateFormat dateFormatter = new SimpleDateFormat (formatString); Date now = new Date(); String dateString = dateFormatter.format(now); en_US: August 2015 ja_JP: 2015年8月

Slide 28

Slide 28 text

Custom Date Formats: API <18 ● ¯\_(ツ)_/¯ ● Collect date formats you need and keep them in your resources ● ...but Android is still going to format according to the user’s locale even if you don’t support it ● Joda-Time

Slide 29

Slide 29 text

SpannableString & String.format ● Try to avoid ● Replace, if you can, with HTML in your strings.xml (limited tag support) public void setSpan (Object what, int start, int end, int flags) textView.setText(Html.fromHtml( res.getString(R.string.fixed_funding)) );

Slide 30

Slide 30 text

Build Flexible Layouts ● Thank God for wrap_content ● Be mindful of line lengths ● What would happen if these two pieces of data needed to be switched around?

Slide 31

Slide 31 text

What other cool things can I do?

Slide 32

Slide 32 text

Android Studio Translations Editor

Slide 33

Slide 33 text

Google Play App Translation Service

Slide 34

Slide 34 text

Google Play Developer Console → Statistics ● What languages and countries your users are in ● How your app compares to others in your category

Slide 35

Slide 35 text

Smartling ● Paid translation service ● API and Java SDK ● Update strings files with a push and a pull

Slide 36

Slide 36 text

Smartling: Push $ ./smartling.sh push Pushing strings.xml to smartling... ApiResponse[data=UploadFileData[stringCount=207, wordCount=506,overWritten=false],code=SUCCESS,messages=[]]

Slide 37

Slide 37 text

Smartling: Pull $ ./smartling.sh pull Pulling non-English locales from smartling... pulling fr-Fr from smartling... saved fr-Fr to /app/src/main/res/values-fr/strings.xml pulling de-DE from smartling... saved de-DE to /app/src/main/res/values-de/strings.xml pulling es from smartling... saved es to /app/src/main/res/values-es/strings.xml

Slide 38

Slide 38 text

Further Reading ● Localizing with Resources http://developer.android. com/guide/topics/resources/localization.html ● Localization Checklist http://developer.android. com/distribute/tools/localization-checklist.html ● Google Play App Translation Service blog post http://android- developers.blogspot.com/2013/11/app-translation-service-now- available.html ● Smartling API http://docs.smartling.com/pages/API/v2/ ● Smartling Java SDK http://docs.smartling. com/pages/API/v2/SDKs/#Java

Slide 39

Slide 39 text

Go out and be fearless! Any questions? @sienatime