Translating WP Full Stripe plugin labels

Introduction

WP Full Stripe displays its labels in US English by default.

You might need to customize the labels for many reasons:

  • You’d like to use the plugin in a different language
  • You’d need to change some labels for a different English-speaking region (UK for example)
  • Your area of specialization uses a different terminology

There are two ways to change the plugin labels:

  1. Changing the labels in the program code directly
    This is not recommended as your changes would be overwritten by the next plugin update.
  2. Creating a label resource file for your translations
    The resource file is independent of the plugin installation so it will survive your plugin updates intact.
    This is the recommended way to translate the plugin.

This article describes how you can translate the plugin labels by creating a resource file.

Important note: In the context of this article, we refer to “translation” even when you change some US English labels to their regional counterparts, like changing “Zip” (En US) to “Postcode” (En UK).

How to translate the plugin labels

In order to translate the plugin text labels, follow these steps:

  1. Copy the file wp-content/plugins/wp-full-stripe/languages/wp-full-stripe.pot
    to wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-<language code>_<country code>.po

    where <language code> is the two-letter ISO language code and <country code> is the two-letter ISO country code.

    Please refer to Locale names section of the gettext utility manual for more information.

  2. Edit the file wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-<language code>_<country code>.po, and add your translations to it.

    If you’d like to change only a few labels, then all other labels should be removed from the file!

  3. Use an online service like http://www.po2mo.net to convert the .po file to an .mo file.

    Copy the newly created .mo file to the wp-content/plugins/wp-full-stripe/languages folder and make sure that the filename conforms to wp-full-stripe-<language code>_<country code>.mo.

    Alternatively, you can:

    • Use a desktop application like Poedit to convert a .po file to an .mo file; or

    • Run the msgfmt utility (part of the gettext distribution) to convert the .po file to an .mo file, for example:

      msgfmt -cv -o \
      wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-de_DE.mo \
      wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-de_DE.po

      Make sure that the newly created .mo file is in the wp-content/plugins/wp-full-stripe/languages folder and its name conforms to wp-full-stripe-<language code>_<country code>.mo.

Real-world example: Changing the ‘Zip’ and ‘State’ labels to ‘Postcode’ and ‘County’ for a UK-based website

As described in the previous section, creating the translation for the ‘Zip’ and ‘State’ labels require the following steps:

  1. Copy the file wp-content/plugins/wp-full-stripe/languages/wp-full-stripe.pot
    to wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-en_GB.po

  2. Edit the wp-full-stripe-en_GB.po file, remove all the labels that you don’t want to translate, and translate the ‘Zip’ and ‘State’ labels so the file looks like this:

    msgid "Zip"
    msgstr "Postcode"

    msgid "State"
    msgstr "County"

  3. Use http://www.po2mo.net to convert the .po file to an .mo file.

    Copy the newly created .mo file to the wp-content/plugins/wp-full-stripe/languages/wp-full-stripe-en_GB.mo .

    Important: Please double check dashes and underscores in the filename, because po2mo spoils the filename, it has to be adjusted manually.

  4. Make sure that language of your WordPress site is set to “English (UK)”, verify it on the “Settings -> General” page in WP admin:
in Customization