Localize Plurals Without Building Sentences From Fragments
A download screen says “1 files ready.” The quick fix is an if count == 1 branch. The next fix adds another branch for zero, then a translated noun, then a different word order for another language.
The problem started before the grammar rule. The app split a sentence into pieces that only made sense in its original language.
Keep the sentence and its count together
Give the localization system the integer inside the whole message:
import SwiftUI
struct ReadyFiles: View {
let count: Int
var body: some View {
Text(
"\(count) files ready",
comment: "Number of completed files available to share.")
}
}
The comment tells a translator what “ready” means. These files have finished preparing and can be shared; the count is not the number still downloading. That distinction can affect the translation even when the English label looks interchangeable.
Avoid preformatting the count into a String and interpolating that instead. The original integer is what allows the message to vary by number. A display-ready string has already discarded the information the plural selection needs.
Also avoid joining Text(count) to a translated noun and a translated “ready.” A translator needs to reorder and inflect the complete sentence, not repair a sentence whose structure is fixed in Swift.
Configure the catalog deliberately
Apple’s string catalog guide describes extracting interpolated messages and adding plural variants. Build the target with a Localizable.xcstrings resource, find this message, and choose Vary by Plural for its numeric substitution.
For the English resource in this example, use:
| Category | Message |
|---|---|
| One | %lld file ready |
| Other | %lld files ready |
Keep the placeholder appropriate to the extracted integer. Do not replace it with a literal 1, and do not manually rename the extracted key to a different format without updating the call site.
When another language is added, fill the categories that Xcode presents for that language. The English pair is not a universal schema. Apple’s plural localization documentation explains why the available forms vary by language.
Decide whether zero is a different product state
Sometimes zero should say “No files ready.” Sometimes it means “Start an export,” with a different action and illustration. Those are different decisions.
A pluralized message is appropriate when the screen is reporting one quantity. A separate empty-state view is appropriate when the workflow itself changes. Keep that product decision in the view model instead of trying to make a noun variation secretly control navigation or buttons.
Do not assume every language treats zero like English. Ask translators to review the complete empty-state copy as well as the count-based message.
Test the resource that ships
A test of count == 1 ? "file" : "files" only proves your replacement rule. It says nothing about the catalog’s target membership, compiled entries, or actual lookup key.
Our companion fixture contains a real catalog with English and Spanish variants. It compiles the catalog with the installed Xcode tool:
xcrun xcstringstool compile Localizable.xcstrings --output-directory PluralFixture.bundle
The Swift fixture loads each compiled language directory explicitly and checks counts 0, 1, and 2 through String(localized:bundle:locale:). Explicit language bundles keep the resource test independent of this Mac’s preferred language list. In an app, also test the normal bundle lookup under the selected app language; choosing a formatting locale is not a substitute for verifying which translation bundle the app selected.
Include a larger count in UI review so grouping and longer translated text have room. Add the boundary values suggested by translators for languages with additional plural categories. A passing English screenshot cannot establish that those branches work.
September 2026 review: the example view and Foundation lookup compile with Swift 6.4. Xcode 27 compiled the companion catalog, and all six English/Spanish 0/1/2 resource assertions passed. Layout and additional language categories still require app-specific review.
The catalog should own the sentence’s grammatical alternatives. Swift should supply the meaning and the original numeric value.