Translating Business Directory Plugin to your native language

The instructions below can also be used to modify some of the labels in Business Directory Plugin to use your own words.

Business Directory uses the standard WordPress string externalization mechanism (PO files) to allow you to translate the plugin to any language you wish. We also support the use of WPML if you prefer. This article explains how to create a single-language translation file.

The Translation file can serve TWO purposes:

  • To change the language Business Directory Plugin is displayed in from English to something else.
  • To change labels, strings and messages that you see in English to whatever you want (also in English).

Choose the proper steps based on which workflow you are following.

Please note: Business Directory Plugin does ship with SOME translations already completed for you! Please look under wp-content/plugins/business-directory-plugin/languages on your site server for the available files (as of Jan 2017, we have full Spanish, French, English, German, Arabic, Polish, and Swedish translations included).

Translate Business Directory Plugin into any language

Business Directory Plugin can be translated into any language, per the WordPress text internationalization standards. For more general information about how WordPress supports externalized strings for plugins, please read this article first.

To FULLY translate the plugin to another language, please follow THESE steps:

  1. Start with the POT file from Business Directory Plugin (in the wp-content/plugins/business-directory-plugin/languages directory of the plugin, named WPBDM.pot).
  2. Downloaded the POedit software (You can find it here).
  3. Translate all strings to your preferred language following the instructions in the POEdit documentation.

    IMPORTANT: WordPress does not support fuzzy translations:

    Fuzzy Translations

    If the Needs Work swtich is on, please review the translated string and set the switch to off, to mark the string as translated. Otherwise, WordPress won’t be able to use that string.

  4. Save the file as WPBDM-<langcode_COUNTRY>.po or WPBDM-<langcode>.po, where <langcode> is the ISO 639-1 code for your language and <langcode_COUNTRY> represents your ISO language code/country combination, such as:

    • en_US (English, US)
    • en_UK (English, UK)
    • fr_FR (French, France)
    • pt_BR (Portuguese, Brazil)
    • and others.

    Country codes can be found on this GNU website.

  5. Upload this new language-coded file to the wp-content/languages/plugins/ on your website’s server (if it does not exist, please CREATE this directory first).
  6. The language of the website should be configured directly through General Settings section in the WordPress Dashboard: https://YOURSITE//wp-admin/options-general.php, where YOURSITE is replaced by the domain name of your WordPress site. Pick the correct language setting and be sure to Save Settings.

    For more information on doing this, see this WordPress Codex page on Installing WordPress in your Language.

  7. IMPORTANT: Be sure to flush any browser caching you have in addition to any WordPress/web hosting caching you have so that you can see your new strings.
  8. You should now see your site in the new language, with a few exceptions (see below!)

The instructions above will translate about 95% of the plugin. Further translation must happen in the following places, which are stored in the database:

  1. Your Business Directory Plugin page name must be translated to your native language (under Pages > All Pages).
  2. Strings that are inside the configuration (see under Directory Admin > Manage Options), such as the Terms and Conditions (General tab), the Submit Listing and Sticky Listing messages (Listings tab) must be translated.
  3. Email templates (under Directory Admin > Manage Options, Email tab) must be translated.
  4. Update all field labels, by going to Directory Admin > Manage Form Fields.

After you do all of these, Business Directory Plugin is fully translated.

Changing the Labels of Business Directory Fields

Changing the labels for Business Directory is identical to Translating BD for an entire language, except that you only need to change the strings inside the translation file that you want to change, leaving the rest untouched. This allows you a simple way to customize the labels of Business Directory without modifying the code.

To update some of the plugin’s labels, strings and messages, please follow these steps:

  1. Start with the main POT file from Business Directory Plugin (in the wp-content/plugins/business-directory-plugin/languages directory of the plugin, named WPBDM.pot).
  2. Downloaded the POedit software (You can find it here).
  3. Open the file, and search for the string(s) you wish to change. Change those labels in the file.
  4. Save the file as WPBDM-en_US.po on your local machine. Make sure POEdit also generated a WPBDM-en_US.mo file; you’ll have to upload both of them to your server (SEE BELOW FOR THE RIGHT LOCATIONS). Save a copy of those files on your local machine, just in case.
  5. Upload BOTH of these new language-coded files to the wp-content/languages/plugins/ on your website’s server (if it does not exist, please CREATE this directory first).
  6. WP 4.x users only: The language of the website should be configured directly through General Settings section in the WordPress Dashboard: https://YOURSITE//wp-admin/options-general.php, where YOURSITE is replaced by the domain name of your WordPress site. Pick the correct language setting and be sure to Save Settings. For more information on doing this, see this WordPress Codex page on Installing WordPress in your Language.
  7. IMPORTANT: Be sure to flush any browser caching you have in addition to any WordPress/web hosting caching you have so that you can see your new strings.
  8. View the page you changed in your browser — You should see your custom message there. If not, double check the steps above and make sure the caches are flushed.

Please note that some labels are configured elsewhere. For example, all form field labels are changed by going to Directory Admin > Manage Form Fields. Some strings are also in the General tab of Directory Admin > Manage Options as well. Please be aware of this.

Where should I upload the translation file?

Translations files for other languages (*.po and *.mo files) can be uploaded to one of the following locations:

  1. wp-content/languages/plugins/ (RECOMMENDED)
  2. <plugin-directory>/languages/ (DEFAULT)
  3. <plugin-directory>

<plugin-directory> is usually /wp-content/plugins/business-directory-plugin.

The best practice is to store custom translations in wp-content/languages/plugins/, because that way the translations won’t be deleted during an upgrade. Options 2 and 3 above will be overwritten on upgrade.

As of Business Directory Plugin 4.x, we now support loading translations from some other locations as well: The file wp-content/languages/{plugin-slug}/{plugin-text-domain}-<langcode/langcode_COUNTRY>.mo, if present, will always be loaded, allowing users to overwrite the translation of specific strings. They can create translation files that include only the strings that they want to change. WordPress will use their translations for those strings and use the ones provided by plugin in other cases.

Then, the plugin will check for each of the following files, in the given order, until one of them can be loaded (if the language is set to English/United States – en_US):

  1. wp-content/plugins/{plugin-slug}/languages/{plugin-text-domain}-en_US.mo

    Generated by us, included in the plugin.

  2. wp-content/plugins/{plugin-slug}/{plugin-text-domain}-en_US.mo

    Previous versions included the translations files in here, in the plugin’s root directory.

  3. wp-content/languages/plugins/{plugin-text-domain}-en_US.mo

    WordPress checks for files in this location automatically.

Where {plugin-slug} is business-directory-plugin and {plugin-text-domain} is WPBDM.

Last, but not least: If you are upgrading from an older version of BD and have an old translation file, you can UPGRADE the translation file instead of starting from scratch! See this article on how to do that: How to Upgrade your BD Translation File for New Plugin Versions.

BD also supports the use of WPML to do translations as well. We cover how to configure that in this article.

Furthermore, here’s a guide for translating WP plugins in general (including language codes, naming conventions, and encodings): https://urbangiraffe.com/articles/translating-wordpress-themes-and-plugins/.