Plural support in Mac and iOS using Localizable.stringsdict

Show/hide this tutorial

Starting in OS X 10.9 and iOS 7, Apple added plural support for localized strings. Rejoice! That means you no longer need to code:

   		 value: "Remove %ld selected file",
   		 comment: "Confirmation dialog text"),

if (count > 1) {// logic to add an "s" for plurals ...

This approach barely works for English and is a huge mess in other languages. Did you know most languages have very different rules for making words plural than English? Take a look at the official Unicode list of plural rules here. Hopefully one glance is enough to convince you that using Apple's built-in solution is best for your sanity and your users'.

Create just %i string(s) instead

The long-term solution to plurals on iOS and Mac is to create just one string:

NSLocalizedStringWithDefaultValue(@"remove.files.dialog" // Unique key of your choice
			, @"Localizable", // .strings file name 
			, [NSBundle mainBundle] // Default bundle
			, @"Remove %ld selected file(s)" // Default (English) text
			, @"Confirmation dialog text" // comment for translator
NSLocalizedString("remove.files.dialog", // Unique key of your choice
		value:"Remove %ld selected file(s)", // Default (English) text
		comment:"Confirmation dialog text") // comment for translator
This is a versatile, localizable string that we can pair with a Localizable.stringsdict file. What's that? Stringsdict is a dictionary (plist) that stores all plural forms of the string. You only have to provide the English. Your translators will provide all the forms necessary for their language. Like magic, it *just works* at run time! The Localizable.stringsdict file looks like this:

While that looks like a lot of work, it isn't. We've built a Localizable.stringsdict generator for you below!
Just choose your strings and type in the singular and plural forms.

Stringsdict is the only way to do plurals correctly for multiple languages, which have different plurals when the number ends in 2-4, or multiples of 10, fractions, or other crazy things you never expected. These have been systematically divided into named categories: one, two, few, many, other, and so on. Don't worry though: your translators will know the difference between few and many if it applies to their language. Some languages, including many Asian languages, have no plurals at all.

Note a couple of cool things from the Remove %ld selected files example above that works in English too. We can easily add precise languages for cases like zero: No files selected or remove the number completely for one: Remove selected file.

Show/hide this tutorial


Start by importing your .strings, en.xliff or .stringsdict file here.

Localizable.stringsdict BETA Automatic variables (simpler) Add blank string

Or create a .stringsdict file from scratch.

Advanced export options Already got a stringsdict? Drag it to the box. Imports automatically.
Save the text above and name the file: Localizable.stringsdict