Generate: Multilingual Content: Polylang

Overview

Page Generator Pro is compatible with Polylang, allowing you to generate content in multiple languages.

To achieve this, you’ll need to:

  • Setup Polylang, to define the Languages to use on your WordPress web site,
  • Define Keyword(s), with Terms in the languages that you wish to generate content for,
  • Define Content Groups for each Language,
  • Link Content Groups, so that Polylang knows, for each language, which Content Group to use,
  • Generate Content from each Content Group

Enable Polylang Languages

With the Polylang Plugin activated, define the languages you want to use on your web site by navigating to WordPress Admin > Languages
Page Generator Pro: Polylang: Languages Menu

Using the Add new language option to define the supported languages:
Page Generator Pro: Polylang: Add New Language

A list of enabled languages is displayed on the right hand side of the screen:
Page Generator Pro: Polylang: Enabled Languages

Enable Polylang on Content Groups

Navigate to WordPress Admin > Languages > Settings
Page Generator Pro: Polylang: Settings Menu

Click Settings below the Custom post types and Taxonomies option:
Page Generator Pro: Polylang: Custom Post Types Settings Menu

Tick / enable the Content Groups option, and click Save Changes
Page Generator Pro: Polylang: Settings: Custom Post Types

For the rest of this Documentation, we’ll assume you have two languages setup:

  • English
  • Spanish

Define Keywords

Refer to the Keywords documentation for full instructions on adding and editing Keywords.  The below is a guide specific to multilingual WordPress installations.

Adding Keywords

To add a Keyword to Page Generator Pro:

  1. Click the Add Keyword button below the Page Generator Pro: Keywords title, which can be found towards the top of the screen:
    Page Generator Pro: Import CSV
  2. The Keywords form will then be displayed, where you can define the following options:
    Page Generator Pro: Keyword Form

    1. Keyword: the unique template tag you’ll use when generating Pages / Posts / Custom Post Types.
      1. The Keyword must be unique from any other Keywords that you might have already defined.
      2. Make sure to only use letters, numbers and underscores.  Spaces and other characters will not work.
    2. Terms:  list the words or phrases that will be cycled through when generating content containing this Keyword, comma separated for each language that is supported on your web site.  Each word or phrase must be on its own line.
    3. Delimiter: Use the comma symbol (,)
    4. Columns: the comma separated list of languages the above Terms are in.

For example, if we’re defining a {service} Keyword for Web Design and Web Development in English and Spanish, we’d enter the following information:

Setting Value
Keyword service
Terms Web Design,Diseño web
Web Development,Desarrollo web
Delimiter ,
Columns english,spanish

Page Generator Pro: Polylang: Keyword

When you’re finished, click the Save button.

A notification will be displayed confirming that the Keyword saved successfully.
Page Generator Pro: Keywords: Success Notification

Editing existing Keywords

To edit an existing Keyword, click the Keyword name in the Keyword table.
Page Generator Pro: Keywords: Edit

In the Keywords form that is then displayed, define the Terms in each of the languages that you have enabled in Polylang.

For example, if we’re editing an existing {service} Keyword, that has Terms in English for Web Design and Web Development, we’d enter the following information:

Setting Value
Keyword service
Terms Web Design,Diseño web
Web Development,Desarrollo web
Delimiter ,
Columns english,spanish

Define Content Groups

Refer to the Generate Content documentation for full instructions on adding and editing Content Groups.  The below is a guide specific to multilingual WordPress installations, and assumes you understand Content Groups.

For each language enabled in Polylang, you’ll need to create a Content Group, defining its language in Polylang’s options.

If you’ve already produced Page(s) in one language outside of Page Generator Pro i.e. manually, you’ll need to put that content into one of the Content Groups, and delete the manually created Pages.  For mappings between languages and Content Groups to work, all content for the section of your site in question must be controlled by Page Generator Pro.

To add a new Content Group to Page Generator Pro, click the Add New button below the Content Groups title, which can be found towards the top of the screen:
Page Generator Pro: Generate Content:

You will then be presented with a screen similar to the one used to edit your WordPress Posts and Pages:
Page Generator Pro: Polylang: Content Groups: Add New

Define your Title, Content and other settings as you would for a Content Group, specific to the language that this Content Group is for.  For example:

  • English: You’d write the content in English, using the {service(english)} Keyword
    Page Generator Pro: Polylang: Content Groups: English
  • Spanish: You’d write the content in Spanish, using the {service(spanish)} Keyword
    Page Generator Pro: Polylang: Content Groups: Spanish

In Polylang’s Languages option, set the Language dropdown to match the language the content is in.  For example:

  • English:
    Page Generator Pro: Polylang: Content Groups: English Language Dropdown
  • Spanish:
    Page Generator Pro: Polylang: Content Groups: Spanish Language Dropdown

Once you have completed all fields either:

  • Click the Save button, if available in the Actions meta box,
  • Click the Publish / Update button, if using Gutenberg.

Repeat this process for each language enabled in Polylang, so that you end up with one Content Group for each language:
Page Generator Pro: Polylang: Content Groups: Table

Next, edit the primary language Content Group.  In Polylang’s Languages option, set the Translations field(s) to match the Content Group providing content in that language.  For example, if we’re editing the English Content Group:

  • We’re asked to provide the Spanish Content Group Translation:
    Page Generator Pro: Polylang: Content Groups: Spanish Translation Field
  • Start typing the Spanish Content Group’s Title in this field:
    Page Generator Pro: Polylang: Content Groups: Select Spanish Content Group
  • Select the Spanish Content Group when it appears:
    Page Generator Pro: Polylang: Content Groups: Selected Spanish Content Group

Once you have completed this, either:

  • Click the Save button, if available in the Actions meta box,
  • Click the Publish / Update button, if using Gutenberg.

Generate Content

Refer to the Generate: Run and Actions documentation for full instructions on generating content.  The below is a guide specific to multilingual WordPress installations.

With our Content Groups complete, we can now generate content for each language.

For the primary language Content Group, click the Generate via Browser option.  For example, if English is our primary language, we’ll do this for the English Content Group:
Page Generator Pro: Polylang: Generate Primary Language

A screen will display showing the progress as each Page is generated, along with the time it took and the server memory usage:
Page Generator Pro: Polylang: Generate Primary Language: Log

Once generation is complete, repeat this step for each additional language’s Content Group.  For example, we’ll do the same for the Spanish Content Group:
Page Generator Pro: Polylang: Generate Additional Language: Log

If we click the first link in the log, we’re taken to the Spanish version of our Web Design service page:
Page Generator Pro: Polylang: Generated Content: Spanish

With Polylang’s Language Switcher widget, we can switch to the English version:
Page Generator Pro: Polylang: Generated Content: English

Editing that page, we can see that Page Generator Pro has linked the translations automatically for each language, showing us which generated Page contains the English version of the same content for the same service:
Page Generator Pro: Polylang: Generated Content: Spanish Translations