• Resolved pewgeuges

    (@pewgeuges)


    Hi,

    I use two plugins that are correctly configured for string translation, strings show up in Polylang’s string translation pane, are translated, but the translated pages still show the default strings as configured in the plugins’ settings pages. And it happens not only to me, this is a cross-user, cross-site, cross-plugin problem.

    See for Footnotes: https://wordpress.org/support/topic/reference-container-heading-translations-and-a-collapse-feature/

    This https://wordpress.org/plugins/footnotes plugin ships with a wpml-config.xml file for the reference container label.

    For Table of contents plus https://wordpress.org/plugins/table-of-contents-plus this is the configuration added so far:

    
    <wpml-config>
    	<admin-texts>
    		<key name="toc-options">
    		    <key name="heading_text" />
    		</key>
    	</admin-texts>
    </wpml-config>
    

    The issue is not solved by assigning every language a unique number as in https://github.com/polylang/polylang/issues/109

    Should this be escalated to GitHub as it looks like a bug, although it’s incredible that this would not have been reported and fixed before.

    So my assumption is that it takes more than adding a wpml-config.xml file to get a plugin with configurable strings to work smoothly with Polylang?

    • This topic was modified 2 years, 8 months ago by pewgeuges.
    • This topic was modified 2 years, 8 months ago by pewgeuges.
    • This topic was modified 2 years, 8 months ago by pewgeuges.
    • This topic was modified 2 years, 8 months ago by pewgeuges.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Chouby

    (@chouby)

    Hello,

    Plugins must also follow best practices. One of the most important in the WordPress ecoystem is “Do nothing before the plugins_loaded action is fired”. Why? Because everything done before this action can not be filtered by other plugins.

    I tested Footnotes. It loads its option before the action ‘plugins_loaded’. As Polylang waits for this action to setup the language and the options filters, teh option is not filtered.

    If I delay the initialization of the Footnotes plugin to hook it to the plugins_loaded action, then the translation of teh option works as expected.

    I did not test the other plugin, but I suppose it’s the same issue.

    Thread Starter pewgeuges

    (@pewgeuges)

    @chouby,

    Thank you very much for testing the Footnotes plugin and for your advice and insight.

    As I failed to implement the solution according to https://polylang.pro/dont-take-any-action-before-plugins_loaded-is-fired/, I’ve ended up applying the quick fix just hooking initialization on plugins_loaded in footnotes.php:

    
    /**
     * Allows other plugins to filter the options.
     *
     * @since TBD [after 2.7.3]
     * @contributor @chouby
     * @link https://wordpress.org/support/topic/plugin-string-translations-ineffective/#post-14714185
     */
    add_action( 'plugins_loaded', function() {
    
    	// Initialize the Plugin.
    	$g_obj_mci_footnotes = new Footnotes();
    	// Run the Plugin.
    	$g_obj_mci_footnotes->run();
    
    } );
    

    Code based on current v2.7.3 https://plugins.trac.wordpress.org/browser/footnotes/tags/2.7.3/footnotes.php?rev=2521062#L117

    While loading translations is already hooked on plugins_loaded, loading options surprisingly is not.

    I’ll report back on Footnotes’ forum (done, see https://wordpress.org/support/topic/reference-container-heading-translations-and-a-collapse-feature/#post-14717295) and just escalated it to https://github.com/markcheret/footnotes/issues/189

    Being committed to fixing Footnotes and while I hadn’t got enough time to contribute to TOC+ as well, I didn’t try the same in the latter either, hoping it will be done after reporting to TOC+.

    Many thanks.

    • This reply was modified 2 years, 8 months ago by pewgeuges.
    • This reply was modified 2 years, 8 months ago by pewgeuges.
    • This reply was modified 2 years, 8 months ago by pewgeuges. Reason: Add a docblock
    • This reply was modified 2 years, 8 months ago by pewgeuges.
    • This reply was modified 2 years, 8 months ago by pewgeuges.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Plugin string translations ineffective’ is closed to new replies.