Guides
Share strings between iOS and Android: %@ vs %s, plurals and escaping
One sentence, two dialects. Where Apple's and Android's format strings, plurals and escaping differ, from each platform's own documentation, and how one catalog can write each file in its own dialect.
Placeholders
The same argument, spelled twice.
iOS formats with Foundation's specifiers, Android with Java's Formatter. Most letters agree; the two that matter most do not.
| Topic | iOS | Android |
|---|---|---|
| Text[1][2] | iOS%@, for an object such as a string. %s reads a C string, and Apple advises against it. | Android%s |
| Integer[1][2][3] | iOS%d for 32 bits, %lld for 64. Xcode writes %lld for an interpolated integer. | Android%d, which takes an int or a long. |
| Decimal[1][2] | iOS%f | Android%f |
| Literal percent sign[1][2] | iOS%% | Android%% |
| Numbered arguments[2][4][5] | iOS%1$@, %2$lld. A translation can put them in another order. | Android%1$s, %2$d. |
| The other platform's spelling[1][2] | iOS%s is read as a C string, not as the string object you passed. | Android%@ and %lld throw UnknownFormatConversionException: neither @ nor l is a conversion. |
Sources
- Apple: String Format Specifiers, read November 9, 2026
- Android: java.util.Formatter, read November 9, 2026
- Apple: Localizing and varying text with a string catalog, read November 9, 2026
- Apple: String Resources, read November 9, 2026
- Android: String resources, read November 9, 2026
Plurals
One idea, three containers.
Both platforms pick a form by the language's plural rules. Where the forms are written down differs.
| Topic | String Catalog | .stringsdict | Android |
|---|---|---|---|
| Where the forms live[1][2][3] | String CatalogA plural variation on the key, per language, added with Vary by Plural. | .stringsdictA dictionary per variable, referenced from NSStringLocalizedFormatKey as %#@name@. | AndroidA <plurals> resource with one <item quantity> per form. |
| Which forms[1][2][3] | String CatalogXcode adds the forms each language needs: one and other for English; one, few, many and other for Russian. | .stringsdictKeys named zero, one, two, few, many and other. other is required; in English zero is optional, and used for 0 when it is there. | Androidzero, one, two, few, many and other, used only where the language needs them: English ignores zero even for 0. |
| The count[1][2][3] | String Catalog%lld, which Xcode picks for an interpolated integer. | .stringsdictThe specifier named in NSStringFormatValueTypeKey, such as d. | Android%d in the item, with the count passed twice: once to pick the form, once to fill it in. |
Sources
- Apple: Localizing and varying text with a string catalog, read November 9, 2026
- Apple: Localizing strings that contain plurals, read November 9, 2026
- Android: String resources, read November 9, 2026
Escaping
What needs a backslash.
Apple's page names three things a .strings value escapes with a backslash, as in C: double quotes, the backslash itself and control characters. strings.xml is XML first and Android's own escapes second.
| Topic | iOS .strings | Android strings.xml |
|---|---|---|
| Double quote[1][2] | iOS .strings\" | Android strings.xml\" |
| Backslash[1][2] | iOS .strings\\ | Android strings.xml\\. The page gives it no row of its own, but a backslash is how Android escapes. |
| Line break[1][2] | iOS .strings\n | Android strings.xml\n |
| Apostrophe[1][2] | iOS .stringsNot covered by Apple's page. | Android strings.xml\', or the whole string wrapped in double quotes. |
@ and ?[1][2] | iOS .stringsNot covered by Apple's page. | Android strings.xml\@ and \? |
< and &[1][2] | iOS .stringsNot covered by Apple's page. | Android strings.xml< and &, by the XML rules. |
| Runs of spaces[1][2] | iOS .stringsNot covered by Apple's page. | Android strings.xmlCollapsed to one space, unless that part of the string is in double quotes. |
Sources
- Apple: String Resources, read November 9, 2026
- Android: String resources, read November 9, 2026
anylocale
One spelling stored, each dialect written.
anylocale stores every argument in one spelling, so %@ from iOS and %s from Android are the same placeholder to a translator. Each pull writes the dialect of the file it produces. Numbering, flags, width and precision are kept.
| Pushed | Stored | Pulled for iOS | Pulled for Android |
|---|---|---|---|
PushedWelcome, %@! | StoredWelcome, [%s]! | Pulled for iOSWelcome, %@! | Pulled for AndroidWelcome, %s! |
PushedWelcome, %s! | StoredWelcome, [%s]! | Pulled for iOSWelcome, %@! | Pulled for AndroidWelcome, %s! |
Pushed%lld results | Stored[%lli] results | Pulled for iOS%lld results | Pulled for Android%d results |
Pushed%1$@ scored %2$lld points | Stored[%1$s] scored [%2$lli] points | Pulled for iOS%1$@ scored %2$lld points | Pulled for Android%1$s scored %2$d points |
Pushed%.1f km | Stored[%.1f] km | Pulled for iOS%.1f km | Pulled for Android%.1f km |
Pushed100%% done | Stored100%% done | Pulled for iOS100%% done | Pulled for Android100%% done |
From one file to the other
Push the String Catalog, pull strings.xml.
Step 1: Start from the catalog Xcode keeps
Every language in one file, with
%@for text and%lldfor an interpolated integer.Localizable.xcstrings{ "sourceLanguage" : "en", "strings" : { "cart_items" : { "localizations" : { "de" : { "variations" : { "plural" : { "one" : { "stringUnit" : { "state" : "translated", "value" : "%lld Artikel" } }, "other" : { "stringUnit" : { "state" : "translated", "value" : "%lld Artikel" } } } } }, "en" : { "variations" : { "plural" : { "one" : { "stringUnit" : { "state" : "translated", "value" : "%lld item" } }, "other" : { "stringUnit" : { "state" : "translated", "value" : "%lld items" } } } } } } }, "score_summary" : { "localizations" : { "de" : { "stringUnit" : { "state" : "translated", "value" : "%1$@ hat %2$lld Punkte erzielt" } }, "en" : { "stringUnit" : { "state" : "translated", "value" : "%1$@ scored %2$lld points" } } } }, "start_button" : { "localizations" : { "de" : { "stringUnit" : { "state" : "translated", "value" : "Los geht's!" } }, "en" : { "stringUnit" : { "state" : "translated", "value" : "Let's go!" } } } }, "welcome_title" : { "localizations" : { "de" : { "stringUnit" : { "state" : "translated", "value" : "Willkommen, %@!" } }, "en" : { "stringUnit" : { "state" : "translated", "value" : "Welcome, %@!" } } } } }, "version" : "1.0" }Step 2: Push the source file
The push is additive: keys missing from the file stay in place, so a truncated file cannot empty a project. Descriptions in the file become translator notes.
shellcurl -fsS -X POST "https://anylocale.com/api/loc/push?project=my-app&format=xcstrings" \ -H "Authorization: Bearer $ANYLOCALE_TOKEN" \ --data-binary @Localizable.xcstringsStep 3: Pull one locale
One file in the android-xml format, written to the path you name. Repeat per locale, or script it over the project's locale list.
shellanylocale pull --project my-app --locale de \ --format android-xml --out app/src/main/res/values-de/strings.xmlapp/src/main/res/values-de/strings.xml<?xml version="1.0" encoding="utf-8"?> <resources> <plurals name="cart_items"> <item quantity="one">%d Artikel</item> <item quantity="other">%d Artikel</item> </plurals> <string name="score_summary">%1$s hat %2$d Punkte erzielt</string> <string name="start_button">Los geht\'s!</string> <string name="welcome_title">Willkommen, %s!</string> </resources>
Good to know
- Each language gets the plural forms CLDR gives it: Russian gets one, few, many and other, and Japanese only other.
- The integer width doesn't make the trip to Android, because Java's
%dalready takes along. The iOS file gets%lldback. - A translation that drops or changes a placeholder is flagged when it is saved, before anyone verifies it.
- A sentence with two counts uses named variables, such as
%#@days@. The Android file gets a<string>that takes each count as%1$s,%2$sand so on, plus one<plurals>per variable, named after the key and the variable. - Number the arguments when a string has more than one. The numbering is written as you gave it, never added, and a
formatted="false"attribute is not kept.
Questions
- What is the Android equivalent of %@?
%s. Java's formatter has no@conversion and throwsUnknownFormatConversionExceptionon%@.- Why does %lld crash on Android?
- In Java's formatter
lis not a conversion, so%lldthrowsUnknownFormatConversionException. Java's%dalready takes along, so the Android spelling is%d. - Do iOS and Android use the same plural forms?
- The same six names: zero, one, two, few, many and other. English needs one and other, Russian one, few, many and other. They part on
zero: an English.stringsdictmay add an optionalzero, and iOS uses it for 0, while Android ignoreszeroin English even for 0. anylocale keeps the forms CLDR gives a language, so an Englishzeroform is not kept; give that text a key of its own. - How do I let a translation reorder the arguments?
- Number them. Both platforms read
%1$and%2$, so a translation can write%2$@ … %1$@on iOS and%2$s … %1$son Android. - Can iOS and Android share one strings file?
- Not one file: Xcode reads
.xcstrings, or.stringswith.stringsdict, and Android readsstrings.xml. Keep one catalog and write each platform's file from it..xcstringsstrings.xml - Does anylocale change my placeholders?
- Only where the target spells them differently.
%@becomes%sin an Android file and%sbecomes%@in an iOS file, and%lldbecomes%dfor Android. Numbering, flags, width and precision are kept. - What happens to an apostrophe from an iOS string?
- It is stored as typed and written as
\'instrings.xml. A double quote becomes\", a line break\n, and<and&become<and&.
Related guides
- Translate .xcstrings String CatalogsPush and pull an Xcode string catalog, plurals and all.Read the guide
- Translate Android strings.xmlRound-trip Android resources, escaping and plurals included.Read the guide
- Translate .stringsdict pluralsRound-trip the plurals that sit beside those singulars.Read the guide
- iOS localization in Xcode and SwiftUILocalize a target through the string catalog it already has.Read the guide
- Android localization with strings.xml and ComposeLocalize a module through its own resource files.Read the guide
Start with the file your app already ships.
After checkout, import one strings file and read the first drafts within minutes.
Nothing to connect and nothing to install. The CLI is optional.
Apple, iOS and Xcode are trademarks of Apple Inc. Android is a trademark of Google LLC. anylocale is not affiliated with or endorsed by Apple or Google.