File formats

.NET resx

.NET XML resource files (.resx): string data entries, read and written for ResourceManager and IStringLocalizer.

FormatIdentifierExtension
.NET resxresx.resx
Resources/Strings.fr.resx
<?xml version="1.0" encoding="utf-8"?>
<root>
  <resheader name="resmimetype">
    <value>text/microsoft-resx</value>
  </resheader>
  <data name="HomeTitle" xml:space="preserve">
    <value>Bon retour</value>
  </data>
  <data name="Greeting" xml:space="preserve">
    <value>Bonjour, {0} !</value>
  </data>
</root>

Keys

The root element must be <root>. Each string <data> element is a key: name is the key name and the text of <value> is the translation.

  • Only string resources are read. A <data> with a type attribute (an image, an icon) or a mimetype attribute (base64 binary) is skipped.
  • <resheader>, <metadata>, <assembly> and the <xsd:schema> block are skipped.
  • A <data> without name or without <value>, or a name that appears twice, is an error.
  • XML entities decode as usual, and xml:space="preserve" is honoured, so leading and trailing spaces in a value are kept.
  • <comment> elements are not imported. Keep descriptions in the console.
  • A DOCTYPE with its own declarations is rejected.

Plurals

ResX has no plural construct. Plural keys are left out of an export.

Placeholders

Composite format items such as {0} and {1:N2} are kept as written. See Placeholders.

Export

An export is a minimal ResX file: the four standard <resheader> entries (resmimetype text/microsoft-resx, version 2.0, and the System.Resources reader and writer), then one <data name="..." xml:space="preserve"> per key in byte order, two-space indented. It has no <xsd:schema> block.

Carriage returns are written as &#13;, and control characters XML cannot represent are replaced with U+FFFD, so the file is always well-formed. Resources other than strings in your original file (images, binary data) are not part of an export, so keep them in a separate .resx.

On this page