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.

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%fAndroid%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

  1. Apple: String Format Specifiers, read November 9, 2026
  2. Android: java.util.Formatter, read November 9, 2026
  3. Apple: Localizing and varying text with a string catalog, read November 9, 2026
  4. Apple: String Resources, read November 9, 2026
  5. 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.

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.

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.

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\nAndroid 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&lt; and &amp;, 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

  1. Apple: String Resources, read November 9, 2026
  2. 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.

PushedWelcome, %@!StoredWelcome, [%s]!Pulled for iOSWelcome, %@!Pulled for AndroidWelcome, %s!
PushedWelcome, %s!StoredWelcome, [%s]!Pulled for iOSWelcome, %@!Pulled for AndroidWelcome, %s!
Pushed%lld resultsStored[%lli] resultsPulled for iOS%lld resultsPulled for Android%d results
Pushed%1$@ scored %2$lld pointsStored[%1$s] scored [%2$lli] pointsPulled for iOS%1$@ scored %2$lld pointsPulled for Android%1$s scored %2$d points
Pushed%.1f kmStored[%.1f] kmPulled for iOS%.1f kmPulled for Android%.1f km
Pushed100%% doneStored100%% donePulled for iOS100%% donePulled for Android100%% done

From one file to the other

Push the String Catalog, pull strings.xml.

  1. Step 1: Start from the catalog Xcode keeps

    Every language in one file, with %@ for text and %lld for 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"
    }
  2. 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.

    shell
    curl -fsS -X POST "https://anylocale.com/api/loc/push?project=my-app&format=xcstrings" \
        -H "Authorization: Bearer $ANYLOCALE_TOKEN" \
        --data-binary @Localizable.xcstrings
  3. Step 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.

    shell
    anylocale pull --project my-app --locale de \
        --format android-xml --out app/src/main/res/values-de/strings.xml
    app/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 %d already takes a long. The iOS file gets %lld back.
  • 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$s and 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 throws UnknownFormatConversionException on %@.
Why does %lld crash on Android?
In Java's formatter l is not a conversion, so %lld throws UnknownFormatConversionException. Java's %d already takes a long, 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 .stringsdict may add an optional zero, and iOS uses it for 0, while Android ignores zero in English even for 0. anylocale keeps the forms CLDR gives a language, so an English zero form 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$s on Android.
Can iOS and Android share one strings file?
Not one file: Xcode reads .xcstrings, or .strings with .stringsdict, and Android reads strings.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 %s in an Android file and %s becomes %@ in an iOS file, and %lld becomes %d for 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 \' in strings.xml. A double quote becomes \", a line break \n, and < and & become &lt; and &amp;.

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.