localization realization

47
Localization Realization Aaron Douglas @astralbodies

Upload: aaron-douglas

Post on 10-May-2015

282 views

Category:

Technology


0 download

DESCRIPTION

Most of us know the drill - write the app, crank out the code and localize later. Thinking about localizing your iOS app up front will save you tons of time later. I'll also talk about a great project that can help you put translation into the hands of your users.

TRANSCRIPT

Page 1: Localization Realization

Localization Realization

Aaron Douglas @astralbodies

Page 2: Localization Realization

Who am I?

• Aaron Douglas

• Red Arrow Labs in Milwaukee

• Mobile (iOS & Android) & Enterprise Java Developer

Page 3: Localization Realization

Internationalization vs Localization

• i18n vs L10n

• i18n = adapting to work everywhere

• L10n = additional features for a specific locale

Page 4: Localization Realization

What Is the Point?

• Language

• Culture

• Conventions

• Legal

Page 5: Localization Realization

Sounds hard.

• It can be difficult

• It’s not as easy as translate.google.com

• It can pay off big

Page 6: Localization Realization

Why Localize?

• Opens up markets for your product(s)

• Apple gives “free” insertion into localized App Stores

• Greater income

• Your power users = your translators

Page 7: Localization Realization

When do I start?

• From day one

• Existing application

Page 8: Localization Realization

What do I localize?

• Strings

• Numbers

• Dates

• Images

• Layouts

Page 9: Localization Realization

NSLocale

Page 10: Localization Realization

NSLocale

• Encapsulates a lot of information

• Language

• Cultural conventions

• Dates

• Numbers

Page 11: Localization Realization

Different Locales

• System Locale

• Current Locale

• NSCurrentLocaleDidChangeNotification

Page 12: Localization Realization

Strings

Page 13: Localization Realization

Strings

• NSLocalizedString

• XIB/NIB/Storyboards

• Localizable.strings

• lproj folders

• UTF-16 files

Page 14: Localization Realization

/* All-day switch label */ "All-day" = "All-day";

cell.textLabel.text = NSLocalizedString(@"All-day", @"All-day switch label");

Keys, Values and Comments

Page 15: Localization Realization

genstrings & ibtool

find . -name \*.m | xargs genstrings -o en.lproj/

ibtool --generate-strings-file MainMenu.strings MainMenu.xib

ibtool --strings-file MainMenu.strings --write ../French.lproj/MainMenu.xib

MainMenu.xib

Page 16: Localization Realization

Looks can be deceiving

• Keys are unique to each strings file

• Don’t overload!

• UTF-16 plays hell with email

• Use the comments properly

• Positional parameters

Page 17: Localization Realization

Comparing & Sorting

• A a B b C c D d = English

• a, A, b, B, c, C, ä, Ä = Swedish

• Called collation

• -compare: is wrong

• Use -localizedStandardCompare:

Page 18: Localization Realization

Validation

• Your validation logic may be locale-dependent

• Postal codes

• Regular Expressions

Page 19: Localization Realization

Debugging

NSDictionary *defaults = @{ @"NSShowNonLocalizableStrings": @(YES), @"NSShowNonLocalizedStrings": @(YES)}; ![[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; ![[NSUserDefaults standardUserDefaults] synchronize];

Page 20: Localization Realization

Numbers

Page 21: Localization Realization

NSNumberFormatter

• +localizedStringFromNumber:numberStyle:

• Styles: General, Currency, Percentage, Scientific, Spell-Out

Page 22: Localization Realization

Examples

• @45678.90

• General: 45,678.90

• Currency: $45,678.90

• Percentage: 4,567,890%

• Scientific: 4.56789E+04

• Spell-Out: Forty five thousand six ...

Page 23: Localization Realization

Locale Specific Formats

• 45 678,90

• ¥456.78

Page 24: Localization Realization

Number Tips

• Avoid intValue

• Use NSNumberFormatter

• Unit conversion is important

Page 25: Localization Realization

Dates

Page 26: Localization Realization

Dates

• One of the most messed up concepts

• NSDate is a wrapped NSTimeInterval

• Simply a point in time

Page 27: Localization Realization

Why Are Dates Hard?

• Time Zones

• Leap Years

• Leap Seconds

• Date Math

• Calendar Conversion

Page 28: Localization Realization

Calendars

• Gregorian

• Islamic

• Hindu

• Hebrew

• and on and on

Page 29: Localization Realization

Don’t Assume

• Date formats / Input masks

• Length of days/weeks/months

• Gregorian

• Location hasn’t changed since launch (timezones!)

Page 30: Localization Realization

Do Assume

• API calls with date formats

• Internally stored dates

• NSDate has no timezone

Page 31: Localization Realization

Images

Page 32: Localization Realization

Images

• Use Core Graphics to draw text

• No text on launch images

• Keep cultural references in mind

Page 33: Localization Realization

Cultural Images

Page 34: Localization Realization

Layouts

Page 35: Localization Realization

Layouts

• Words can be different lengths in another language

• Mac OS X has autolayouts

• iOS may “some day” have autolayout

• [UIBarButtonItem possibleTitles]

Page 36: Localization Realization

ibtool

• Separate NIBs for each locale

• Don’t make layout changes in locale-specific NIB!

• Programmatically move items

• Wait until iOS 6...

Page 37: Localization Realization

Translation

Page 38: Localization Realization

Process

• Collect Strings files/resources

• Send to translators

• Incorporate new strings

• Test, test, test, test!

Page 39: Localization Realization

translate.google.com

Page 40: Localization Realization

Greenwich

Page 41: Localization Realization

Greenwich

• Mac & iOS Apps!

• iOS requires a Mac & Bonjour

• http://github.com/fadingred/Greenwich

Page 42: Localization Realization

Services

• gengo - http://gengo.com

• Applingua - http://applingua.com

• Amazon Mechanical Turk

Page 43: Localization Realization

Resources

Page 44: Localization Realization

Apple Developer Library

• Internationalization Programming Topics

• International Mountains (Sample Code)

Page 45: Localization Realization

WWDC Videos

• 2011 - 131 - Getting Your Apps Ready for China and Other Hot Markets

• 2012 - 244 - Internationalization Tips and Tricks

Page 46: Localization Realization

Demo

Page 47: Localization Realization

Questions?