Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Internationalization & Localization: Best Pract...

Ayuna Vogel
November 15, 2016

Internationalization & Localization: Best Practices

Ayuna Vogel's talk on iOS localization at the Brooklyn Swift Developers Meetup at Prolific Interactive on November 15, 2016

Videos to go along:

video part 1 - https://www.facebook.com/prolificinteractive/videos/10154067752492596/

video part 2 - https://www.facebook.com/prolificinteractive/videos/10154067764867596/

Ayuna Vogel

November 15, 2016
Tweet

More Decks by Ayuna Vogel

Other Decks in Programming

Transcript

  1. i18n To internationalize your app means to adapt it for

    users in other countries who want to use your app in a language they understand, and see dates, times, and numbers in familiar, regional formats. l10n To localize your app means to translate it into other languages.
  2. Steps 1. Internationalize your app 2. Localize your App 3.

    Test your app 4. Specify territories in iTunes Connect
  3. 1. Internationalize Your App • Separate user facing text from

    your code. • Use base internationalization to separate user facing text from your .storyboard and .xib files. • Use Auto Layout so views adjust to the localized text. • Use standard APIs to handle the complexity of different writing systems and locale formats. • If the app supports right-to-left languages, mirror the user interface and change the text direction as needed.
  4. 2. Localize Your App • Export and import the localizations

    using standard file formats. • Lock views in the user interface. • Export the localizations. • Submit the exported files to translators. • Import the localization files and confirm the changes. Perform additional localization steps yourself.
  5. 3. Test Your App • Detect Auto Layout problems and

    non-localized strings. Run your app using pseudo-languages. Pseudo-localization lets you test whether your app's UI adapts well for running in other languages. • As a rule, non-English languages are 30% longer, so small buttons and titles may not fit when you localize. Simulate right-to-left languages if internationalizing/localizing app for right-to-left languages. • Test specific languages and regions. • After importing localizations, test your app in all the languages you support.
  6. 4. Specify territories in iTunes Connect • Before you submit

    your localized app to the App Store, add territories and localize your metadata using iTunes Connect. • You should localize your app description. Also, make sure you have a list of search keywords for localization. They will help users find your app while searching its localized version in the App Store.
  7. Ayuna’s suggested workflow 1. Separate user facing text, export strings

    2. Send to translators 3. Test with pseudo-localization, find Auto Layout bugs 4. Internationalize 5. Import translations 6. Test 7. Ship
  8. User facing text & String formatting • Code strings •

    Storyboard & .xib strings • InfoPlist.Strings
  9. Code Strings • NSLocalizedString wrapper let termsOfServiceText = NSLocalizedString("Terms of

    Service", comment: “”) let privacyPolicyText = NSLocalizedString("Privacy Policy", comment: "Privacy Policy label text")
  10. Code Strings • NSLocalizedString wrapper let termsOfServiceText = NSLocalizedString("Terms of

    Service", comment: “”) let privacyPolicyText = NSLocalizedString("Privacy Policy", comment: "Privacy Policy label text") let text = String(format: NSLocalizedString("By joining, you agree to our %@ and %@.", comment: "The placeholders are for 'Terms of Service' and 'Privacy Policy'"), termsOfServiceText, privacyPolicyText)
  11. Code Strings • Don’t break strings into separate strings (lost

    context, not helpful for translators, declination & conjugation, word order)
  12. By joining, you agree to our %@ and %@. Comment:

    The placeholders are for 'Terms of Service' and 'Privacy Policy'
  13. /* The placeholders are for 'Terms of Service' and 'Privacy

    Policy' */ "By joining, you agree to our %@ and %@." = "En rejoignant Vimeo, vous acceptez nos %1$@ et %2$@."; /* The placeholders are for 'Terms of Service' and 'Privacy Policy' */ "By joining, you agree to our %@ and %@." = "En rejoignant, vous acceptez nos %1$@ et %2$@.";
  14. Code Strings • Keys vs strings let termsOfServiceText = NSLocalizedString("Terms

    of Service", comment: "") let termsOfServiceText = NSLocalizedString(“termsOfServiceLabel”, comment: "")
  15. /* Terms of Service */ "Terms of Service" = "Términos

    de servicio"; /* Terms of Service */ "termsOfServiceLabel" = "Términos de servicio";
  16. /* Localized versions of Info.plist keys */ "CFBundleDisplayName" = "Me

    Gusta"; /* Localized versions of Info.plist keys */ "CFBundleDisplayName" = "Мне Нра";
  17. Dev Comments • Button vs. label • Approx. or max.

    length • Use single quotation marks or params for placeholders /* Navigation bar title for Notifications settings screen.*/ "Notifications" = "ঌܿ"; /* The user can choose to sort search results for channels, users, or videos by Popularity.*/ "Popularity" = "ੋӝب"; /* Param 1: current page; Param 2: total count */ “currentPage.results.label” = "Showing %1d out of %2d results"; // “Showing 6 out of 12 results”
  18. NSNumberFormatter • Strings with numbers (number of users, followers, search

    results, etc.) • Decimal, thousands separator, currency, and percentage symbols. • Currency For example, the number 1,234.56 is formatted as 1.234,56 in Italy. Use the NSNumberFormatter class to create localized string representations of NSNumber objects.
  19. NSNumberFormatter let numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = .CurrencyStyle numberFormatter.currencyCode =

    “EUR” let cashString = numberFormatter.stringFromNumber(3.50) // 3.50€ or €3.50, depending on locale let numberFormatter = NSNumberFormatter() numberFormatter.numberStyle = .CurrencyStyle numberFormatter.currencyCode = “EUR” let cashString = numberFormatter.stringFromNumber(3.50) // 3.50€ or €3.50, depending on locale
  20. Wrong approach if n == 1 { secondString = “\(n)

    second” } else { secondString = “\(n) seconds” }
  21. Handling Noun Plurals and Units of Measurement • // NSLocalizedString

    localizedString = [NSString localizedStringWithFormat:NSLocalizedString(@"%d file(s) remaining", @"Message shown for remaining files"), count]; • // in Localizable.strings file /* Message shown for remaining files */ "%d file(s) remaining" = "%d file(s) remaining"; • Create a .stringsdict property list file and localize it for each language that has different plural rules. • Add the language-specific plural rules to each .stringsdict file.
  22. <plist version="1.0"> <dict> <key>%d file(s) remaining</key> <dict> <key>NSStringLocalizedFormatKey</key> <string>%#@files@</string> <key>files</key>

    <dict> <key>NSStringFormatSpecTypeKey</key> <string>NSStringPluralRuleType</string> <key>NSStringFormatValueTypeKey</key> <string>d</string> <key>one</key> <string>Остался %d файл</string> <key>many</key> <string>Осталось %d файлов</string> <key>other</key> <string>Осталось %d файла</string> </dict> </dict> </dict> </plist>
  23. Translations • Internal • External • Apple • Style Guide

    • Yourself Resources: iOS Glossary – common translations for iOS terms (Settings, Tap, etc.)
  24. Nota Bene! - Tell translators to follow the original capitalization

    & punctuation. - If working with Smartling, be careful with translation memory smart matching. Some string won’t show up.
  25. Detect Auto Layout Bugs • Detect Auto Layout problems and

    non-localized strings • As a rule, non-English languages are 30% longer, so small buttons and titles may not fit when you localize • Test on iPhone 4s • Simulate right-to-left languages if internationalizing/ localizing app for right-to-left languages
  26. Fix Auto Layout Bugs • Test with Double Length Pseudolanguages

    • Adjust based on the length of the strings • Preview in Assistant Editor
  27. Specify territories in iTunes Connect • Before you submit your

    localized app to the App Store, add territories and localize your metadata using iTunes Connect. • You should localize your app description. Also, make sure you have a list of search keywords for localization. They will help users find your app while searching its localized version in the App Store.
  28. Resources Documentation iOS Developer Library - Internationalization and Localization Guide

    WWDC Videos WWDC 2016: Internationalization Best Practices WWDC 2014: Localizing with Xcode Tutorials https://www.raywenderlich.com/64401/internationalizationtutorialforios2014 https://www.oneskyapp.com/academy/learnioslocalization/ http://blog.localize.io/step-by-step-ios-localization-tutorial/