Using Language Files To Help WPML With Gettext

The following findings are current as of WPML 3.4.0 and SLP 4.5.07.

GetText Strings

The short version:  When using WPML to switch languages you will want to make sure your alternate language files are up-to-date and installed in the Store Locator Plus languages folder.   You can use Loco Translate to sync and generate updated .po/.mo files.  You may want to check out the WordPress Translate for Store Locator Plus site and download the latest .po and .mo files from there.

The WPML String Translations set manually via the user in the admin panel is NOT used when for the plugin when a gettext string is used.  Developer’s Note: WPML String Translations appear to only be used when employing the wpml_translate_string or wpml_translate_single_string filters.

Store Locator Plus sets most of the default text in the Text Manager class using gettext functions.     When a page implements the [slplus] shortcode the string presented in various locations, the default Find Button label, for example, is NOT loaded in the alternate language despite using the WPML String Translation plugin.

SLP Text String Management Class
SLP Text String Management Class

Manually setting the translation via the WPML String Translation admin interface does not seem to to be used by default despite WPML Multilingual CMS, WPML String Translation, and WPML Translation Management being installed and active.

WPML String Translations Ignored
WPML String Translations Ignored
 String Translations Ignored - UI
String Translations Ignored – UI

 

 

Using Loco Translate To Help WPML

By using Loco Translate to sync and save an updated .po/.mo language file to the SLP languages directory, the WPML language switcher will now pick up the proper translation.  The process I used to get the Italian translation for “Find Locations” to show up when I select the Italian version of the page:

  1. Install and Active Loco Translate
  2. Go To Manage Translations in Loco Translate
  3. Select the existing it_IT translation file next to Store Locator Plus.
  4. Click sync to load in the latest gettext() calls that need translation.
  5. Add the missing “Find Locations” text in Italian.
  6. Save the file.

Now my Italian version of the English “Locations” page shows the proper text on the Find Locations button when I switch from the English page to the Italian page.

WPML Using Language Files To Set Text
WPML Using Language Files To Set Text

wpml-config.xml

This file resides in the root directory of the plugin.

The file is only loaded on admin pages.

The admin-texts node is only used for changing the text on the admin options, serial or singular, only.

The user’s language on the admin page is based on the language selected in their PROFILE, not via the language selector on the admin bar.

Related Articles

WPML.org : Translating wp_options Entries

WPML.org: The wpml-config.xml File