Convert CSV to PO: What the Conversion Changes and When It Is Worth Doing

A practical review of converting CSV to gettext PO files: what changes, where meaning can break, how to validate the result, and when plain CSV is better.

Converting CSV to PO usually means turning a spreadsheet of source strings and translations into a gettext Portable Object file, the plain-text format many software projects use for localization. This review covers that meaning only. "PO" is also short for purchase order, and turning CSV data into purchase orders is a different task that is not covered here.

Is CSV-to-PO conversion the right step?

It is a good fit when the strings are headed for a gettext-based workflow, such as a project that compiles PO files to binary MO files with msgfmt or a framework that reads PO directly. The main benefit is structure. A PO file can hold message context, plural forms, translator and developer comments, status flags such as fuzzy, and a header that declares the character encoding and plural rule. CSV has none of these as built-in concepts.

The decisive tradeoff is that gettext looks up translations by the exact source string (msgid), within its context. If the source column changes at all during spreadsheet editing or conversion, even by one trimmed space, a curly quote or a different Unicode normalization form, the translation silently stops matching and the original text is shown instead. The conversion is only worth doing if the source column reaches the PO file unchanged.

  • Plain CSV or a simple text list is preferable when:
  • The target system does not use gettext or PO files.
  • The goal is review or approval of wording by people outside the localization pipeline.
  • The data is a one-off list with no plurals, context or later updates from the code.
  • You cannot confirm the source strings match the program's strings exactly, because a PO file built on mismatched msgids gives a false sense of completeness.

What the conversion actually changes

This is a structural re-encoding of stored text, not a visual effect. Unlike reversed text, mirrored glyphs, Unicode "font" substitution or CSS styling, nothing about how the characters look should change. Each CSV row becomes a PO entry, columns are mapped to PO fields, and the quoting rules change: CSV escapes a double quote by doubling it, while PO uses C-style backslash escapes and writes line breaks as \n. A converter also adds a header entry, which is stored as an entry with an empty msgid.

CSV element | PO equivalent | What to check
Source text column | msgid | Must match the program's string exactly
Translation column | msgstr | An empty msgstr means untranslated, not "translate as blank"
Context column, if present | msgctxt | Identical source text with different context needs this to avoid duplicates
Notes or comments column | #. or # comment lines | Many converters drop unmapped columns
Doubled quotes inside a quoted field | Backslash-escaped quotes | Unescaped quotes break PO syntax
Line break inside a quoted field | \n plus concatenated string lines | Unquoted line breaks split a CSV row into two
File encoding | Content-Type charset in the header | The declared charset must match the actual bytes
Separate columns per plural form | msgid_plural and msgstr[0], msgstr[1] and so on | The number of forms must match the Plural-Forms header for the language

An illustrative example

The following input and output were written by hand to show the mapping. They are not the output of any particular converter, and real tools differ in column names, header fields and line wrapping.

context,source,target
,Save,Guardar
menu,Open,Abrir
,"He said ""hi""","Dijo ""hola"""
,"Line one
Line two","Línea uno
Línea dos"
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Language: es\n"

msgid "Save"
msgstr "Guardar"

msgctxt "menu"
msgid "Open"
msgstr "Abrir"

msgid "He said \"hi\""
msgstr "Dijo \"hola\""

msgid "Line one\n"
"Line two"
msgstr "Línea uno\n"
"Línea dos"

Checked against the mechanism: the doubled CSV quotes became backslash-escaped quotes, the embedded line break became \n with the remaining text on a continuation line that gettext concatenates, the row with a context value gained a msgctxt line, and the accented characters are unchanged. That last point holds only because the file is saved as UTF-8 and the header says so. No characters are reversed or reordered. Right-to-left translations, such as Arabic or Hebrew, are stored in logical order in both CSV and PO, and a correct conversion leaves that order alone; how the text is displayed is up to the editor or application.

Where conversions commonly go wrong

  • Encoding: a CSV saved from a spreadsheet may use a legacy code page or start with a byte order mark, while the PO header declares UTF-8.
  • Delimiters: some locales export semicolon-separated files under a .csv name, and TSV files often have no quoting rules at all, so tabs or line breaks inside text can shift columns.
  • Spreadsheet edits: autocorrect may turn straight quotes into curly ones, and cells can be reinterpreted as numbers, dates or formulas, which changes the source text.
  • Whitespace: trimming leading or trailing spaces alters the msgid, so the translation no longer matches.
  • Unicode normalization: a tool that converts between composed and decomposed forms of accented letters produces strings that look identical but do not match byte for byte.
  • Duplicates: two rows with the same source text and no distinguishing context produce duplicate entries, which msgfmt reports as an error.
  • Plurals: a single translation column cannot express plural forms, so plural strings need extra columns and a converter that supports them.
  • Blank translations: an empty target cell becomes an untranslated entry, and the program falls back to the source text.
  • Round trips: converting PO to CSV and back can drop comments, fuzzy flags, source references and obsolete entries, depending on the tool.

Will the result stay readable and usable after copying or sharing?

A PO file is plain text, so it opens in any text editor and survives copying as long as nothing rewrites it. The risks come from its syntax. Copying a msgstr into another application carries the literal backslash escapes, so \n and " appear as typed characters unless someone unescapes them. Pasting PO content through a word processor or a messaging app that converts straight quotes to curly ones will break the file. Searching for a phrase can also fail when the phrase is split across continuation lines.

The conversion does not alter reading order, so it creates no bidirectional or visual-order problems for assistive technology. A screen reader will, however, read the raw file as text, including keywords like msgid, comment markers and escape sequences, which makes the raw file harder to review that way than a table in a spreadsheet or a dedicated PO editor. No scoped test of a specific screen reader, editor or destination app was available for this review, so no claims are made about how particular products handle PO files.

Keep a plain-text equivalent when the people reading the strings are not working in the localization toolchain, such as stakeholders approving copy or reviewers relying on assistive technology. Exporting the same entries back to a clean CSV or a simple two-column list is usually easier for them than the PO file itself.

Validating a converted file

  • Run the file through msgfmt with checking enabled; it reports syntax errors, duplicate entries and header problems.
  • Compare the number of entries with the number of data rows in the CSV.
  • If the project has a POT template extracted from the code, use msgcmp to confirm that every msgid in your PO file exists in the template.
  • Spot-check rows containing quotes, line breaks, leading or trailing spaces, non-Latin scripts and plural forms.
  • Open the file in a PO editor or your translation platform to confirm it loads and shows the expected number of translated and untranslated entries.
msgfmt --check --statistics -o /dev/null messages.po
msgcmp messages.po template.pot

Choosing a converter

Options range from command-line tools, such as the csv2po and po2csv converters in the Translate Toolkit, to custom scripts and web-based converters. Whichever you use, check that it lets you map columns explicitly, reads and writes UTF-8, handles quoted fields with embedded line breaks, supports context and plural forms if you need them, and leaves the source text unmodified. For web-based converters, do not assume anything about privacy or data retention from the site's design or marketing language. Read the stated policy, and if it is unclear, avoid uploading unreleased product text or other confidential strings.

Evidence gaps

No specific converter, editor or destination was tested for this review, and no measurements, prices or product specifications were available. The guidance above rests on the documented structure of CSV and gettext PO files and the general behavior of gettext tools. Before relying on a particular converter, verify its behavior with a small sample containing the edge cases listed above.