Using WPML to generate multilingual PDF documents

This tutorial shows you how to generate PDF documents in multiple languages using WooCommerce PDF Invoices & Packing Slips Professional and WPML.

To learn how to do this using the free version of the PDF plugin, see our documentation on determining the PDF language.

Getting Started #

Start by installing and activating the following plugins:

WPML allows you to choose between two different translation modes:

  • Translate Everything  automatically translates your site’s content as you add or edit it. You can also choose to review the automatic translations to ensure they are correct.
  • Translate Some allows you to decide which content to translate, as well as who will translate it. You can choose to translate your content yourself, send it to individual translators, or use a professional translation agency.

If you’re new to WPML, we suggest taking a look at their Getting Started Guide to learn more about the different translation options available.

Using WPML with WooCommerce PDF Invoices & Packing Slips Professional #

From your admin menu, go to WooCommerce > PDF Invoices and click on the Documents tab. If you click through the different documentoptions, you’ll see that some PDF settings now have language tabs.

This is shown in the example below for DocumentsInvoice. As you can see, you can set the Document title and PDF filename for your default language, as well as your secondary language(s).

Language tabs in Documents – Invoices

You can also set your Shop NameShop Address, and Footer in your default and secondary languages from the General tab. When you generate a PDF document, your customer will see these fields in the corresponding language.

A PDF Invoice with the Shop Name, Shop Address, and Footer translated

For additional language settings, click over to the Pro tab and scroll down to Multilingual settings:

Use the drop-down list to define the language of your document(s). You can choose between three options:

  • Order/customer language will generate a PDF in the language your customer places an order in.
  • Site default language sets your site’s default language as the language of the PDF document.
  • Specific language (choose from the available ones) generates your PDF in the language of your choice. You can choose between your site’s default language and secondary language(s).

Translating Strings in WPML #

WPML’s String Translation makes it possible to translate additional texts coming from your plugin:

  1. Go to WPML > Theme and plugins localization and scroll down to Strings in the plugins. Check the box next to WooCommerce PDF Invoices & Packing Slips Professional and click the Scan selected plugins for strings button.
  2. Once scanning is complete, go to WPML > String Translation and use the In domain drop-down menu to search for strings belonging to a certain domain. In our example, we are searching for strings in the woocommerce-pdf-invoices-packing-slips domain.
  3. A list of strings available for translation will appear. Click the plus icon under the language you want to translate your chosen string into. Input your translation and hit enter.
Translating a string with WPML’s String Translation

PDF Showing Strings in the Wrong Language #

If you’re using the Customizer from the Premium Templates extension or a custom filter hook, you may need to auto-register your strings for translation:

  1. Go to WPML > String Translation and scroll down to Auto register strings for translation. Check the box to enable Look for strings while pages are rendered.
  2. Create a PDF document.
  3. Search for the custom strings in the String Translation table and enter the translations for each string.

The Auto register strings for translation feature automatically disables after two hours, but it may slow down your site. We suggest turning it off once you’ve found your strings.