Import Polylang translations from CSV / XML

Import WP’s Polylang add-on allows you to easily import Polylang translations to post types from XML / CSV files.

Import Polylang translations from CSV or XML files

The Import WP Polylang add-on adds a new section to the “Template Fields” step of the import creation page labelled “Polylang”, by all Polylang fields are hidden, but can be enabled via the Enable Fields button shown at the bottom of the section.

The “Language” field is used to set the current translation language of the object being imported, this can be populated via the dropdown containing a list of all active languages, or can be dynamically populated via a value from the CSV or XML file.

The “Translation” field is used to connect translations together, this can be linked using the Post ID, Post Slug, Post Name, or referencing a value in your CSV or XML file.

Import Polylang translations to posts, pages and custom post types.

When importing Polylang custom post type translations make sure you have enabled the custom post type to allow translations in Polylang (by default pages and posts are enabled), otherwise the Polylang section will not appear in Import WP. To enable the custom post type for translating, go to “Languages > Settings > Custom post types and Taxonomies” and make sure the post type is selected with changes saved.

The following CSV example shows the minimum columns required to import Polylang translations into WordPress posts with translated title and content fields, the important columns to note are the language and translation columns.

Page oneExample page one contenten
Page unExemple de contenu de la première pagefrPage one
Pagina unoEsempio di contenuto della prima paginaitPage one
Page twoExample page two contenten
Pagina dueEsempio di contenuto della seconda paginaitPage two
Page deuxExemple de contenu de la page deuxfrPage two
Example Polylang translation csv file

The “Language” column uses the 2-letters ISO 639-1 code and is used to set the current posts language while also being used as a reference in the translation field.

Setting the language and translation fields on the “Polylang” Section, setting the “Translation Field Type” to “Name”, as the “Translation” column in this example references a post by its title/name.

Filling out the rest of the post template fields, setting the title, content and post status to the relevant CSV columns allows the translations to be created and referenced during the import.

Using the default permissions and running the importer, you should see the following available posts, each showing with their related translations that can be edited via the pencil icon under its flag.

Polylang translations import using a reference column

Import WP’s Polylang add-on allows you to use a reference column when selecting how translations are related via the “Translation Field Type” field.

Using a similar example CSV file, with extra ID and Translation ID columns, the ID is not the post ID, from the example you can see the first 3 rows are grouped using the Translation ID, and the group matches up to a row in the ID column.

IDTitleContentLanguageTranslation ID
1Page oneExample page one contenten1
2Page unExemple de contenu de la première pagefr1
3Pagina unoEsempio di contenuto della prima paginait1
4Page twoExample page two contenten4
5Pagina dueEsempio di contenuto della seconda paginait4
6Page deuxExemple de contenu de la page deuxfr4
Example Polylang translation with reference column csv file

The “Translation Field Type” allows us to select a value and have that value be referenced against another column in the CSV file, with the example CSV we set the “Translation” field to the Translation ID Column, and set the “Translation Reference Column” to the ID Column.