Skip to content

Latest commit

 

History

History
16 lines (14 loc) · 2.23 KB

Localization.md

File metadata and controls

16 lines (14 loc) · 2.23 KB

Localization

How do we use it?

We use the localization tools and APIs provided by Apple, e.g. NSLocalizedString.

Key Considerations

  • All user-facing text should be made localizable with the NSLocalizedString family of APIs with corresponding Localizable.stringsdict files for plurals.
  • The key parameter of NSLocalizedString(_:comment:) should be the text as it appears in English. Do not use other constants or identifiers, like "button.log-in.forgot-password".
  • Always fill out the comment parameter of NSLocalizedString(_:comment:) with a detailed description of the text with enough information such that a translator could understand the text without further context. Add detailed descriptions of positional parameters, and when multiple parameters are present, refer to them in the text based on their position in the English translation.
    • Examples:
    NSLocalizedString("%d comments", comment: "Label displayed at the top of a thread. Parameter is the number of comments in the thread.")
    
    NSLocalizedString("Welcome to %@, %@!", comment: "Message shown at the top of the home screen after logging in. First parameter is the app name. Second parameter is the logged in user’s first name.")
  • When formatting numbers and dates for display, use the “localized” API variants, such as setLocalizedDateFormatFromTemplate(_:) and localizedString(from:dateStyle:timeStyle:).
  • Consider using String.variantFittingPresentationWidth(_:) when creating adaptive width Strings instead of using conditional logic.