Title: WPML Compatibility fix
Last modified: June 1, 2018

---

# WPML Compatibility fix

 *  Resolved [rotbieest](https://wordpress.org/support/users/rotbieest/)
 * (@rotbieest)
 * [8 years ago](https://wordpress.org/support/topic/wpml-compatibility-fix/)
 * Hi there,
 * First of all, thanks for reviving the old Table of Contents Plus plugin, much
   appreciated!
 * Secondly, kindly find my two cents below to make it even better!
 * I am opening a new ticket for this because the other had already been marked 
   as ‘resolved’ and wasn’t my topic to begin with.
 * I am referring to this one: [https://wordpress.org/support/topic/translate-with-wpml-5/](https://wordpress.org/support/topic/translate-with-wpml-5/)
 * I managed to make this work based on an old support topic related to the original
   Table of Contents Plus plugin from which this plugin was originally forked.
 * View the support topic here:
    [https://wpml.org/forums/topic/table-of-contents-plus-plugin/](https://wpml.org/forums/topic/table-of-contents-plus-plugin/)
 * Summary of the above:
 * —–
    The cause of this is issue is in the code of the Table of Contents plugin.
   For a final solution I recommend you to contact the authors of the plugin. As
   a workaround you can go to /wp-content/plugins/table-of-contents-plus/toc.php
   line 1529 and change:
 * `$html .= '<p class="toc_title">' . htmlentities( $toc_title, ENT_COMPAT, 'UTF-
   8' ) . '</p>';`
 * to
 * `$html .= '<p class="toc_title">' . __(htmlentities( $toc_title, ENT_COMPAT, '
   UTF-8' )) . '</p>';`
    —–
 * Now, I’ve had to change some things around because the code has since changed.
 * I managed to make things work as follows:
 * Go to /wp-content/plugins/easy-table-of-contents/easy-table-of-contents.php line
   1053 and change:
 * `$html .= '<p class="ez-toc-title">' . esc_html( htmlentities( $toc_title, ENT_COMPAT,'
   UTF-8' ) ) . '</p>' . PHP_EOL;`
 * to
 * `$html .= '<p class="ez-toc-title">' . __( esc_html( htmlentities( $toc_title,
   ENT_COMPAT, 'UTF-8' ) ) ). '</p>' . PHP_EOL;`
 * Then, purge cache, deactivate Easy Table of contents plugin and re-activate (
   make sure you have WPML String Translation installed).
 * Upon reactivation, WPML String Translation will scan the newly activated plugin
   for strings and the string will appear in string translation.
 * I couldn’t find it immediately though so I had to do a search for “Table of Contents”
   => the string that is set as default as the TOC header label.
 * Please note that the text domain is not set properly, it is under ‘default’ instead
   of under the text domain ‘easy-table-of-contents’.
 * Surely, the plugin developer will know how to do this properly, as the above 
   is only a workaround and may even have improper coding. But at least it works
   for now.
 * To be clear here, WPML has nothing to do with this. It is the markup of the code
   in Easy Table of Contents plugin that is the problem. If you do not know how 
   to apply the correct markup, I am sure they (WPML) will be glad to assist you
   with this though.
 * I’m not a developer myself but I believe the problem is the same as the below
   topic:
 * Source: [https://wpml.org/forums/topic/the-wpml-doesnt-recognize-woocommerce-price-string/](https://wpml.org/forums/topic/the-wpml-doesnt-recognize-woocommerce-price-string/)
 * —–
    The strings added in the PHP code need to be wrapped in a GetText call to
   be registered by WPML String Translation
 * Relevant Documentation:
    [https://wpml.org/faq/language-setup/](https://wpml.org/faq/language-setup/)
   [https://wpml.org/documentation/support/troubleshooting-string-localization/](https://wpml.org/documentation/support/troubleshooting-string-localization/)
   [https://wpml.org/2009/05/wordpress-theme-localization/](https://wpml.org/2009/05/wordpress-theme-localization/)
   [http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/](http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/)—–
 * Hopefully you can find the time to make this plugin even better by fixing this!
   Making the plugin WPML compatible is surely a good thing!
 * Kind regards

Viewing 1 replies (of 1 total)

 *  [Steven](https://wordpress.org/support/users/shazahm1hotmailcom/)
 * (@shazahm1hotmailcom)
 * [8 years ago](https://wordpress.org/support/topic/wpml-compatibility-fix/#post-10350121)
 * I made this change to the forthcoming 2.0 release.
    The actual code change will
   be:
 *     ```
       $html .= '<p class="ez-toc-title">' . esc_html__( htmlentities( $toc_title, ENT_COMPAT, 'UTF-8' ), 'easy-table-of-contents' ). '</p>' . PHP_EOL;
       ```
   
 * If you could test this ahead of the actual release and confirm it works as expected,
   I would appreciate it.
 * ps. Even though this is now wrapped in a gettext call, if a user changes the 
   default string in the settings from “Table of Contents” to anything else, it 
   will no longer work. Sort of… In WPML you would instead add the translates to
   title in the settings and not the default title. Hope that makes sense.

Viewing 1 replies (of 1 total)

The topic ‘WPML Compatibility fix’ is closed to new replies.

 * ![](https://ps.w.org/easy-table-of-contents/assets/icon-256x256.png?rev=3045459)
 * [Easy Table of Contents](https://wordpress.org/plugins/easy-table-of-contents/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/easy-table-of-contents/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/easy-table-of-contents/)
 * [Active Topics](https://wordpress.org/support/plugin/easy-table-of-contents/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/easy-table-of-contents/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/easy-table-of-contents/reviews/)

## Tags

 * [gettext](https://wordpress.org/support/topic-tag/gettext/)

 * 1 reply
 * 2 participants
 * Last reply from: [Steven](https://wordpress.org/support/users/shazahm1hotmailcom/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/wpml-compatibility-fix/#post-10350121)
 * Status: resolved