Using Loco Translate to customize translations

Note: A ‘string’ is somewhat synonymous to ‘text’. In this documentation, we are indeed referring to the translatable texts, scripts or characters – depending on your language.

Finding Strings #

Most strings that we are interested in will most likely be included in either WooCommerce, our free plugin, our even in one of our paid extensions.

Remember that the strings could come from any other third-party plugin you installed.

To select a plugin to translate with Loco Translate, go to the path below.

Path: Loco Translate > Plugins.

An image of the loco-translate plugin list
An image of the loco-translate plugin list

For example, you may want to change the “VAT” string translation, as shown in the PDF below:

An image of the VAT string in a pdf

This string originates from the following plugin/extension:
PDF Invoices and Packing Slips for WooCommerce – Professional, so that is what to select in this case.

An image of a successfully found string to translate

Now that this ‘VAT’ string has been sreached for and found, modify this translation to your liking, then click the blue ‘Save’ button.

An image showing translation modification

Result on PDF:

An image showing a translation on the pdf

Troubleshooting #

Synchronize files #

Click on the ‘Sync’ button to synchronize the translations.

As shown in the image below, searching for “VAT” string did not yield any result, due to being out-of-date.

loco-translate-sync-button

This process fetches the currently available source strings and applies them to the existing PO file (translation file). This will result in changes in the available strings, if there are indeed new

If the location of the translation files is set to ‘author’ or ‘system’’, you will very likely receive some WordPress error notices.

An image in loco-translate showing notices

The notices, as shown in the image above:

  • Notice: Translations don’t match template. Run sync to update from wpo_wcpdf_pro.pot.
  • Notice: Changes to this file may be overwritten or deleted when you update WordPress.

The 2nd notice above is because the ‘Author’ location is the location in which the plugin is installed, so this is where the plugin files will be refreshed on plugin-update.

An image of the translation file path

So if you modify translations from the Author location, they will be overridden (lost) on the next plugin update. To fix this, relocate your translation files (see below).

Relocate files #

You may need to Relocate your translations so that they are not overridden on plugin update.

Go to ‘Relocate’:

loco-translate-relocate.png

Select ‘Custom’:

locotranslate-relocate-select-custom.png

Now select ‘Move files’ in order to confirm the changes:

locotranslate-confirm-relocate-move-files.png

Now, your translation changes are safe and will not get overridden.

You possibly may need to Synchronize your translations afterwards. The notice below reads:

  • Notice: Translations don’t match template. Run sync to update from wpo_wcpdf_pro.pot.
An image showing an updated, total string count

From the image above, BEFORE clicking the sync button:

  • Total string count = 328 strings
  • Translation completion = 100%

These values will change once we synchronize our translation files.

An image showing updated translation statistics

From the image above, AFTER clicking the sync button:

  • Total string count = 326 strings (6 fuzzy, 60 untranslated)
  • Translation completion = 80%

Now, you should be able to find all translations relating to the current plugin you are viewing.

When relocating files, if ‘System’ is chosen as the new location – instead of ‘Author’ or ‘Custom’ – this notice will appear:

  • Notice: This directory is managed by WordPress. Removed files may be restored during updates.

It is also possible to set your own custom defined path, if you select ‘Advanced’ instead of ‘Move files’.

An image of the advanced-button for relocating files
An image of a custom defined path for translation files

Translation template file remains out-of-sync #

In some cases, the POT file may remain out-of-sync even if your plugin is of the latest version. This POT file will therefore be missing some needed strings, even though the string may be appearing for you for other languages, strangely. This may be due to a plugin conflict.

Follow these steps to fix this issue:
Select ‘Edit template‘, in order to edit the .pot file.

Search the string. It will likely not be found, just like in the image below. In this example, we are searching for the ‘Original Invoice Number‘ string, but is is not found.

loco-translate-sync-the-pot-file--before.png

Notice on the top right of the image below, that the file ends in ‘.pot‘, instead of ‘.po‘. This is good and means we are indeed modifying the translation template file. However, we are only going to synchronize it.

Now click the sync button:

loco-translate-sync-button.png

…and you should get the screen below, where we can now find the :

loco-translate-sync-the-pot-file--after.png

Now go back to the language you were translating (leave the .pot file and go back to the .po file) and press the Sync button there too!
This would then make your missing strings visible.

Broken Translation: Missing placeholder #

In strings, placeholders look like this:

  • 1st placeholder = %1$s
  • 2nd placeholder = %2$s
  • 3rd placeholder = %3$s
    and the sequence continues…

There are times when the strings in the plugin might actually have an issue with the placeholders missing from the translated string. If some are missing, they need to be fixed in order for the translations to remain in sync, otherwise it is not possible to synchronize them.

In the image below, the error reads:

  • Missing placeholders; source text formatting suggests at least 4.
An image of a broken translation

Though this is indeed something you could fix on your own, please let us know of this issue by contacting us at support@wpovernight.com.

How to fix

Short answer: Add the placeholders to the translation and ensure the translation is correct, or to your liking.

This is the original translation, as our example:

To keep %1$s API limits under control, you are required to activate your Professional extension license to use this service. See how to activate your license %2$shere%4$s, or clear the cache %3$shere%4$s.

This is the broken translation (in French):

Pour garder les limites de l'API %1$s sous contrôle, vous devez activer votre licence d'extension professionnelle pour utiliser ce service. Découvrez comment activer votre licence %2$s.

Upon further observation, it can indeed be seen that the translated string only has 2 placeholders, but the original string has 4 placeholders.

  • This is the part that was missing:
    or clear the cache %3$shere%4$s.
  • The translation of this missing part would be:
    ou videz le cache %3$sici%4$s.

This needs to be added to the translated string to fix it.

Fixed translated string:

Pour garder les limites de l'API %1$s sous contrôle, vous devez activer votre licence d'extension professionnelle pour utiliser ce service. Découvrez comment activer votre licence %2$s, ou videz le cache %3$sici%4$s.

After pasting your fixed translation, remember to save your changes by clicking the ‘save’ button!

An image of the save-button