Contents

numericFormat

A string representing a count for the type, e.g. “2 books”.

Declaration

var numericFormat: LocalizedStringResource?

Discussion

In your numericFormat implementation, use StringInterpolation placeholders and provide a .stringsdict file with all possible pluralizations for the type, such as “0 books”, “1 book”, and “2 books”.

Example:

TypeDisplayRepresentation(
    name: LocalizedStringResource("Book"),
    numericFormat: LocalizedStringResource("\(placeholder: .int) books")
)
<dict>
   <key>Book</key>
   <dict>
     <key>NSStringLocalizedFormatKey</key>
     <string>%#@VARIABLE@</string>
     <key>VARIABLE</key>
     <dict>
       <key>NSStringFormatSpecTypeKey</key>
       <string>NSStringPluralRuleType</string>
       <key>one</key>
       <string>Book</string>
       <key>other</key>
       <string>Books</string>
     </dict>
   </dict>
   <key>%lld books</key>
   <dict>
     <key>NSStringLocalizedFormatKey</key>
     <string>%#@count@</string>
     <key>count</key>
     <dict>
       <key>NSStringFormatSpecTypeKey</key>
       <string>NSStringPluralRuleType</string>
       <key>NSStringFormatValueTypeKey</key>
       <string>lld</string>
       <key>zero</key>
       <string>%lld books</string>
       <key>one</key>
       <string>%lld book</string>
       <key>other</key>
       <string>%lld books</string>
     </dict>
   </dict>
 </dict>