36
Localizing iOS Apps Anthony Weiss weissazool.com [email protected] Friday, November 9, 12

Localizing iOS Apps

  • View
    1.191

  • Download
    0

Embed Size (px)

DESCRIPTION

Presentation for Tokyo iOS Developers meetup about localization. Topics include: Localizing text with NSLocalizedString() and genstrings, localizing images, localizing storyboards and nibs with ibtool.

Citation preview

Page 1: Localizing iOS Apps

Localizing iOS Apps

Anthony Weissweissazool.com

[email protected]

Friday, November 9, 12

Page 2: Localizing iOS Apps

Why localize?

Friday, November 9, 12

Page 3: Localizing iOS Apps

You make more money.

Friday, November 9, 12

Page 4: Localizing iOS Apps

Fixed cost of translationvs.

Unlimited potential upside

Friday, November 9, 12

Page 5: Localizing iOS Apps

Time investment:Minimal.

Friday, November 9, 12

Page 6: Localizing iOS Apps

How to prepare your app for localization:

NSLocalizedString(key, comment)

Friday, November 9, 12

Page 7: Localizing iOS Apps

labelExample.text = ! NSLocalizedString(@"NSLocalizedString() example", ! ! ! ! ! ! ! ! ! @"Translate 'example' only");

if (papayas == 0) { papayaPlurality = NSLocalizedString(@"NoPapayas", ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! @"No papayas."); additionalComment = NSLocalizedString(@"How sad.", ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! @"Regretfulness");}return [NSString stringWithFormat:! ! ! ! NSLocalizedString(@"You have %d %@. %@", ! ! ! ! ! ! ! ! ! ! ! ! @"Papaya possession"), ! ! ! ! papayas, papayaPlurality, additionalComment];

Friday, November 9, 12

Page 8: Localizing iOS Apps

Comments can give your translators

context.

Friday, November 9, 12

Page 9: Localizing iOS Apps

Everything’s in NSLocalizedString().

Now what?The genstrings command-line tool.

Friday, November 9, 12

Page 10: Localizing iOS Apps

What’s genstrings?genstrings searches your code for macros related to

localization, including NSLocalizedString().

Friday, November 9, 12

Page 11: Localizing iOS Apps

genstrings en.lprojgenstrings -o target-directory source-filesgenstrings -o target-directory other-source-files -a

Friday, November 9, 12

Page 12: Localizing iOS Apps

/* Translate 'example' only */"NSLocalizedString() example" = ! ! ! ! ! ! ! ! ! ! "NSLocalizedString() example";

/* No papayas. */"NoPapayas" = "papayas";

/* Regretfulness */"How sad." = "How sad.";

/* Papaya possession */"You have %d %@. %@" = "You have %1$d %2$@. %3$@";

Friday, November 9, 12

Page 13: Localizing iOS Apps

/* Translate 'example' only */"NSLocalizedString() example" = "Ejemplo de ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! NSLocalizedString()";

/* No papayas. */"NoPapayas" = "papayas";

/* Regretfulness */"How sad." = "Que lástima. ";

/* Papaya possession */"You have %d %@. %@" = "%3$@Usted tiene %1$d %2$@.";

Friday, November 9, 12

Page 14: Localizing iOS Apps

/* Papaya possession */"You have %d %@. %@" = "You have %1$d %2$@. %3$@";

/* Papaya possession */"You have %d %@. %@" = "%3$@Usted tiene %1$d %2$@.";

Friday, November 9, 12

Page 15: Localizing iOS Apps

Friday, November 9, 12

Page 16: Localizing iOS Apps

How does NSLocalizedString() work?

It’s dictionaries all the way down.

Friday, November 9, 12

Page 17: Localizing iOS Apps

NSLocalizedStringFromTable(key, table, comment)

Looks up your string in table.strings

Friday, November 9, 12

Page 18: Localizing iOS Apps

Adding localizations to your project

Let’s localizing!

Friday, November 9, 12

Page 19: Localizing iOS Apps

Friday, November 9, 12

Page 20: Localizing iOS Apps

I’ve got images with English text in them.

Friday, November 9, 12

Page 21: Localizing iOS Apps

en.lproj/aybabtu.png

Friday, November 9, 12

Page 22: Localizing iOS Apps

en.lproj/aybabtu.png

ja.lproj/aybabtu.png

Friday, November 9, 12

Page 23: Localizing iOS Apps

en.lproj/aybabtu.png

ja.lproj/aybabtu.png

es.lproj/aybabtu.png

Friday, November 9, 12

Page 24: Localizing iOS Apps

Friday, November 9, 12

Page 25: Localizing iOS Apps

I like Interface Builder. I don’t want to set my UI

text in code.

Friday, November 9, 12

Page 26: Localizing iOS Apps

ibtoolibtool --generate-strings-file MainStoryboard.strings

MainStoryboard.storyboard

ibtool --generate-strings-file NibName.strings NibName.xib

Friday, November 9, 12

Page 27: Localizing iOS Apps

/* Class = "IBUILabel"; text = "This text has been laid out in the nib."; ObjectID = "3ZM-yV-HpI"; */"3ZM-yV-HpI.text" = "This text has been laid out ! ! ! ! ! ! ! ! ! ! ! in the nib.";

/* Class = "IBUILabel"; text = "Just the way I like it!"; ObjectID = "Oxg-9T-bKW"; */"Oxg-9T-bKW.text" = "Just the way I like it!";

Friday, November 9, 12

Page 28: Localizing iOS Apps

ibtool --strings-file es.lproj/MainStoryboard.strings --write es.lproj/MainStoryboard.storyboard en.lproj/MainStoryboard.storyboard

ibtool --strings-file target-language/NibName.strings --write target-language/NibName.xib base-language/NibName.xib

Friday, November 9, 12

Page 29: Localizing iOS Apps

Friday, November 9, 12

Page 30: Localizing iOS Apps

Friday, November 9, 12

Page 31: Localizing iOS Apps

Friday, November 9, 12

Page 32: Localizing iOS Apps

Money, revisited.

Friday, November 9, 12

Page 33: Localizing iOS Apps

• Cost of translation: ¥8,000

• Revenue per sale: ¥60

• Sell 8000/60 = 135 extra apps in that language to break even.

Friday, November 9, 12

Page 34: Localizing iOS Apps

Which you need to leverage with sales and marketing.

Localization gives you a competitive advantage.

Friday, November 9, 12

Page 35: Localizing iOS Apps

Additional Resources

• https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html

• https://developer.apple.com/library/ios/#documentation/MacOSX/Conceptual/BPInternational/Articles/LocalizingInterfaces.html

• http://gengo.com/contact-support/quality-policy/

• http://kb.applingua.com/2011/10/3rd-party-localization-string-extraction-tools/

Friday, November 9, 12

Page 36: Localizing iOS Apps

WZLocalize

github.com/weissazool/WZLocalize

Friday, November 9, 12