Skip to content

Localization

Daniel Jilg edited this page Oct 4, 2019 · 7 revisions

Localization works as described in the Apple Documentation or this helpful tutorial. Strings files are included in the project and can be exported to and imported from Xliff files if necessary for translation by external translation agencies.

Strings files live in the Translations directory,

To test localization, you can edit your currently active scheme, and in "Options", set the "Application Language". Don't commit this change please.

Adding new Strings

1. Add to Strings.swift

Do not put NSLocalizedString instances directly into your code please. Instead, add the to Strings.swift. Check if there is already a section there where your strings fit in well, and if not add one. Sections should look like below. Don't forget the tableName parameter.

Localized Strings should use keys that describe a path to where they can be found, like HomePanel.ContextMenu.OpenInNewTab. Do not use "Open in New Tab" as a key!

// Home Panel Context Menu.
extension Strings {
    public static let OpenInNewTabContextMenuTitle = NSLocalizedString("HomePanel.ContextMenu.OpenInNewTab" tableName: "UserAgent", comment: "The title for the Open in New Tab context menu action for sites in Home Panels")
    public static let OpenInNewPrivateTabContextMenuTitle = NSLocalizedString("HomePanel.ContextMenu.OpenInNewPrivateTab" tableName: "UserAgent", comment: "The title for the Open in New Private Tab context menu action for sites in Home Panels")
    // ...
}

2. Add to UserAgent.strings

Add your keys and translations to UserAgent.strings. If you don't speak all available languages, ask a coworker or create a ticket if no one is available.

Clone this wiki locally