IN 4 SIMPLE STEPS: translate Gravity PDF strings into different languages using Loco Translate Plugin
So, what’s the problem?
Your native language isn’t English, you’ve adjusted your WordPress Site Language and now your admin area gets automatically translated. You’ve got Gravity PDF installed and you’re using one of the Core or Universal templates to generate your PDFs. Your Product fields are grouped together in a nice table at the end of the document, but for reasons unknown to you, the column labels are still in English! “Why won’t it just work,” you frustratingly think to yourself. “The rest of my admin area is being translated. Why won’t this?”
The short answer to that question is we’d love more volunteers to help us translate the free (and full-featured) version of Gravity PDF into more language so it will “just work” for you – to those amazing people who’ve already contributed: we thank you! While that’s a long term solution, it doesn’t solve your immediate problem, and that’s what this article is all about.
With the help of another free plugin called Loco Translate, you’re just four steps away from being a pro string translator. Vamonos (let’s go)! 👇
Step 1: Install Loco Translate Plugin
Navigate to your Plugins page, search for Loco Translate, and click Install Now. Once installed, activate the plugin.(You can also download the plugin from their WordPress.org plugins page).
Step 2: Add a New Language
Click on the newly added Loco Translate admin menu item (on the left under your “Settings” menu).You can see our example site is set to French. Yours will likely differ and you should tweak the instructions to suit.
You’ll then need to 2. Choose a location for the translation file. Steer clear of the Author option as it stores the translations in the plugin directory and it will be overridden when you update Gravity PDF. We’re going to use the default System location instead.
Step 3: Filter and Translate Strings
Before you do the actual translations, you should make a list of all the strings you want to update. For this guide we’re going to be translating the Subtotal and Shipping strings from the Product table.
You’ll notice below the string selection box are two additional boxes. The first shows you the untranslated source text, and the second is where you enter the translated text. In the translation box (the third one) we’re going to enter Sous-total.
Next, we’ll search for the Shipping string. When you locate it you’ll notice that the string includes a placeholder character “%s”. These placeholder characters get dynamically replaced by Gravity PDF at runtime and will be important to keep in your translated version. In the translation box we’ll enter “Livraison (%s)”.
Once you’re happy with the translations click the Register button (in our example it’s the big blue translated Enregistrer button).
Repeat this process for any other strings you need translated.
Step 4: Check your PDF
Now that you’ve completed your translations, let’s check out the PDF. Head to the appropriate Gravity Forms Entry List page and select the “View PDF” link on one of your entries.As you can see, the PDF is correctly displaying the translated strings. Voilà!🧐
This technique works for any language, in any plugin or theme, and isn’t limited to PDF translations. You don’t even need to translate the text. If you aren’t happy with the current text displayed you can change it to something else in the same language.