<< Previous Page WP EasyCart Documentation Next Page >>

What is WPML

WPML is a popular plugin that is used to convert a WordPress website into multiple languages. More information can be found at WPML's website

Steps For Integration

  1. Ensure language files exist for the WP EasyCart by visiting your EasyCart Admin -> Store Setup -> Advanced Language. Read below if you need to add a language file to fit your requirements.


  2. Ensure the language codes match: Do this by selecting each language from the drop down you looked at in step 1, one at a time. For each, scroll down to the bottom of the page and check the language code. Make sure the language codes match, for example, WPML uses ES for Spanish and by default the EasyCart displays SP, resave after change each to match what WPML uses.


  3. Add a "Store", "Account", and "Cart" page for each WPML language. Keep the pages for default langauge assigned to the store in the store setup (e.g. if you use English as the default, keep the English store, account, and cart pages assigned in the store setup).


  4. For non-default language pages, you should use (example is for a Spanish translation, change to match correct language code): [ec_store language="ES"], [ec_cart language="ES"], and [ec_account language="ES"]


  5. Translate Your Products: Throughout the product setups, you can force a translation of any text by entering a translation of each. For example, if you want a product title to be different for English and German, enter [EN]English Title[/EN][DE]German Title[/DE]. The store will translate based on the WPML language selected.


Language Switcher Fix in Store

If you would like to be able to switch languages within a product, you should add the following code to your theme's functions.php file.

add_filter('icl_ls_languages', 'wpml_ls_filter'); function wpml_ls_filter($languages) { if( isset( $_GET['model_number'] ) ){ global $sitepress; foreach( $languages as $lang_code => $language ){ $languages[$lang_code]['url'] = $languages[$lang_code]['url'] . '/?model_number='.$_GET['model_number']; } } return $languages; }

How to Add a New Language File

Note: Once you have added a language file and accessed the advanced language page, you cannot make changes to the language file directly! In order to prevent changes to language from being overwritten during an upgrade, language data is stored in your database once imported. The following instructions therefore only apply to those who need to add a new language to the system!

  1. Copy any of the existing text files, located in wp-content/plugins/wp-easycart/inc/language/, and rename to something that makes sense.
  2. Open the file and make changes as needed. Keep in mind, json formatting is very specific and any mistake in formatting will result in an error. Please run the file through something like http://jsonlint.com/ before uploading to your server to prevent errors.
  3. Go to your EasyCart Admin -> Store Setup -> Advanced Language to complete the insertion of a new language
  4. If you have made errors in the translation, you must make changes through the advanced language page, NOT THE TXT FILE UPLOADED. If you have a translation that you would like to add to the default EasyCart plugin, please email us with your file and we will add it to the core.