You are currently viewing WPML – WordPress Multilingual Implementation
wpml-wordpress-multilingual-implementation (4)

WPML – WordPress Multilingual Implementation

  • Post published:March 24, 2017

vteam #453 has been working on the project of a community website. The aim of this project was to incorporate international language support according to WordPress standards using the BuddyPress plugin. The WPML plugin was used to provide multilingual functionality to the site.

WPML includes features like WPML String Translation and a core Translation component that supports all international languages and can be customized with custom themes and integrated plug-ins. However, many challenges were faced; the most predominant being the need for high levels of customization and the difficulty involved in the integrated plugins being used on the site already.

vteam #453 formatted all the possible strings with the __(“string to translate”,”domain”) function so the theme could detect the translated string from the WPML String Translation component. So that the translation plugin would be compatible with BuddyPress’ BuddyPress Multilingual plugin, which allows BuddyPress sites to run fully multilingual using the WPML plugin, was used.

Commonly, other plugins use the String Translation function; __(“string to translate”,”domain”) , so it was easy to pick relevant domain of plugin and add translation for strings.

The GravityForms plugin was used on this site to build the main forms like “Contact Us”. So, “Gravity Forms Multilingualcomponent, which is known to work with WMPL was used to translate the forms by picking data from wp-admin > WPML > Language section.

Defined translations of deferent sections were required to be stored in database tables. These sections included:

  • Education Level
  • Featured Items
  • Subjects
  • Subject Areas

Tables of the above mentioned sections have associated translated tables. So, the vteam #453 utilized WPML snippets and constants like ICL_LANGUAGE_CODE to implement customization. For example the use of  ICL_LANGUAGE_CODE is given as:

if( defined('ICL_LANGUAGE_CODE') )
      $subjects_translated = cur_subjects_query(ICL_LANGUAGE_CODE); 
function cur_subjects_query($current_language)
    $q_subjects = "
                    subjects.subjectid as subjectid_orignal,
                    subjects.subject as subject,
                    subjects.displayname as displayname_orignal,
                    subjects_ml.subjectid as subjectid,
                    subjects_ml.displayname as displayname,
                    subjects_ml.language as language
                    FROM subjects
                    INNER JOIN subjects_ml
                    ON subjects.subjectid = subjects_ml.subjectid
                    WHERE subjects_ml.language = '$current_language'
                ORDER BY subjects.displayname asc
                    limit 1000
    return $q_subjects;