Fearless Internationalization and Localization Across the Nations

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

Transcript of Fearless Internationalization and Localization Across the Nations

Page 1: Fearless Internationalization and Localization Across the Nations

Fearless Internationalization and Localization Across the

Nations Siena Aguayo

Software Engineer at Indiegogo @sienatime

Page 2: Fearless Internationalization and Localization Across the Nations

@sienatime

•  What are l10n and i18n?

Overview

•  Why should I care?

•  How do I internationalize my Android app?

•  What other cool things can I do?

Page 3: Fearless Internationalization and Localization Across the Nations

@sienatime

Page 4: Fearless Internationalization and Localization Across the Nations

@sienatime

Page 5: Fearless Internationalization and Localization Across the Nations

@sienatime

What are l10n and i18n?

Page 6: Fearless Internationalization and Localization Across the Nations

@sienatime

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

Page 7: Fearless Internationalization and Localization Across the Nations

@sienatime

Localization

•  Displaying data (dates, numbers, currencies, etc.) according to target region

•  Adjusting branding according to target culture

BUSINESS •  Translating content into target languages

Page 8: Fearless Internationalization and Localization Across the Nations

@sienatime

Internationalization

•  Preparing your app for localized content

•  Defining alternate resource files

•  Using number and date formatters

•  Designing and implementing flexible layouts

ENGINEERING

Page 9: Fearless Internationalization and Localization Across the Nations

@sienatime

localization internationalization

not just translation™

Page 10: Fearless Internationalization and Localization Across the Nations

@sienatime

Why should I care?

Page 11: Fearless Internationalization and Localization Across the Nations

@sienatime

EMPATHY

Page 12: Fearless Internationalization and Localization Across the Nations

Android peeps made with androidify.com

Android is everywhere!

@sienatime

Page 13: Fearless Internationalization and Localization Across the Nations

@sienatime

From a technical perspective...

•  Separation of concerns

•  Organization & readability

Page 14: Fearless Internationalization and Localization Across the Nations

@sienatime

ya ain’t gonna need it (you’re not going to need it)

Page 15: Fearless Internationalization and Localization Across the Nations

@sienatime

How do I internationalize my Android app?

Page 16: Fearless Internationalization and Localization Across the Nations

@sienatime

How do I prepare my Android app for localized content?

Page 17: Fearless Internationalization and Localization Across the Nations

@sienatime

What content is localizable?

•  Strings

•  Numbers and currency

•  Dates and time

•  Images with text on them (avoid)

•  Audio and video files

Page 18: Fearless Internationalization and Localization Across the Nations

@sienatime

Resource Files Java

Strings Images Audio Video

Numbers Currency Dates Time

Page 19: Fearless Internationalization and Localization Across the Nations

@sienatime

Resource Files

•  Have a set of default resources

•  Define alternates as you need them

res values strings.xml

Page 20: Fearless Internationalization and Localization Across the Nations

@sienatime

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

Page 21: Fearless Internationalization and Localization Across the Nations

@sienatime

Android Is on Your Side

Page 22: Fearless Internationalization and Localization Across the Nations

@sienatime

<string name="app_name" translatable="false"> Indiegogo </string>

Hey, Don’t Translate This

Helpful lint errors

Page 23: Fearless Internationalization and Localization Across the Nations

@sienatime

<string name="campaign_ended_label" note="example: Ended on January 21, 2014"> Ended on %s </string>

XML Is Extensible

Page 24: Fearless Internationalization and Localization Across the Nations

@sienatime

Numbers & Currencies

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

Page 25: Fearless Internationalization and Localization Across the Nations

@sienatime

*.java res.getQuantityString(

R.plurals.number_of_fb_friends, count, numberFormat.format(count)

);

strings.xml <plurals name="number_of_fb_friends"> <item quantity="one">%s friend</item> <item quantity="other">%s friends</item> </plurals>

Plurals

beware of %d

Page 26: Fearless Internationalization and Localization Across the Nations

@sienatime

Dates & Time // DateFormat.getDateFormat (short) // DateFormat.getMediumDateFormat // DateFormat.getLongDateFormat

en_US short: 08/07/2015 medium: Aug 7, 2015 long: August 7, 2015

en_AU short: 07/08/2015 medium: 7 Aug 2015 long: 7 August 2015

DateFormat dateFormatter = DateFormat.getDateFormat(context); Date now = new Date(); dateFormatter.format(now);

Page 27: Fearless Internationalization and Localization Across the Nations

@sienatime

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月

Page 28: Fearless Internationalization and Localization Across the Nations

@sienatime

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

Page 29: Fearless Internationalization and Localization Across the Nations

@sienatime

Multi-Format Spannables

Try to avoid

public void setSpan (Object what, int start, int end, int flags)

I’m some fancy spanned text! spanned

Page 30: Fearless Internationalization and Localization Across the Nations

@sienatime

Multi-Format Spannables

Replace, if you can, with HTML in your strings.xml (limited tag support)

textView.setText(Html.fromHtml( res.getString(R.string.fixed_funding)) );

<string name="flexible_funding"> <![CDATA[ <b>Flexible Funding.</b> Campaign keeps all funds raised. ]]> </string>

Page 31: Fearless Internationalization and Localization Across the Nations

@sienatime

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?

Page 32: Fearless Internationalization and Localization Across the Nations

@sienatime

What other cool things can I do?

Page 33: Fearless Internationalization and Localization Across the Nations

@sienatime

Android Studio Translations Editor

Page 34: Fearless Internationalization and Localization Across the Nations

@sienatime

Google Play App Translation Service

Page 35: Fearless Internationalization and Localization Across the Nations

@sienatime

Google Play Developer Console → Statistics

•  What languages and countries your users are in

•  How your app compares to others in your category

Page 36: Fearless Internationalization and Localization Across the Nations

@sienatime

Smartling

•  Paid translation service

•  API and Java SDK

•  Update strings files with a push and a pull

Page 37: Fearless Internationalization and Localization Across the Nations

@sienatime

Smartling: Push

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

Page 38: Fearless Internationalization and Localization Across the Nations

@sienatime

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

Page 39: Fearless Internationalization and Localization Across the Nations

@sienatime

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

Page 40: Fearless Internationalization and Localization Across the Nations

@sienatime

Go out and be fearless!

Any questions? @sienatime