Xcode i18n

Xcodei18n

Vorbereitungen

  1. Select Project -> Info -> Localisation: Gewünschte hinzufügen
  2. Select Project -> Product -> Export Localisation (From MainMenu)
  3. Open xliff file with appropriate app
  4. Translate
  5. Editor -> Import

Coding

String(localized: "YOUR_LOCALIZED_KEY")
NSLocalizedString("Abenteuer", comment: "") String(format: NSLocalizedString("%d Units in: %@", comment: ""), inventoryItem.amount, inventoryItem.place.title)

Pluralisation

String.localizedStringWithFormat(NSLocalizedString("%d unit(s) in: %@", comment: "Message for stock in place"), self.amount, self.place.title) 1. Neue plist erzeugen und in "Localizable.stringsdict" umbenennen 2. Vorlage verwenden 3. Stringsdict localisieren

Vorlage:

<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 file remaining</string> <key>other</key> <string>%d files remaining</string> </dict> </dict> </dict> </plist>

Referenzen:

Meta data

Xcode i18n
Date
March 21, 2020
over 4 years ago
Language
de
Updated on
October 19, 2024