Import WPML translations from CSV / XML
Import WP’s WPML add-on extends Import WP and allows you to easily import WPML translations to post types from any xml or csv file.
Table of Contents
Import WPML translations from XML or CSV files
The Import WP WPML add-on adds a new section to the “Template Fields” step of the import creation page labelled “WPML”, by default all WPML 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 to WPML, 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 WPML translations to posts, pages and custom post types.
When importing WPML custom post type translations make sure you have enabled the custom post type to allow translations in WPML To enable the custom post type for translating, go to “WPML > Settings > Post Type Translation”.
The following CSV example shows the minimum columns required to import WPML translations into WordPress posts with translated title and content fields, the important columns to note are the language and translation columns.
ID | Title | Content | Language | Translation | Translation ID |
---|---|---|---|---|---|
1 | Page one | Example page one content | en | ||
2 | Page un | Exemple de contenu de la première page | fr | Page one | 1 |
3 | Pagina uno | Esempio di contenuto della prima pagina | it | Page one | 1 |
4 | Page two | Example page two content | en | ||
5 | Pagina due | Esempio di contenuto della seconda pagina | it | Page two | 4 |
6 | Page deux | Exemple de contenu de la page deux | fr | Page two | 4 |
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 “WPML” 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.