XML format
Android strings
Android's translatable string resources, where apostrophes must be escaped and placeholders need XLIFF markup to survive translation.
res/values/strings.xml holds an Android app's user-visible text, with one file per locale. It is the source document for every translation workflow an app has, which is why it borrows from XLIFF: <xliff:g> marks the runs a translator must not touch, such as format specifiers and product names.
The escaping rules catch people out more than the structure does. Android applies its own layer of escaping on top of XML's, so an apostrophe in ordinary prose has to be escaped with a backslash even though XML is perfectly happy with it — and the failure is a build error in a file that looks correct.
- Apostrophes and double quotes need a backslash escape, on top of XML escaping. A bare ' is a resource compiler error.
- A string with more than one format specifier must number them (%1$s, %2$s) so translators can reorder them.
- Wrap anything that must not be translated in <xliff:g id="…">, or it will come back localised.
- Mark strings that should not be sent for translation with translatable="false".
- An @ or ? at the start of a value is a resource reference; escape it with a backslash to use it literally.
- Root element
<resources>- Media type
application/xml- Extensions
.xml- Namespaces
urn:oasis:names:tc:xliff:document:1.2
- XMLDir label
- —
Specification: Android string resources
A minimal valid document
Every example on this site is checked against the same parser the workspace uses, so what you see below is known to be well-formed.
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" translatable="false">Example</string>
<string name="greeting">Hello, <xliff:g id="name" example="Ada">%1$s</xliff:g>!</string>
<string name="cannot_open">Can\'t open that file</string>
<plurals name="items">
<item quantity="one">%1$d item</item>
<item quantity="other">%1$d items</item>
</plurals>
</resources>Other formats
- XML sitemap
- Sitemap index
- RSS 2.0
- Atom 1.0
- SOAP envelope
- XML Schema (XSD)
- WSDL
- XSLT stylesheet
- SVG
- OPML
- RDF/XML
- GPX
- KML
- XLIFF
- UBL Invoice
- JUnit XML
- Maven POM
- SAML 2.0
- Property list
- DocBook 5
- JATS article
- MusicXML 4.0
- MathML
- XSL-FO
- OOXML document
- Android manifest
- MSBuild project
- Log4j 2 config
- JaCoCo report
- Checkstyle report
- EPUB package
- XMP metadata
- TEI document
- ISO 20022 pain.001
- HL7 CDA
- TTML captions
- OpenStreetMap XML
Get started
Bring order to the XML your team can't afford to ignore.
Create a free account and get a private workspace to search, validate, diff, and monitor your XML feeds, sitemaps, schemas, and vendor integrations.