CSV to Android strings.xml
Paste the translated sheet and, ideally, the default res/values/strings.xml it came from. Out comes the file for res/values-fr/ (or any other locale): every translation escaped the way Android's resource compiler expects, in the original order with the original comments, and strings nobody translated left out so the app falls back to the default language for them.
CSV to strings.xml
The CSV is read by its header: name, type, index and the translation column — translation by default, or any other name you type, so a sheet with one column per language (fr, de, pl…) produces each file in turn.
How to use it
- Paste or drop the translated CSV on the left. It is normally the file strings.xml to CSV produced, with the
translationcolumn filled in. - Paste or drop the default
res/values/strings.xmlon the right. - Check the status line and the list under the panes, then save the result as
res/values-<locale>/strings.xml.
With the original file (recommended)
- The output keeps the original's order, comments, indentation, the
xmlns:xliffdeclaration and every attribute on every resource (formatted="false",tools:ignore…). Only the text changes. - A string's text is rewritten in the same form it had: a string with tags in it is parsed as markup, so
<b>and<xliff:g>come back as elements; a string that was a CDATA section is written as CDATA again. - Strings without a translation are left out. Android's localisation guide describes what happens then: when a string is missing from the locale's file, the app falls back to the default
res/values/strings.xml. Choose keep the source text to copy them over instead. - A string-array keeps its length: if only some items are translated, the rest keep the source text and are listed under the panes.
- Plurals take the quantities the translation needs. A row for
fewormanythat the original does not have is added in the standard order (zero, one, two, few, many, other); a quantity left empty is removed. - Resources marked
translatable="false"are dropped (untick the box to keep them), and so are resources that are not strings, such as dimensions and colours — this tool writes strings only. Rows that match nothing in the original are listed rather than guessed at.
Without it
Leave the right pane empty and a fresh <resources> file is built from the CSV alone, in row order, with the comment column written as XML comments. A cell containing tags is treated as markup; anything else as plain text. Use this when the template is not to hand, and compare the result with the original before shipping it.
Escaping, applied
The translation column holds plain text, and the output escapes it the way Android's documentation describes: ' becomes \', " becomes \", a backslash is doubled, line breaks and tabs become \n and \t, and a value that starts with @ or ? gets the \@ / \? escape from the same table — a leading @ is how a reference such as @string/app_name is written. Text whose spacing would otherwise collapse — leading or trailing spaces, two spaces in a row — is wrapped in double quotes, the documented way to preserve it. Then XML escaping is applied on top (&, <).
FAQ
Does a round trip change my file?
Export a strings.xml to CSV, choose keep the source text, and build it again: every string has the same decoded text as before. The escaping can be spelled differently — "Don't" may come back as Don\'t — which Android reads as the same string.
Format arguments like %1$s?
They are ordinary text to this tool and are copied as written. Make sure the translation keeps every argument the source has; wrapping them in <xliff:g> in the default file tells translators not to touch them.
My spreadsheet uses semicolons.
Comma, semicolon and tab delimiters are detected from the header row.
Related tools
- strings.xml to CSV — make the sheet in the first place
- CSV to XLIFF — the same merge for XLIFF files
- XML Diff — compare the translated file with the default one
- XML Formatter — re-indent a file built without a template
Privacy
100% client-side. Both files are read and combined in your browser; nothing is uploaded. See the privacy policy.