WordPress - How to translate a PDF ?

In this article, you'll learn which kind of PDF Weglot can translate on your WordPress website.



1. Which PDF can be translated by Weglot?

Weglot can translate PDFs on WordPress using the following processes:

When a plugin generates a PDF, by default it will not be translated. Thanks to a filter (a code snippet), Weglot will be able to retrieve the HTML code generated to create the PDF and translate it.

Weglot is currently able to translate the following PDFs:

  • Gravity PDF:

Weglot provides a developer's documentation in which you'll be able to find the filter needed to activate the translation of Gravity PDF.

https://developers.weglot.com/wordpress/use-cases/translate-pdf-with-gravity-pdf

  • WooCommerce PDF Invoice

Weglot provides a developer's documentation in which you'll be able to find the filter needed to activate the translation of invoice PDF generated by WooCommerce.

https://developers.weglot.com/wordpress/use-cases/translate-pdf-for-woocommerce-pdf-invoice


In case you have links displaying your PDFs on your website, and you would like to display your translated PDF on your translated language with Weglot, we invite you to take a look at our other article about How to change a Media file (Image, PDF, etc) on my translated website.

2. How can I add the code snippet?

There are two ways to add the code snippet:

  1. You can install a plugin, like Code Snippet, on your WordPress admin to add the code snippet more easily (recommended):

Once Code Snippet is installed, you can open the Code Snippet's window by clicking on "Snippets" in the left bar of your admin panel.

Once opened, you can press the "Add New" button at the top of the page in order to create a new snippet:

Screenshot showing the location of the Add New button

Once the snippet is created, you can now edit it:

Screenshot showing the steps to follow in order to create a new snippet

In order to translate the Gravity PDF or WooCommerce invoices PDF, you will need to run the snippet "everywhere".

Once you have edited the code snippet, you can save the changes and activate the snippet. Do not hesitate to clear your WordPress cache to see the changes.


  1. Alternatively, the code snippet can be added at the end of your functions.php file:

On your WordPress admin, you can find your functions.php file in the left sidebar, hover over Appearances, then click on "Theme Editor":

In the right sidebar, click on "functions.php". You can add your code snippet at the bottom of this file.

Once the code snippet is added, do not hesitate to clear your WordPress cache to see the changes.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us